@ouro.bot/cli 0.1.0-alpha.1133 → 0.1.0-alpha.1135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1135",
|
|
6
|
+
"changes": [
|
|
7
|
+
"When my provider refuses a request, I hear why and answer you myself instead of you getting a switch-provider message to deal with."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1134",
|
|
12
|
+
"changes": [
|
|
13
|
+
"I now see a session the app calls running but whose history has not grown for half an hour as stuck, so a hung session no longer hides among the working ones."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1133",
|
|
6
18
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1135</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
package/dist/heart/core.js
CHANGED
|
@@ -18,6 +18,8 @@ exports.settleContentMismatchError = settleContentMismatchError;
|
|
|
18
18
|
exports.getSettleRetryError = getSettleRetryError;
|
|
19
19
|
exports.stripLastToolCalls = stripLastToolCalls;
|
|
20
20
|
exports.repairOrphanedToolCalls = repairOrphanedToolCalls;
|
|
21
|
+
exports.isRejectedRequest = isRejectedRequest;
|
|
22
|
+
exports.dropReplayedReasoning = dropReplayedReasoning;
|
|
21
23
|
exports.runAgent = runAgent;
|
|
22
24
|
const config_1 = require("./config");
|
|
23
25
|
const identity_1 = require("./identity");
|
|
@@ -966,6 +968,24 @@ function isContextOverflow(err) {
|
|
|
966
968
|
return true;
|
|
967
969
|
return false;
|
|
968
970
|
}
|
|
971
|
+
// The provider refused the request itself (a 400 that is not a context overflow): something in what the runtime sent, not
|
|
972
|
+
// an outage. The agent gets one corrected retry instead of the turn failing (a replayed reasoning signature, a gap in tool results).
|
|
973
|
+
function isRejectedRequest(err) {
|
|
974
|
+
return err instanceof Error && err.status === 400 && !isContextOverflow(err);
|
|
975
|
+
}
|
|
976
|
+
// Reasoning blocks replayed from earlier turns are the agent's private scratch, and a provider may refuse their signatures.
|
|
977
|
+
// The current turn's own blocks stay: the provider needs them to continue tool use within the turn.
|
|
978
|
+
function dropReplayedReasoning(messages, keepFrom) {
|
|
979
|
+
return messages.map((message, index) => {
|
|
980
|
+
if (index >= keepFrom || message.role !== "assistant")
|
|
981
|
+
return message;
|
|
982
|
+
const record = message;
|
|
983
|
+
if (!("_thinking_blocks" in record) && !("_reasoning_items" in record))
|
|
984
|
+
return message;
|
|
985
|
+
const { _thinking_blocks: _thinking, _reasoning_items: _reasoning, ...rest } = record;
|
|
986
|
+
return rest;
|
|
987
|
+
});
|
|
988
|
+
}
|
|
969
989
|
const RETRY_LABELS = {
|
|
970
990
|
"auth-failure": "auth error",
|
|
971
991
|
"usage-limit": "usage limit",
|
|
@@ -1170,6 +1190,8 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1170
1190
|
let done = false;
|
|
1171
1191
|
let lastUsage;
|
|
1172
1192
|
let overflowRetried = false;
|
|
1193
|
+
let rejectedRequestRetried = false;
|
|
1194
|
+
let replayedReasoningDropped = false;
|
|
1173
1195
|
let outcome = "settled";
|
|
1174
1196
|
let completion;
|
|
1175
1197
|
let suspension;
|
|
@@ -1508,7 +1530,10 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1508
1530
|
// Whatever path built this request, every tool call reaches the provider with a result: a gap the runtime left must
|
|
1509
1531
|
// never 400 the turn and leave the agent unable to answer.
|
|
1510
1532
|
repairOrphanedToolCalls(attemptMessages);
|
|
1511
|
-
|
|
1533
|
+
const currentTurnStart = () => currentUserMessage ? Math.max(0, attemptMessages.indexOf(currentUserMessage)) : 0;
|
|
1534
|
+
if (replayedReasoningDropped)
|
|
1535
|
+
attemptMessages = dropReplayedReasoning(attemptMessages, currentTurnStart());
|
|
1536
|
+
if (rejectedAttempt.length > 0 || canonicalBudget.status !== "within_budget" || replayedReasoningDropped)
|
|
1512
1537
|
providerRuntime.resetTurnState(attemptMessages);
|
|
1513
1538
|
const turnCallbackBufferRef = { current: null };
|
|
1514
1539
|
const callProviderTurn = async () => {
|
|
@@ -1568,6 +1593,22 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
1568
1593
|
callbacks.onError(new Error("context trimmed, retrying..."), "transient");
|
|
1569
1594
|
return callProviderTurn();
|
|
1570
1595
|
}
|
|
1596
|
+
if (isRejectedRequest(error) && !rejectedRequestRetried) {
|
|
1597
|
+
// Never leave the agent unable to answer: correct what the runtime sent, tell the agent why, and let it carry on.
|
|
1598
|
+
rejectedRequestRetried = true;
|
|
1599
|
+
replayedReasoningDropped = true;
|
|
1600
|
+
const detail = error.message;
|
|
1601
|
+
attemptMessages = dropReplayedReasoning(attemptMessages, currentTurnStart());
|
|
1602
|
+
repairOrphanedToolCalls(attemptMessages);
|
|
1603
|
+
attemptMessages = [...attemptMessages, {
|
|
1604
|
+
role: "user",
|
|
1605
|
+
content: `[runtime] The provider refused my last request (${detail}). The runtime dropped reasoning replayed from earlier turns and closed any tool call left without a result. I carry on with the turn from here.`,
|
|
1606
|
+
}];
|
|
1607
|
+
providerRuntime.resetTurnState(attemptMessages);
|
|
1608
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "engine", event: "engine.rejected_request_recovered", message: "provider refused the request; retrying once with corrected history", meta: { provider: providerRuntime.id, model: providerRuntime.model, detail: String(detail).slice(0, 300) } });
|
|
1609
|
+
callbacks.onError(new Error("provider refused the request, correcting and retrying..."), "transient");
|
|
1610
|
+
return callProviderTurn();
|
|
1611
|
+
}
|
|
1571
1612
|
throw error;
|
|
1572
1613
|
}
|
|
1573
1614
|
};
|
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.realRunFile = exports.HOUSESITTER_ENV = exports.SEND_WAIT_MS = void 0;
|
|
39
|
+
exports.realRunFile = exports.HUNG_MS = exports.HOUSESITTER_ENV = exports.SEND_WAIT_MS = void 0;
|
|
40
40
|
exports.defaultStateDir = defaultStateDir;
|
|
41
41
|
exports.assertSessionId = assertSessionId;
|
|
42
42
|
exports.eventLogPath = eventLogPath;
|
|
@@ -89,6 +89,8 @@ const MAX_EVENT_BYTES = 8 * 1024 * 1024;
|
|
|
89
89
|
const MESSAGE_MAX_CHARS = 4_000;
|
|
90
90
|
/** A cut loop this fresh may just be a turn the database has not marked running yet. */
|
|
91
91
|
const STUCK_GRACE_MS = 120_000;
|
|
92
|
+
/** A session the app says is running whose history, sub-agents included, has not grown for this long is hung. */
|
|
93
|
+
exports.HUNG_MS = 30 * 60_000;
|
|
92
94
|
const SESSION_ID = /^[A-Za-z0-9-]+$/;
|
|
93
95
|
const ASK_TOOLS = new Set(["ask_user", "ask_followup_question", "request_user_input"]);
|
|
94
96
|
const PLAN_TOOLS = new Set(["exit_plan_mode"]);
|
|
@@ -330,31 +332,36 @@ function tailFacts(events) {
|
|
|
330
332
|
return { awaiting, loopCut, detail, lastActivity, ...(prompt ? { prompt } : {}) };
|
|
331
333
|
}
|
|
332
334
|
const factsCache = new Map();
|
|
333
|
-
/** The tail facts, re-read only when the log changed, so a periodic snapshot stays cheap. */
|
|
335
|
+
/** The tail facts and when the log was last written, re-read only when the log changed, so a periodic snapshot stays cheap. */
|
|
334
336
|
function cachedTailFacts(stateDir, id) {
|
|
335
337
|
const file = eventLogPath(id, { stateDir });
|
|
336
338
|
let key = "missing";
|
|
339
|
+
let writtenAtMs = null;
|
|
337
340
|
try {
|
|
338
341
|
const stat = fs.statSync(file);
|
|
339
342
|
key = `${stat.size}:${stat.mtimeMs}`;
|
|
343
|
+
writtenAtMs = stat.mtimeMs;
|
|
340
344
|
}
|
|
341
345
|
catch {
|
|
342
346
|
// No log yet: the facts of an empty history.
|
|
343
347
|
}
|
|
344
348
|
const cached = factsCache.get(file);
|
|
345
349
|
if (cached?.key === key)
|
|
346
|
-
return cached
|
|
347
|
-
const
|
|
348
|
-
factsCache.set(file,
|
|
349
|
-
return
|
|
350
|
+
return cached;
|
|
351
|
+
const entry = { key, facts: tailFacts(tailEvents(stateDir, id, STATUS_TAIL_BYTES)), writtenAtMs };
|
|
352
|
+
factsCache.set(file, entry);
|
|
353
|
+
return entry;
|
|
350
354
|
}
|
|
351
|
-
function classify(isRunning, facts, nowMs) {
|
|
355
|
+
function classify(isRunning, facts, nowMs, writtenAtMs = null) {
|
|
352
356
|
if (facts.awaiting === "permission")
|
|
353
357
|
return { state: "waiting", detail: "waiting for a permission answer" };
|
|
354
358
|
if (facts.awaiting)
|
|
355
359
|
return { state: "waiting", detail: `waiting for the person's ${facts.awaiting === "plan" ? "plan approval" : "answer"}` };
|
|
356
|
-
if (isRunning)
|
|
360
|
+
if (isRunning) {
|
|
361
|
+
if (writtenAtMs !== null && nowMs - writtenAtMs >= exports.HUNG_MS)
|
|
362
|
+
return { state: "stuck", detail: `the app says it is running, but its history has not grown for ${Math.round((nowMs - writtenAtMs) / 60_000)} min` };
|
|
357
363
|
return { state: "working", detail: "the app says it is running" };
|
|
364
|
+
}
|
|
358
365
|
if (facts.loopCut) {
|
|
359
366
|
const at = Date.parse(facts.lastActivity ?? "");
|
|
360
367
|
if (!Number.isNaN(at) && nowMs - at < STUCK_GRACE_MS)
|
|
@@ -374,10 +381,10 @@ function listAppSessions(options = {}) {
|
|
|
374
381
|
if (seen.has(row.id) || !SESSION_ID.test(row.id))
|
|
375
382
|
continue;
|
|
376
383
|
seen.add(row.id);
|
|
377
|
-
const facts = cachedTailFacts(stateDir, row.id);
|
|
384
|
+
const { facts, writtenAtMs } = cachedTailFacts(stateDir, row.id);
|
|
378
385
|
const isRunning = row.is_running === 1;
|
|
379
386
|
const repositoryTrust = trusts.get(row.id);
|
|
380
|
-
const { state, detail } = repositoryTrust ? { state: "waiting", detail: "waiting for a repository trust decision" } : classify(isRunning, facts, now);
|
|
387
|
+
const { state, detail } = repositoryTrust ? { state: "waiting", detail: "waiting for a repository trust decision" } : classify(isRunning, facts, now, writtenAtMs);
|
|
381
388
|
rows.push({
|
|
382
389
|
id: row.id,
|
|
383
390
|
name: row.name || row.title || (row.workspace_id ? "(unnamed)" : "(unnamed chat)"),
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1135",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1135",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|