niahere 0.5.3 → 0.5.4
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/package.json +1 -1
- package/src/core/runner.ts +17 -2
package/package.json
CHANGED
package/src/core/runner.ts
CHANGED
|
@@ -125,15 +125,30 @@ export async function runJobAcrossChain(
|
|
|
125
125
|
): Promise<RunnerOutput> {
|
|
126
126
|
const cursor = new ChainCursor(chain);
|
|
127
127
|
let output: RunnerOutput = { agentText: "", sessionId: "", error: "no model configured" };
|
|
128
|
+
const abandoned: string[] = [];
|
|
129
|
+
|
|
130
|
+
// The last entry's message alone hides why the chain started walking, which
|
|
131
|
+
// is usually the more useful half.
|
|
132
|
+
const withTrail = (out: RunnerOutput): RunnerOutput =>
|
|
133
|
+
out.error && abandoned.length > 0 ? { ...out, error: `${out.error} (after ${abandoned.join("; ")})` } : out;
|
|
128
134
|
|
|
129
135
|
for (let entry = cursor.current; entry; ) {
|
|
130
136
|
output = await runEntry(entry, sessionCtx, jobPrompt, onActivity, activeRoom);
|
|
131
|
-
if (!output.failover) return output;
|
|
137
|
+
if (!output.failover) return withTrail(output);
|
|
132
138
|
|
|
133
139
|
const from = describeEntry(entry);
|
|
140
|
+
if (output.error) abandoned.push(`${from}: ${output.error}`);
|
|
134
141
|
entry = cursor.advance(output.failover);
|
|
135
|
-
if (entry)
|
|
142
|
+
if (entry) {
|
|
143
|
+
log.warn(
|
|
144
|
+
{ from, to: describeEntry(entry), scope: output.failover, err: output.error, terminal_reason: output.terminalReason },
|
|
145
|
+
"failing over to next model",
|
|
146
|
+
);
|
|
147
|
+
}
|
|
136
148
|
}
|
|
149
|
+
|
|
150
|
+
// The chain ran out: the final entry's own failure is already the last trail
|
|
151
|
+
// entry, so reporting it twice adds nothing.
|
|
137
152
|
return output;
|
|
138
153
|
}
|
|
139
154
|
|