@gaunt-sloth/core 2.0.0-alpha.22 → 2.0.0-alpha.24
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/README.md +43 -18
- package/dist/config/defaults.d.ts +5 -7
- package/dist/config/defaults.js +3 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/loader.d.ts +40 -0
- package/dist/config/loader.js +179 -6
- package/dist/config/loader.js.map +1 -1
- package/dist/config/profiles.d.ts +68 -0
- package/dist/config/profiles.js +93 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/schema.d.ts +69 -2
- package/dist/config/schema.js +87 -5
- package/dist/config/schema.js.map +1 -1
- package/dist/config/types.d.ts +103 -5
- package/dist/config/types.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +26 -1
- package/dist/core/GthAbstractAgent.js +122 -1
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.js +40 -0
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +99 -0
- package/dist/core/GthLangChainAgent.js +333 -2
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/debugCapture.d.ts +16 -0
- package/dist/core/debugCapture.js.map +1 -1
- package/dist/core/plainToolIndication.js +48 -28
- package/dist/core/plainToolIndication.js.map +1 -1
- package/dist/core/refusal.d.ts +53 -0
- package/dist/core/refusal.js +129 -0
- package/dist/core/refusal.js.map +1 -0
- package/dist/core/runStats.d.ts +14 -3
- package/dist/core/runStats.js +48 -3
- package/dist/core/runStats.js.map +1 -1
- package/dist/core/toolCallRepair/grammar.d.ts +41 -0
- package/dist/core/toolCallRepair/grammar.js +116 -0
- package/dist/core/toolCallRepair/grammar.js.map +1 -0
- package/dist/core/toolCallRepair/index.d.ts +2 -0
- package/dist/core/toolCallRepair/index.js +7 -0
- package/dist/core/toolCallRepair/index.js.map +1 -0
- package/dist/core/toolCallRepair/payload.d.ts +36 -0
- package/dist/core/toolCallRepair/payload.js +341 -0
- package/dist/core/toolCallRepair/payload.js.map +1 -0
- package/dist/core/toolCallRepair/promote.d.ts +45 -0
- package/dist/core/toolCallRepair/promote.js +90 -0
- package/dist/core/toolCallRepair/promote.js.map +1 -0
- package/dist/core/toolDisplay.d.ts +14 -1
- package/dist/core/toolDisplay.js +69 -12
- package/dist/core/toolDisplay.js.map +1 -1
- package/dist/core/toolOutputChannel.d.ts +33 -6
- package/dist/core/toolOutputChannel.js +61 -8
- package/dist/core/toolOutputChannel.js.map +1 -1
- package/dist/core/types.d.ts +22 -0
- package/dist/providers/geminiSchemaSanitizer.d.ts +6 -3
- package/dist/providers/geminiSchemaSanitizer.js +152 -6
- package/dist/providers/geminiSchemaSanitizer.js.map +1 -1
- package/dist/providers/modelDiscovery.d.ts +18 -4
- package/dist/providers/modelDiscovery.js +67 -17
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/openai.js +34 -0
- package/dist/providers/openai.js.map +1 -1
- package/dist/utils/crashHandler.d.ts +87 -0
- package/dist/utils/crashHandler.js +128 -0
- package/dist/utils/crashHandler.js.map +1 -0
- package/dist/utils/debugDump.d.ts +58 -0
- package/dist/utils/debugDump.js +149 -15
- package/dist/utils/debugDump.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +22 -8
- package/dist/utils/llmUtils.js +48 -8
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/redactSecrets.js +68 -20
- package/dist/utils/redactSecrets.js.map +1 -1
- package/package.json +1 -1
- package/schema/gsloth-config.schema.json +224 -5
|
@@ -7,8 +7,258 @@ import { isToolAllowed } from '#src/utils/toolMatching.js';
|
|
|
7
7
|
import { appendOsShellNote, appendCwdNote, appendCommitCoAuthorNote, appendModelContextNote, appendMcpServerInstructionsNote, resolveModelIdentity, } from '#src/utils/systemPromptNotes.js';
|
|
8
8
|
import { isShellCommandFailedError } from '#src/core/shell/ShellCommandFailedError.js';
|
|
9
9
|
import { extractDebugRequestExtras } from '#src/core/debugCapture.js';
|
|
10
|
+
import { promoteTextEmittedToolCallMessage } from '#src/core/toolCallRepair/index.js';
|
|
10
11
|
import { AIMessage, ToolMessage } from '@langchain/core/messages';
|
|
11
12
|
import { createAgent, createMiddleware } from 'langchain';
|
|
13
|
+
/**
|
|
14
|
+
* GS2-36 — default cap for the tool-error retry budget: how many status:'error' tool results may
|
|
15
|
+
* accrue back-to-back (no successful tool result in between) before the run is ended gracefully.
|
|
16
|
+
* Small on purpose: it still lets the model try a couple of genuine recovery variants (the whole
|
|
17
|
+
* point of feeding errors back — GS2-32 showed the model routes around a surfaced error in 1–2
|
|
18
|
+
* tries) while stopping a runaway self-inflicted loop long before createAgent's coarse
|
|
19
|
+
* recursionLimit backstop would.
|
|
20
|
+
*/
|
|
21
|
+
export const MAX_CONSECUTIVE_TOOL_ERRORS = 5;
|
|
22
|
+
/**
|
|
23
|
+
* GS2-36 — the tool-error retry budget as a standalone, testable middleware factory (exported so the
|
|
24
|
+
* real thing can be unit-tested and exercised in a real `createAgent` graph, mirroring
|
|
25
|
+
* `createPathNamespaceCorrectionMiddleware`).
|
|
26
|
+
*
|
|
27
|
+
* Runs in `beforeModel` (like langchain's own `modelCallLimitMiddleware`): after the tools node has
|
|
28
|
+
* appended its result(s) and before the next model call is spent, it walks the trailing messages and
|
|
29
|
+
* counts CONSECUTIVE errored tool results — a `ToolMessage` with `status: 'error'` (the shape the
|
|
30
|
+
* shell/MCP softeners produce; GthAbstractAgent maps `status==='error' → isError`). The walk skips
|
|
31
|
+
* the assistant tool-call requests between rounds, and RESETS on the first successful tool result
|
|
32
|
+
* (progress / diagnosis) or a Human/System message (a fresh user turn). Once the count reaches the
|
|
33
|
+
* cap it returns `{ jumpTo: 'end', messages: [<action-oriented notice>] }`, ending the run without
|
|
34
|
+
* spending another model call.
|
|
35
|
+
*
|
|
36
|
+
* Scope: counts `status: 'error'` results only. The recoverable fs error STRINGS
|
|
37
|
+
* (`write_file`/`edit_file`/…) are `status: 'success'` by the write_file precedent, so a pure fs
|
|
38
|
+
* error loop is deliberately NOT capped here — it stays bounded by the coarse `recursionLimit` and is
|
|
39
|
+
* the remit of the loop-DETECTION node (EXT-36). Counting `status: 'error'` overall (not per-tool)
|
|
40
|
+
* catches both same-tool and alternating-tool error loops with one robust rule.
|
|
41
|
+
*/
|
|
42
|
+
export function createToolErrorBudgetMiddleware(maxConsecutiveErrors = MAX_CONSECUTIVE_TOOL_ERRORS) {
|
|
43
|
+
return createMiddleware({
|
|
44
|
+
name: 'GthLeanToolErrorBudget',
|
|
45
|
+
beforeModel: {
|
|
46
|
+
canJumpTo: ['end'],
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
hook: (state) => {
|
|
49
|
+
const messages = Array.isArray(state?.messages) ? state.messages : [];
|
|
50
|
+
let consecutive = 0;
|
|
51
|
+
let lastErrorContent = '';
|
|
52
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
53
|
+
const msg = messages[i];
|
|
54
|
+
if (ToolMessage.isInstance(msg)) {
|
|
55
|
+
if (msg.status === 'error') {
|
|
56
|
+
consecutive++;
|
|
57
|
+
if (!lastErrorContent) {
|
|
58
|
+
lastErrorContent = typeof msg.content === 'string' ? msg.content : '';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// A successful tool result — the model is making progress / diagnosing, so the
|
|
63
|
+
// unrecovered-error streak is broken. Stop the walk (reset).
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (AIMessage.isInstance(msg)) {
|
|
68
|
+
// The assistant tool-call request that produced the error above; skip and keep counting.
|
|
69
|
+
// GS2-72: this `continue` INTENTIONALLY also skips the budget's OWN injected terminal
|
|
70
|
+
// notice (itself an AIMessage). If the run re-enters beforeModel on the same thread after
|
|
71
|
+
// a jumpTo:'end' (a re-invoke on the same thread — e.g. the no-checkpointer degrade of
|
|
72
|
+
// the string path's empty-stream fallback, or a later turn that keeps erroring), skipping
|
|
73
|
+
// the notice lets the walk still reach the errored results and re-trip deterministically.
|
|
74
|
+
// Do NOT special-case the notice to reset/break here — treating it as a fresh-turn
|
|
75
|
+
// boundary would let the capped loop resume.
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// A Human/System message: a fresh user-turn boundary — earlier errors don't count.
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (consecutive >= maxConsecutiveErrors) {
|
|
84
|
+
const firstLine = (lastErrorContent.split('\n')[0] ?? '').slice(0, 300);
|
|
85
|
+
const notice = `Stopped after ${consecutive} consecutive failed tool calls to avoid a retry loop that ` +
|
|
86
|
+
'keeps spending tokens without making progress' +
|
|
87
|
+
(firstLine ? ` (last error: ${firstLine})` : '') +
|
|
88
|
+
'. Do not repeat the same call: inspect the error, then change your approach — different ' +
|
|
89
|
+
'arguments, a narrower path, or a different tool — or report the blocker to the user.';
|
|
90
|
+
return { jumpTo: 'end', messages: [new AIMessage(notice)] };
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* EXT-36 — default number of consecutive identical `(tool, args)` calls before the tool-loop guard
|
|
99
|
+
* fires. Small on purpose: it must catch a genuine no-progress loop (a model re-issuing the SAME
|
|
100
|
+
* call verbatim) while never tripping a legitimate one-off retry (2x). Kept below GS2-36's coarser
|
|
101
|
+
* error cap (5) because a same-signature repeat is a stronger, more specific loop signal than "an
|
|
102
|
+
* error happened again".
|
|
103
|
+
*/
|
|
104
|
+
export const DEFAULT_TOOL_LOOP_THRESHOLD = 3;
|
|
105
|
+
/**
|
|
106
|
+
* EXT-36 — normalise the `toolLoopGuard` config union (`false | true | { warn?, halt?, threshold? }`)
|
|
107
|
+
* into concrete {@link ToolLoopGuardOptions}, applying the WARN-ON-by-default policy at the read site
|
|
108
|
+
* (mirrors how `output.header` / `debugDump.redact` default with `!== false`, NOT in DEFAULT_CONFIG,
|
|
109
|
+
* so the effective-config snapshot never churns).
|
|
110
|
+
* - `false` → both modes off (a no-op guard);
|
|
111
|
+
* - `true` / absent → warn on, halt off, default threshold;
|
|
112
|
+
* - object → per-field, with warn defaulting ON and halt defaulting OFF.
|
|
113
|
+
*/
|
|
114
|
+
export function resolveToolLoopGuardOptions(setting) {
|
|
115
|
+
if (setting === false)
|
|
116
|
+
return { warn: false, halt: false };
|
|
117
|
+
if (setting === true || setting === undefined || setting === null)
|
|
118
|
+
return {};
|
|
119
|
+
return { warn: setting.warn, halt: setting.halt, threshold: setting.threshold };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* EXT-36 — a deterministic, key-sorted stringify so `(tool, args)` signatures are stable regardless
|
|
123
|
+
* of object key order. No-args (`{}`) collapses to `"{}"`, so identical no-arg repeats collide BY
|
|
124
|
+
* DESIGN — that is exactly the loop signal. Known limitation: args carrying a volatile value (a
|
|
125
|
+
* timestamp / uuid) make every call look distinct, so the guard cannot see that loop; volatile-key
|
|
126
|
+
* stripping is deliberately NOT attempted (over-engineering for a rare, model-authored case).
|
|
127
|
+
*/
|
|
128
|
+
function stableStringify(value) {
|
|
129
|
+
if (value === null || typeof value !== 'object')
|
|
130
|
+
return JSON.stringify(value) ?? 'null';
|
|
131
|
+
if (Array.isArray(value))
|
|
132
|
+
return `[${value.map(stableStringify).join(',')}]`;
|
|
133
|
+
const record = value;
|
|
134
|
+
const keys = Object.keys(record).sort();
|
|
135
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(record[k])}`).join(',')}}`;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* EXT-36 — the tool-loop guardrail as a standalone, testable middleware factory. The ORTHOGONAL
|
|
139
|
+
* sibling of {@link createToolErrorBudgetMiddleware}: GS2-36 caps a consecutive-tool-ERROR streak;
|
|
140
|
+
* this catches a **repeated identical `(tool, args)` / no-progress loop** — the same call re-issued
|
|
141
|
+
* verbatim, whether it keeps erroring OR keeps "succeeding" with the same result (the fs-error-string
|
|
142
|
+
* loop GS2-36's comment explicitly leaves to EXT-36).
|
|
143
|
+
*
|
|
144
|
+
* STATELESS (the critical trap): the factory runs ONCE per session, so a closure-held counter would
|
|
145
|
+
* bleed across every turn. Like GS2-36 it holds NO state — each `beforeModel` recomputes the streak
|
|
146
|
+
* from the message tail.
|
|
147
|
+
*
|
|
148
|
+
* Detection. A signature is `(tool_name, args_hash)`. Name + args live on `AIMessage.tool_calls[]`,
|
|
149
|
+
* NOT on the `ToolMessage` (softener ToolMessages carry only content+tool_call_id+status), so each
|
|
150
|
+
* `ToolMessage` is paired to its call by `tool_call_id === AIMessage.tool_calls[].id` to recover the
|
|
151
|
+
* signature. The backward walk counts CONSECUTIVE ToolMessages with the SAME signature; a DIFFERENT
|
|
152
|
+
* signature breaks the streak (the model tried something else = progress), and a Human/System message
|
|
153
|
+
* is a fresh-turn boundary. Assistant messages (the tool-call requests) are skipped. Known no-op
|
|
154
|
+
* (safe, never a false trip): a single AIMessage issuing PARALLEL tool calls yields back-to-back
|
|
155
|
+
* differing signatures, which the walk reads as progress and resets.
|
|
156
|
+
*
|
|
157
|
+
* Two modes (composable):
|
|
158
|
+
* - WARN (default ON, provably harmless): the default path must NOT change what the model sees.
|
|
159
|
+
* Appending ANY message then re-invoking the model mutates its input — a *steer*, not a *warn* —
|
|
160
|
+
* and is provider-unsafe by default (Gemini expects a trailing user turn → crash risk; Anthropic
|
|
161
|
+
* treats a trailing assistant as PREFILL → the note silently becomes the opening of the model's own
|
|
162
|
+
* next reply, corrupt with no error; a HumanMessage after a ToolMessage is two consecutive user
|
|
163
|
+
* turns for Anthropic/Gemini). So WARN instead SURFACES a user-visible notice via {@link onWarn}
|
|
164
|
+
* and returns `undefined` — zero `state.messages` mutation, zero control-flow. Fired statelessly
|
|
165
|
+
* ONCE per streak at the exact crossing (`streak === threshold`): a still-looping streak on later
|
|
166
|
+
* turns (`streak > threshold`) does not re-surface, while an interrupted-then-resumed loop
|
|
167
|
+
* re-reaches `threshold` and surfaces again — no marker/`additional_kwargs` machinery needed.
|
|
168
|
+
* - HALT (opt-in only, active loop-breaking): at/over threshold, return
|
|
169
|
+
* `{ jumpTo: 'end', messages: [new AIMessage(reason)] }` — a TERMINAL notice (the model is never
|
|
170
|
+
* re-invoked after it, so the prefill/role hazard cannot arise; the GS2-72-proven clean-stream
|
|
171
|
+
* path). NEVER throws. A validated behaviour change lives behind this opt-in.
|
|
172
|
+
*
|
|
173
|
+
* @param onWarn TUI-safe user-notice sink for WARN, wired at the read site to
|
|
174
|
+
* `statusUpdate(StatusLevel.WARNING, …)` (routed through the agent's status callback the renderer
|
|
175
|
+
* consumes, never raw stdout, so it can't leak over the Ink frame). Omitted → WARN still runs but
|
|
176
|
+
* surfaces nothing (still zero model-input mutation).
|
|
177
|
+
*/
|
|
178
|
+
export function createToolLoopGuardMiddleware(options = {}, onWarn) {
|
|
179
|
+
const warn = options.warn ?? true;
|
|
180
|
+
const halt = options.halt ?? false;
|
|
181
|
+
const threshold = options.threshold ?? DEFAULT_TOOL_LOOP_THRESHOLD;
|
|
182
|
+
return createMiddleware({
|
|
183
|
+
name: 'GthLeanToolLoopGuard',
|
|
184
|
+
beforeModel: {
|
|
185
|
+
canJumpTo: ['end'],
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
187
|
+
hook: (state) => {
|
|
188
|
+
// `false` config resolves to warn:false + halt:false — a genuine no-op (fast bail).
|
|
189
|
+
if (!warn && !halt)
|
|
190
|
+
return undefined;
|
|
191
|
+
const messages = Array.isArray(state?.messages) ? state.messages : [];
|
|
192
|
+
// Recover each tool call's signature by id — name + args are on the AIMessage, not the
|
|
193
|
+
// ToolMessage. One pass over all AIMessages builds the id → {sig, name} lookup.
|
|
194
|
+
const callById = new Map();
|
|
195
|
+
for (const msg of messages) {
|
|
196
|
+
if (AIMessage.isInstance(msg) && Array.isArray(msg.tool_calls)) {
|
|
197
|
+
for (const tc of msg.tool_calls) {
|
|
198
|
+
const id = tc?.id;
|
|
199
|
+
if (typeof id === 'string') {
|
|
200
|
+
const name = typeof tc.name === 'string' ? tc.name : '';
|
|
201
|
+
callById.set(id, { sig: `${name}${stableStringify(tc.args ?? {})}`, name });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Walk the tail backward, counting consecutive identical signatures since the last boundary.
|
|
207
|
+
let streak = 0;
|
|
208
|
+
let currentSig;
|
|
209
|
+
let currentName = '';
|
|
210
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
211
|
+
const msg = messages[i];
|
|
212
|
+
if (ToolMessage.isInstance(msg)) {
|
|
213
|
+
const call = callById.get(msg.tool_call_id);
|
|
214
|
+
// No paired call → cannot prove a repeat; treat as a boundary (never a false trip).
|
|
215
|
+
if (!call)
|
|
216
|
+
break;
|
|
217
|
+
if (currentSig === undefined) {
|
|
218
|
+
currentSig = call.sig;
|
|
219
|
+
currentName = call.name;
|
|
220
|
+
streak = 1;
|
|
221
|
+
}
|
|
222
|
+
else if (call.sig === currentSig) {
|
|
223
|
+
streak++;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
break; // different signature = the model tried something else = progress
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if (AIMessage.isInstance(msg)) {
|
|
230
|
+
continue; // the tool-call request — skip and keep counting the streak
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
break; // Human/System message: a fresh user turn resets everything.
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (currentSig === undefined || streak < threshold)
|
|
237
|
+
return undefined;
|
|
238
|
+
// HALT (opt-in): end the run cleanly — never a throw. Terminal, so the model is never
|
|
239
|
+
// re-invoked after this AIMessage (no prefill/role hazard). Takes precedence over WARN.
|
|
240
|
+
if (halt) {
|
|
241
|
+
const notice = `Stopped after ${streak} identical calls to the \`${currentName}\` tool with the same ` +
|
|
242
|
+
'arguments to avoid a loop that keeps spending tokens without making progress. ' +
|
|
243
|
+
'The same call cannot yield a different result: change your approach — different ' +
|
|
244
|
+
'arguments, a narrower step, or a different tool — or report the blocker to the user.';
|
|
245
|
+
return { jumpTo: 'end', messages: [new AIMessage(notice)] };
|
|
246
|
+
}
|
|
247
|
+
// WARN (default): SURFACE a user-visible notice and DO NOT touch state.messages (return
|
|
248
|
+
// undefined → the model's input is byte-for-byte unchanged, so no prefill/role hazard on any
|
|
249
|
+
// provider). Fire once per streak at the exact crossing: `streak === threshold` is a
|
|
250
|
+
// stateless "fire once" — a still-looping streak (streak > threshold) stays quiet, while an
|
|
251
|
+
// interrupted-then-resumed loop re-reaches threshold and surfaces again.
|
|
252
|
+
if (warn && streak === threshold) {
|
|
253
|
+
onWarn?.(`Tool-loop guard: the agent has called \`${currentName}\` with the same arguments ` +
|
|
254
|
+
`${streak} times without new progress. It may be stuck — consider interrupting and ` +
|
|
255
|
+
'refining the request.');
|
|
256
|
+
}
|
|
257
|
+
return undefined;
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
}
|
|
12
262
|
/**
|
|
13
263
|
* Lean agent: builds a standard `createAgent` (ReAct) graph. All run/stream/event
|
|
14
264
|
* plumbing lives in {@link GthAbstractAgent}; this class only knows how to construct
|
|
@@ -92,6 +342,38 @@ export class GthLangChainAgent extends GthAbstractAgent {
|
|
|
92
342
|
return state;
|
|
93
343
|
},
|
|
94
344
|
});
|
|
345
|
+
// EXT-35: promote a text-emitted tool call to a native tool_call so the loop doesn't stall.
|
|
346
|
+
// Small/local models (Gemma, lmstudio, gpt-oss) often serialise a tool call as assistant TEXT
|
|
347
|
+
// instead of a native `tool_call`; the ReAct router then sees no tool_calls on the last message
|
|
348
|
+
// and ENDS the turn ("no tool calls = done"). This afterModel hook runs ONLY when the last
|
|
349
|
+
// AIMessage carries no native tool_calls (the native happy path is byte-for-byte untouched):
|
|
350
|
+
// it parses a STANDALONE text-emitted call (bracket / <function=…> / Harmony), gated HARD by the
|
|
351
|
+
// bound-tool allow-list + a payload-size cap + standalone-only, and — when it promotes — returns
|
|
352
|
+
// the rewritten message. Preserving the original message id is load-bearing: LangGraph's
|
|
353
|
+
// message-state reducer merges by id, so a same-id message REPLACES the model's text message in
|
|
354
|
+
// graph state; the router then sees the native tool_calls and routes to the tools node, so the
|
|
355
|
+
// loop continues instead of concluding done. Ported from the openclaw tool-call-repair reference.
|
|
356
|
+
// Bound-tool names are the allow-list; an empty toolset promotes nothing (prose-safe default).
|
|
357
|
+
const repairToolNames = new Set(tools.map((t) => t.name).filter((name) => Boolean(name)));
|
|
358
|
+
const toolCallRepairMiddleware = createMiddleware({
|
|
359
|
+
name: 'GthMiddlewareToolCallRepair',
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
361
|
+
afterModel: (state) => {
|
|
362
|
+
const lastMessage = state.messages[state.messages.length - 1];
|
|
363
|
+
if (!AIMessage.isInstance(lastMessage))
|
|
364
|
+
return state;
|
|
365
|
+
if (lastMessage.tool_calls && lastMessage.tool_calls.length > 0)
|
|
366
|
+
return state;
|
|
367
|
+
const promoted = promoteTextEmittedToolCallMessage(lastMessage, {
|
|
368
|
+
allowedToolNames: repairToolNames,
|
|
369
|
+
});
|
|
370
|
+
if (!promoted)
|
|
371
|
+
return state;
|
|
372
|
+
debugLog(`Repaired a text-emitted tool call into a native tool_call: ${formatToolCalls(promoted.tool_calls ?? [])}`);
|
|
373
|
+
// Replace-by-id (same id) so the reducer swaps the text message rather than appending.
|
|
374
|
+
return { messages: [promoted] };
|
|
375
|
+
},
|
|
376
|
+
});
|
|
95
377
|
// EXT-21: lean-path sibling of the deep agent's GthDeepShellExitSoftening (GthDeepAgent.ts).
|
|
96
378
|
// `exec` / `ask --write` route through this lean `createAgent` graph, whose run_* shell/dev
|
|
97
379
|
// tools (GthDevToolkit.executeCommand) THROW a ShellCommandFailedError on a non-zero exit or a
|
|
@@ -177,11 +459,24 @@ export class GthLangChainAgent extends GthAbstractAgent {
|
|
|
177
459
|
name: 'GthMiddlewareDebugCapture',
|
|
178
460
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
461
|
wrapModelCall: async (request, handler) => {
|
|
462
|
+
// GS2-56: stash the always-on last-model-request snapshot (extras + as-sent messages)
|
|
463
|
+
// UNCONDITIONALLY — before the `capture` short-circuit — so `/debug-dump` has the full
|
|
464
|
+
// model input even when no TUI `/debug` sink is attached (a non-TUI surface, or `/debug`
|
|
465
|
+
// never opened). Guarded: snapshotting must never break the run. The computed extras are
|
|
466
|
+
// reused for the sink below so extraction runs once.
|
|
467
|
+
let extras;
|
|
468
|
+
try {
|
|
469
|
+
extras = extractDebugRequestExtras(request);
|
|
470
|
+
this.setLastModelRequest(request.messages, extras);
|
|
471
|
+
}
|
|
472
|
+
catch {
|
|
473
|
+
/* the always-on snapshot must never break the run */
|
|
474
|
+
}
|
|
180
475
|
const capture = getDebugCapture();
|
|
181
476
|
if (!capture)
|
|
182
477
|
return handler(request);
|
|
183
478
|
try {
|
|
184
|
-
capture.onRequest?.(request.messages,
|
|
479
|
+
capture.onRequest?.(request.messages, extras);
|
|
185
480
|
}
|
|
186
481
|
catch {
|
|
187
482
|
/* a debug sink must never break the run */
|
|
@@ -203,18 +498,54 @@ export class GthLangChainAgent extends GthAbstractAgent {
|
|
|
203
498
|
// two softeners is not load-bearing: they catch DISJOINT conditions (a ShellCommandFailedError
|
|
204
499
|
// vs a name==='ToolException') and each rethrows what it doesn't recognize, so neither can
|
|
205
500
|
// swallow the other.
|
|
501
|
+
// EXT-35: toolCallRepairMiddleware sits AFTER toolCallStatusMiddleware in the array. afterModel
|
|
502
|
+
// nodes execute in reverse array order (the later one runs first), so repair runs BEFORE the
|
|
503
|
+
// status middleware — a promoted call is therefore reported by the "Requested tools:" line too.
|
|
504
|
+
// Correctness (routing) is order-independent: the router reads final graph state after all
|
|
505
|
+
// afterModel nodes, and repair replaces-by-id, so the promoted tool_calls are present regardless.
|
|
506
|
+
// GS2-36: cap a self-inflicted tool-error loop. The shell/MCP softeners above turn a failed
|
|
507
|
+
// run_*/MCP call into a status:'error' ToolMessage the model observes; a model that keeps
|
|
508
|
+
// re-issuing the same failing call would drain tokens turn after turn. This beforeModel guard
|
|
509
|
+
// ends the run gracefully once MAX_CONSECUTIVE_TOOL_ERRORS such results accrue with no successful
|
|
510
|
+
// tool result in between — a tighter, error-specific complement to createAgent's coarse
|
|
511
|
+
// recursionLimit (loop DETECTION proper is the separate EXT-36). Placed after the softeners and
|
|
512
|
+
// before user middleware so it can't be bypassed. Lean backend only (per GS2-36 scope); the deep
|
|
513
|
+
// backend keeps its own recursionLimit backstop.
|
|
514
|
+
const toolErrorBudget = createToolErrorBudgetMiddleware();
|
|
515
|
+
// EXT-36: the ORTHOGONAL loop guard — repeated identical (tool, args) / no-progress detection,
|
|
516
|
+
// the sibling of GS2-36's error budget above. It catches the case GS2-36 explicitly leaves open:
|
|
517
|
+
// a model re-issuing the SAME call verbatim, whether it keeps erroring or keeps "succeeding" with
|
|
518
|
+
// the same result. Placed at index 3, immediately AFTER toolErrorBudget (index 2) and BEFORE user
|
|
519
|
+
// middleware: beforeModel hooks run in forward order with jumpTo short-circuiting, so on a
|
|
520
|
+
// simultaneous trip GS2-36's coarse error cap wins first and EXT-36 fires on its own
|
|
521
|
+
// signature-repeat threshold otherwise; keeping it outboard of user middleware means it can't be
|
|
522
|
+
// bypassed. WARN is on by default and SURFACES a user notice WITHOUT touching state.messages (the
|
|
523
|
+
// default path must never mutate the model's input — appending a message + re-invoking is a
|
|
524
|
+
// provider-unsafe steer, not a warn); HALT (opt-in) actively breaks the loop via a terminal
|
|
525
|
+
// jumpTo:'end'. Default WARN-ON is applied here at the read site (resolveToolLoopGuardOptions),
|
|
526
|
+
// NOT in DEFAULT_CONFIG, so the
|
|
527
|
+
// effective-config snapshot never churns. Lean backend only (like GS2-36); the deep array is
|
|
528
|
+
// untouched. `toolLoopGuard: false` resolves to a no-op guard (still installed at index 3 so the
|
|
529
|
+
// placement is stable).
|
|
530
|
+
const toolLoopGuard = createToolLoopGuardMiddleware(resolveToolLoopGuardOptions(this.config.toolLoopGuard),
|
|
531
|
+
// WARN surfaces through the same TUI-safe status channel every other agent notice uses
|
|
532
|
+
// (renderer-consumed, never raw stdout) so it can't leak over the Ink frame (TUI-C31).
|
|
533
|
+
(message) => statusUpdate(StatusLevel.WARNING, message));
|
|
206
534
|
const middleware = [
|
|
207
535
|
shellExitSoftening,
|
|
208
536
|
mcpToolErrorSoftening,
|
|
537
|
+
toolErrorBudget,
|
|
538
|
+
toolLoopGuard,
|
|
209
539
|
...configuredMiddleware,
|
|
210
540
|
toolCallStatusMiddleware,
|
|
541
|
+
toolCallRepairMiddleware,
|
|
211
542
|
debugCaptureMiddleware,
|
|
212
543
|
];
|
|
213
544
|
this.headerStatus(`Loaded middleware: ${middleware.map((m) => m.name).join(', ')}`);
|
|
214
545
|
// GS2-21: compose gsloth's system prompt (backstory + guidelines + per-command mode prompt +
|
|
215
546
|
// system prompt) EXACTLY as GthDeepAgent does, so identity profiles and `.gsloth.*.md` are
|
|
216
547
|
// honored on the lean backend too. Previously the lean agent gave the model NO system prompt
|
|
217
|
-
// (only the deep agent composed one), so `system-prompt.md` /
|
|
548
|
+
// (only the deep agent composed one), so `system-prompt.md` / the guidelines never reached
|
|
218
549
|
// the model — the robot (agent.backend: lean) behaved as if it never got its guidelines.
|
|
219
550
|
// This is passed to createAgent as `systemPrompt`, which langchain applies as the agent's
|
|
220
551
|
// static system message on every turn — NOT injected as a separate mid-conversation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GthLangChainAgent.js","sourceRoot":"","sources":["../../src/core/GthLangChainAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAA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Y,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -25,6 +25,22 @@ export interface DebugToolDef {
|
|
|
25
25
|
/** The tool's JSON-schema parameters, when resolvable. */
|
|
26
26
|
schema?: unknown;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* GS2-56 — the always-on snapshot of the LAST model request, kept on
|
|
30
|
+
* {@link import('#src/core/GthAbstractAgent.js').GthAbstractAgent} independent of any
|
|
31
|
+
* {@link DebugCapture} sink. It is the SAME data the sink reports (the as-sent, post-summarization
|
|
32
|
+
* `request.messages` plus the {@link DebugRequestExtras}), captured unconditionally at each model
|
|
33
|
+
* call so `/debug-dump` can render the full model input even when the TUI `/debug` panel was never
|
|
34
|
+
* opened and on non-TUI surfaces. Reuses {@link DebugRequestExtras} rather than forking a parallel
|
|
35
|
+
* capture shape; `WriteDebugDumpInput.modelRequest` is this same type, so the caller threads
|
|
36
|
+
* `agent.lastModelRequest` straight through with no reshaping.
|
|
37
|
+
*/
|
|
38
|
+
export interface LastModelRequest {
|
|
39
|
+
/** The request extras (system prompt, tool defs with schema, model params, tool-choice). */
|
|
40
|
+
extras?: DebugRequestExtras;
|
|
41
|
+
/** The exact messages sent to the model for the last call (post-summarization / middleware). */
|
|
42
|
+
messages?: BaseMessage[];
|
|
43
|
+
}
|
|
28
44
|
/**
|
|
29
45
|
* Debug-capture sink for the TUI's `/debug` panel.
|
|
30
46
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugCapture.js","sourceRoot":"","sources":["../../src/core/debugCapture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debugCapture.js","sourceRoot":"","sources":["../../src/core/debugCapture.ts"],"names":[],"mappings":"AAwEA;;;;;;;;GAQG;AACH,MAAM,sBAAsB,GAAG;IAC7B,OAAO;IACP,WAAW;IACX,SAAS;IAC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AG,CAAC,YAAY;QAClB,CAAC,CAAC,OAAO,aAAa,EAAE,OAAO,KAAK,QAAQ;YAC1C,CAAC,CAAC,aAAa,CAAC,OAAO;YACvB,CAAC,CAAC,SAAS,CAAC;IAClB,MAAM,MAAM,GAAuB;QACjC,YAAY;QACZ,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC;QACjC,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1C,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAC;IACF,kGAAkG;IAClG,MAAM,MAAM,GACV,MAAM,CAAC,YAAY,KAAK,SAAS;QACjC,MAAM,CAAC,KAAK,KAAK,SAAS;QAC1B,MAAM,CAAC,WAAW,KAAK,SAAS;QAChC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC;IAClC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACrC,CAAC"}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* the user just watched.
|
|
26
26
|
*/
|
|
27
27
|
import { AIMessage, AIMessageChunk, ToolMessage } from '@langchain/core/messages';
|
|
28
|
-
import { buildToolPreviewLines, getToolGlyph,
|
|
28
|
+
import { buildToolPreviewLines, getToolGlyph, isShellShapedResult, renderToolLineAnsi, summariseToolCall, } from '#src/core/toolDisplay.js';
|
|
29
29
|
import { displayToolIndication } from '#src/utils/consoleUtils.js';
|
|
30
30
|
import { getUseColour, stdout } from '#src/utils/systemUtils.js';
|
|
31
31
|
const INDENT = ' ';
|
|
@@ -78,8 +78,10 @@ export function createPlainToolIndication(emit = displayToolIndication) {
|
|
|
78
78
|
result,
|
|
79
79
|
isError,
|
|
80
80
|
// Shell-shaped results stream their child output live through the channel's default
|
|
81
|
-
// sink on this surface — suppress the duplicated body, keep the status tail.
|
|
82
|
-
|
|
81
|
+
// sink on this surface — suppress the duplicated body, keep the status tail. TUI-C32
|
|
82
|
+
// residual c: gate on the tool NAME + shape (not shape alone), so a non-shell tool whose
|
|
83
|
+
// result merely quotes `<COMMAND_OUTPUT>` keeps its preview body instead of being suppressed.
|
|
84
|
+
liveOutputAlreadyShown: isShellShapedResult(name, result),
|
|
83
85
|
});
|
|
84
86
|
const body = preview.map((line) => INDENT + renderToolLineAnsi(line, colour));
|
|
85
87
|
// Leading newline mirrors the historical notice framing (the model text stream may have
|
|
@@ -91,24 +93,49 @@ export function createPlainToolIndication(emit = displayToolIndication) {
|
|
|
91
93
|
// Order matters: AIMessageChunk extends AIMessage, so test the chunk shape first
|
|
92
94
|
// (mirrors processEventStream).
|
|
93
95
|
if (AIMessageChunk.isInstance(chunk)) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
entry
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
// TUI-C32 residual e — fail-soft, matching the ToolMessage branch: accumulating tool-call
|
|
97
|
+
// deltas (`JSON.stringify(tc.args)` can throw on an unserialisable arg, e.g. a BigInt) must
|
|
98
|
+
// never break the run's stream loop. On any error we simply skip this chunk's tracking.
|
|
99
|
+
try {
|
|
100
|
+
const c = chunk;
|
|
101
|
+
const deltas = c.tool_call_chunks ?? [];
|
|
102
|
+
if (deltas.length > 0) {
|
|
103
|
+
for (const delta of deltas) {
|
|
104
|
+
const index = typeof delta.index === 'number' ? delta.index : 0;
|
|
105
|
+
const entry = streaming.get(index) ?? { name: '', argsText: '' };
|
|
106
|
+
if (delta.id)
|
|
107
|
+
entry.id = delta.id;
|
|
108
|
+
if (delta.name)
|
|
109
|
+
entry.name = entry.name || delta.name;
|
|
110
|
+
if (delta.args)
|
|
111
|
+
entry.argsText += delta.args;
|
|
112
|
+
streaming.set(index, entry);
|
|
113
|
+
}
|
|
107
114
|
}
|
|
115
|
+
else {
|
|
116
|
+
// Some providers surface COMPLETE tool_calls on a chunk instead of deltas.
|
|
117
|
+
for (const tc of c.tool_calls ?? []) {
|
|
118
|
+
if (tc.id) {
|
|
119
|
+
byId.set(tc.id, {
|
|
120
|
+
id: tc.id,
|
|
121
|
+
name: tc.name,
|
|
122
|
+
argsText: JSON.stringify(tc.args ?? {}),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
/* indication is best-effort; the model-facing stream is untouched */
|
|
108
130
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (AIMessage.isInstance(chunk)) {
|
|
134
|
+
// A non-chunk AIMessage (resumed/checkpoint-replayed runs) carries final tool_calls.
|
|
135
|
+
// TUI-C32 residual e — same fail-soft wrap as above/the ToolMessage branch.
|
|
136
|
+
try {
|
|
137
|
+
const m = chunk;
|
|
138
|
+
for (const tc of m.tool_calls ?? []) {
|
|
112
139
|
if (tc.id) {
|
|
113
140
|
byId.set(tc.id, {
|
|
114
141
|
id: tc.id,
|
|
@@ -118,15 +145,8 @@ export function createPlainToolIndication(emit = displayToolIndication) {
|
|
|
118
145
|
}
|
|
119
146
|
}
|
|
120
147
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (AIMessage.isInstance(chunk)) {
|
|
124
|
-
// A non-chunk AIMessage (resumed/checkpoint-replayed runs) carries final tool_calls.
|
|
125
|
-
const m = chunk;
|
|
126
|
-
for (const tc of m.tool_calls ?? []) {
|
|
127
|
-
if (tc.id) {
|
|
128
|
-
byId.set(tc.id, { id: tc.id, name: tc.name, argsText: JSON.stringify(tc.args ?? {}) });
|
|
129
|
-
}
|
|
148
|
+
catch {
|
|
149
|
+
/* indication is best-effort; the model-facing stream is untouched */
|
|
130
150
|
}
|
|
131
151
|
return;
|
|
132
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plainToolIndication.js","sourceRoot":"","sources":["../../src/core/plainToolIndication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"plainToolIndication.js","sourceRoot":"","sources":["../../src/core/plainToolIndication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,MAAM,GAAG,MAAM,CAAC;AActB;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAAI,GAA2B,qBAAqB;IAEpD,wFAAwF;IACxF,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;IACrD,yEAAyE;IACzE,MAAM,IAAI,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEhD,MAAM,sBAAsB,GAAG,GAAS,EAAE;QACxC,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,EAAE;gBAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,CAAC,OAAoB,EAAQ,EAAE;QACvD,MAAM,EAAE,GAAG,OAAO,OAAO,CAAC,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