@genesislcap/ai-assistant 15.21.0 → 15.21.1

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.
Files changed (29) hide show
  1. package/dist/ai-assistant.api.json +135 -1
  2. package/dist/ai-assistant.d.ts +152 -0
  3. package/dist/chat-driver.cjs +281 -81
  4. package/dist/chat-driver.cjs.map +2 -2
  5. package/dist/chat-driver.mjs +277 -81
  6. package/dist/chat-driver.mjs.map +2 -2
  7. package/dist/custom-elements.json +175 -8
  8. package/dist/dts/components/chat-driver/chat-driver.d.ts +39 -0
  9. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  10. package/dist/dts/components/orchestrating-driver/index.d.ts +2 -1
  11. package/dist/dts/components/orchestrating-driver/index.d.ts.map +1 -1
  12. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +101 -0
  13. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  14. package/dist/dts/config/fallback-agents.d.ts +7 -0
  15. package/dist/dts/config/fallback-agents.d.ts.map +1 -1
  16. package/dist/dts/state/debug-event-log.d.ts +1 -1
  17. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  18. package/dist/dts/utils/context-tokens.d.ts +25 -3
  19. package/dist/dts/utils/context-tokens.d.ts.map +1 -1
  20. package/dist/dts/utils/history-transform.d.ts +23 -3
  21. package/dist/dts/utils/history-transform.d.ts.map +1 -1
  22. package/dist/esm/components/chat-driver/chat-driver.js +72 -56
  23. package/dist/esm/components/orchestrating-driver/index.js +1 -1
  24. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +266 -36
  25. package/dist/esm/config/fallback-agents.js +12 -1
  26. package/dist/esm/state/debug-event-log.js +7 -2
  27. package/dist/esm/utils/context-tokens.js +27 -3
  28. package/dist/esm/utils/history-transform.js +54 -5
  29. package/package.json +16 -16
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrating-driver.d.ts","sourceRoot":"","sources":["../../../../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,kBAAkB;IAa1B,OAAO,CAAC,mBAAmB;CAU5B"}
1
+ {"version":3,"file":"orchestrating-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/orchestrating-driver/orchestrating-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EACV,WAAW,EAKZ,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAI3E,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAkBpC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe;AACzB,kDAAkD;AAChD,YAAY;AACd,6EAA6E;GAC3E,UAAU;AACZ;;;;;GAKG;GACD,kBAAkB;AACpB,+DAA+D;GAC7D,kBAAkB;AACpB,kDAAkD;GAChD,gBAAgB;AAClB,kFAAkF;GAChF,sBAAsB;AACxB,oEAAoE;GAClE,mBAAmB;AACrB,0EAA0E;GACxE,QAAQ,CAAC;AAqCb;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,sBAAsB,ijBAIyH,CAAC;AAuB7J;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,WAAY,Y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,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAmC7E,mBAAmB;IAwJ3B,mBAAmB,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrF,qDAAqD;IACrD,uBAAuB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIjE,4CAA4C;IAC5C,cAAc,IAAI,WAAW,GAAG,SAAS;YAI3B,UAAU;IA2GxB;;;;;;;;;;OAUG;YACW,kBAAkB;IAuBhC;;;;OAIG;IACH,MAAM,IAAI,IAAI;IAKd;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB9B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,aAAa;IAoCrB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;YAgCd,QAAQ;IAmMtB;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAe5B"}
@@ -14,6 +14,13 @@ export declare const friendlyFallbackAgent: FallbackAgentConfig;
14
14
  * elaboration. The `{{agents}}` placeholder is replaced at runtime by
15
15
  * `OrchestratingDriver` with the generated specialist list.
16
16
  *
17
+ * The `{{unroutable}}` placeholder positions `UNROUTABLE_INSTRUCTION` — the framework's
18
+ * instruction for a substantive request no specialist covers, which is otherwise APPENDED to a
19
+ * string-form prompt. Positioned rather than appended for one reason: this preset's whole point is
20
+ * brevity, and appended text would be the last thing the model reads. Putting the block above the
21
+ * brevity rule leaves "a single short sentence" with the recency, so the two compose instead of
22
+ * competing. A prompt whose tone rules matter should do the same.
23
+ *
17
24
  * @beta
18
25
  */
19
26
  export declare const strictFallbackAgent: FallbackAgentConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"fallback-agents.d.ts","sourceRoot":"","sources":["../../../src/config/fallback-agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAInC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAIjC,CAAC"}
1
+ {"version":3,"file":"fallback-agents.d.ts","sourceRoot":"","sources":["../../../src/config/fallback-agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAInC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAQjC,CAAC"}
@@ -28,7 +28,7 @@ import type { TurnFailureReason } from '@genesislcap/foundation-ai';
28
28
  * Catalogue of meta event names. This is the documented surface — extend it as
29
29
  * new events are wired in (Tier 2/3 lifecycle, interaction, provider events).
30
30
  */
31
- export type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'interaction.external-cost' | 'interaction.external-cost-dropped' | 'external-diagnostics.folded' | 'context.updated' | 'context.threshold-crossed' | 'context.compacted' | 'context.condensed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed' | 'session.cleared' | 'session.switched' | 'session.switch-deferred' | 'persistence.toggled' | 'persistence.saved' | 'persistence.save-failed' | 'persistence.suppressed' | 'persistence.not-resumable' | 'persistence.restored' | 'persistence.restore-orphan';
31
+ export type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'routing.decided' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'interaction.external-cost' | 'interaction.external-cost-dropped' | 'external-diagnostics.folded' | 'context.updated' | 'context.threshold-crossed' | 'context.compacted' | 'context.condensed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed' | 'session.cleared' | 'session.switched' | 'session.switch-deferred' | 'persistence.toggled' | 'persistence.saved' | 'persistence.save-failed' | 'persistence.suppressed' | 'persistence.not-resumable' | 'persistence.restored' | 'persistence.restore-orphan';
32
32
  /**
33
33
  * How much a reader should care about an event — lets a consumer (or an AI
34
34
  * agent) filter the timeline: skip `low` UI/bookkeeping noise, skim `normal`
@@ -1 +1 @@
1
- {"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GACtB,2BAA2B,GAC3B,mCAAmC,GAEnC,6BAA6B,GAE7B,iBAAiB,GACjB,2BAA2B,GAC3B,m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AC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAEN;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAEnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CA0BrF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAmB7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
1
+ {"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,iBAAiB,GACjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GACtB,2BAA2B,GAC3B,mCAAmC,GAEnC,6BAA6B,GAE7B,iBAAiB,GACjB,2BAA2B,GAC3B,mBAAmB,GACnB,mBAAmB,GAEnB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GAEpB,iBAAiB,GACjB,kBAAkB,GAClB,yBAAyB,GACzB,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,CAAC,CAEnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CA0BrF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAqB7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -32,10 +32,32 @@ export declare const COMPACTION_SUMMARY_TOKEN_ESTIMATE = 1200;
32
32
  * `assistant(toolCalls)` and its results must not be mistaken for a safe split.
33
33
  *
34
34
  * Mirrors what the request-build chokepoint and the transports actually send:
35
- * `system-event` / `synthetic-user` are display-only rows, and the
35
+ * `system-event` / `synthetic-user` are display-only rows, the
36
36
  * reasoning/narration splits (GENC-1410, plus the legacy `thinking` flag they
37
- * superseded) are skipped when building the request. Counting any of them would
38
- * inflate every estimate against a prompt that never carries them.
37
+ * superseded) are skipped when building the request, and `excludeFromProvider`
38
+ * marks prose the driver wrote rather than the model (GENC-1573). Counting any
39
+ * of them would inflate every estimate against a prompt that never carries
40
+ * them.
41
+ *
42
+ * Keep this list aligned with the skip block in `toAnthropicMessages` /
43
+ * `toGeminiContents` — it exists to predict them.
44
+ *
45
+ * SCOPED TO WHAT CANONICAL HISTORY CARRIES, though, which is less than the wire
46
+ * decides. This runs against stored history, whereas `transformHistoryForAgent`
47
+ * is applied later and only at the request-build site — so neither of the things
48
+ * that transform does is visible here: the `excludeFromProvider` it stamps on
49
+ * another agent's `toolResult`, nor the foreign `tool_use` blocks it flattens to
50
+ * prose. In the session quoted in its docblock that is 389 `tool_use` + 313
51
+ * `tool_result` payloads still counted in full against a prompt that no longer
52
+ * carries them. So for `excludeFromProvider` this predicate is exact only for the
53
+ * driver-authored notices that carry the flag in stored history.
54
+ *
55
+ * The divergence predates the flag — masking already emptied `args` after
56
+ * estimation — and is left as is deliberately: the estimator over-counts, which
57
+ * errs towards compacting early rather than towards an over-limit request. Noted
58
+ * because the next person to trust this as an exact mirror will be debugging a
59
+ * multi-agent session that compacts sooner than they expect. Reviewer catch on
60
+ * #2496.
39
61
  */
40
62
  export declare function reachesProvider(m: ChatMessage): boolean;
41
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"context-tokens.d.ts","sourceRoot":"","sources":["../../../src/utils/context-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAexC;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAIvD;AAmGD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE,CAmC/E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAO9E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAK7E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,SAAS,WAAW,EAAE,EACrC,cAAc,EAAE,SAAS,WAAW,EAAE,GACrC,MAAM,CAaR;AAED,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC,8EAA8E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wBAAgB,qBAAqB,CACnC,aAAa,EAAE,SAAS,WAAW,EAAE,EACrC,cAAc,EAAE,SAAS,WAAW,EAAE,GACrC,MAAM,CAaR;AAED,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,GAAG,EAAE,MAAM,EACX,aAAa,GAAE,MAA0C,GACxD,oBAAoB,CAkBtB"}
@@ -1,9 +1,29 @@
1
1
  import type { ChatMessage } from '@genesislcap/foundation-ai';
2
2
  import { type CompactionProjection } from './context-tokens';
3
3
  /**
4
- * Prepares history for the LLM only: masks tool call args and results from other
5
- * agents so the active specialist is not confused by tools it does not have.
6
- * Canonical history in `ChatDriver` stays unmasked for UI and logging.
4
+ * Prepares history for the LLM only: another agent's tool traffic becomes prose, so the active
5
+ * specialist sees THAT work happened without being handed calls it cannot make or results it
6
+ * cannot use. Canonical history in `ChatDriver` stays untouched for UI and logging.
7
+ *
8
+ * Why prose rather than masked-in-place blocks (GENC-1573). Masking used to clear a foreign
9
+ * call's `args` and stub its result's content, but leave both as real `tool_use`/`tool_result`
10
+ * blocks on the wire. That put a large, wholly uninformative structure in front of every routed
11
+ * agent — in the measured session the fallback's requests carried 389 `tool_use` and 313
12
+ * `tool_result` blocks, every one of them another agent's, the args emptied to `{}` and the
13
+ * results reduced to the same placeholder sentence repeated 313 times. It cost tokens on every
14
+ * turn, told the model nothing, and asked a tool-less agent to make sense of a tool transcript.
15
+ *
16
+ * A foreign result is dropped rather than rendered: its content was already replaced by a
17
+ * placeholder, so the only thing left to say is "a result came back", which the call line
18
+ * already implies. It is dropped via `excludeFromProvider` rather than by filtering the array,
19
+ * so index-aligned callers and the token estimator see the same list they always did.
20
+ *
21
+ * Pairs are flattened together, keyed on tool-call id rather than per message, because a
22
+ * half-flattened pair is a rejected request: an orphaned `tool_result` has no `tool_use` to
23
+ * answer. Both halves of a pair normally carry the same `agentName` — `appendToHistory` stamps
24
+ * the active agent on the call and its result alike — but a session restored from before that
25
+ * stamping, or appended with no agent active, can hold one half unattributed, and per-message
26
+ * flattening would then split it.
7
27
  */
8
28
  export declare function transformHistoryForAgent(history: ChatMessage[], agentName: string): ChatMessage[];
9
29
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"history-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/history-transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,kBAAkB,CAAC;AA0B1B;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAKjG;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAG3F;AAID;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CASvF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,eAAe,GAAE,MAAkC,GAClD,MAAM,GAAG,IA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;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CASvF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,eAAe,GAAE,MAAkC,GAClD,MAAM,GAAG,IAAI,CAkBf;AAED,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,GAAG,IAAI,CAS7B;AAkCD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAYA;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE,CAanF;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAG7D"}
@@ -92,6 +92,28 @@ const MAX_STALE_TOOL_CALLS = DEFAULT_MAX_UNKNOWN_TOOL_CALLS * 2;
92
92
  // ceiling, not a per-turn total.
93
93
  const MAX_MALFORMED_RETRIES = 5;
94
94
  const MAX_EMPTY_RESPONSE_RETRIES = 3;
95
+ /**
96
+ * Framed-tail nudge added to a retry after a MALFORMED tool call.
97
+ *
98
+ * Exported so tests can assert placement (framed tail, never the system prompt) without pinning
99
+ * the wording — the copy is a prompt, and a prompt should be free to improve.
100
+ *
101
+ * @beta
102
+ */
103
+ export const MALFORMED_CALL_NUDGE = 'IMPORTANT: Use only the structured function-call API to invoke tools. Do not write Python code or use Python-style syntax to call tools.';
104
+ /**
105
+ * Framed-tail nudge added to a retry after an EMPTY response.
106
+ *
107
+ * Rewritten in GENC-1573. The previous copy ("You must respond to the user's message. Call the
108
+ * appropriate tool or provide a text response") told a model that had just returned nothing to
109
+ * respond, without naming the one exit available to an agent that genuinely cannot act: saying so.
110
+ * Across nine failures in the measured session it changed nothing — all 29 attempts came back at
111
+ * 8–9 output tokens — and most of those were on a tool-less agent, for which "call the appropriate
112
+ * tool" is not an option at all. This version names the honest answer explicitly.
113
+ *
114
+ * @beta
115
+ */
116
+ export const EMPTY_RESPONSE_NUDGE = "IMPORTANT: Your previous attempt returned nothing at all, which is never a valid response. Answer the user's last message now, in prose — even if all you can honestly say is that you cannot help with it and why. If a tool is the right way to answer, call it. Do not return an empty response.";
95
117
  // Transient throws while building the per-turn tool surface or calling the provider retry the
96
118
  // SAME iteration up to this many times before propagating, rather than tearing down the turn.
97
119
  const MAX_SETUP_TRANSPORT_RETRIES = 3;
@@ -520,7 +542,7 @@ export class ChatDriver extends EventTarget {
520
542
  spentUsd: e.spentUsd,
521
543
  isSubAgent: this.isSubAgent,
522
544
  });
523
- this.appendToHistory({ role: 'assistant', content: this.budgetExhaustedBubble(e) });
545
+ this.appendDriverNotice(this.budgetExhaustedBubble(e));
524
546
  return this.turnDone('budget-exhausted', budgetDetailOf(e));
525
547
  }
526
548
  /**
@@ -558,7 +580,7 @@ export class ChatDriver extends EventTarget {
558
580
  upstreamType: e.upstreamType,
559
581
  isSubAgent: this.isSubAgent,
560
582
  });
561
- this.appendToHistory({ role: 'assistant', content: this.providerRefusedBubble() });
583
+ this.appendDriverNotice(this.providerRefusedBubble());
562
584
  return this.turnDone('provider-refused', undefined, detail);
563
585
  }
564
586
  /** The typed failure reason on a loop result, or `undefined` for a clean turn / handoff. */
@@ -1216,12 +1238,12 @@ export class ChatDriver extends EventTarget {
1216
1238
  }
1217
1239
  catch (e) {
1218
1240
  logger.warn(`ChatDriver: compaction summary failed: ${e instanceof Error ? e.message : e}`);
1219
- this.appendToHistory({ role: 'assistant', content: failMessage });
1241
+ this.appendDriverNotice(failMessage);
1220
1242
  return null;
1221
1243
  }
1222
1244
  if (!summaryText) {
1223
1245
  logger.warn('ChatDriver: compaction summary was empty; leaving history untouched');
1224
- this.appendToHistory({ role: 'assistant', content: failMessage });
1246
+ this.appendDriverNotice(failMessage);
1225
1247
  return null;
1226
1248
  }
1227
1249
  let tokensBefore;
@@ -1630,10 +1652,7 @@ export class ChatDriver extends EventTarget {
1630
1652
  name: e instanceof Error ? e.name : undefined,
1631
1653
  message: e instanceof Error ? e.message : String(e),
1632
1654
  });
1633
- this.appendToHistory({
1634
- role: 'assistant',
1635
- content: 'Sorry, something went wrong on my end. Please try again in a moment.',
1636
- });
1655
+ this.appendDriverNotice('Sorry, something went wrong on my end. Please try again in a moment.');
1637
1656
  result = this.turnDone('exception');
1638
1657
  return result;
1639
1658
  }
@@ -2011,10 +2030,7 @@ export class ChatDriver extends EventTarget {
2011
2030
  name: e instanceof Error ? e.name : undefined,
2012
2031
  message: e instanceof Error ? e.message : String(e),
2013
2032
  });
2014
- this.appendToHistory({
2015
- role: 'assistant',
2016
- content: 'Sorry, something went wrong on my end. Please try again in a moment.',
2017
- });
2033
+ this.appendDriverNotice('Sorry, something went wrong on my end. Please try again in a moment.');
2018
2034
  result = this.turnDone('exception');
2019
2035
  return result;
2020
2036
  }
@@ -2254,7 +2270,7 @@ export class ChatDriver extends EventTarget {
2254
2270
  this.failSubAgent('provider_refused', undefined, this.providerRefusedDetail);
2255
2271
  }
2256
2272
  else {
2257
- this.appendToHistory({ role: 'assistant', content: this.providerRefusedBubble() });
2273
+ this.appendDriverNotice(this.providerRefusedBubble());
2258
2274
  }
2259
2275
  return this.turnDone('provider-refused', undefined, this.providerRefusedDetail);
2260
2276
  }
@@ -2284,10 +2300,7 @@ export class ChatDriver extends EventTarget {
2284
2300
  // arrived as a sub-agent's failure payload — `budgetWallDetail`, first
2285
2301
  // attribution wins — and an unattributable child wall (detail
2286
2302
  // undefined) composes the neutral default.
2287
- this.appendToHistory({
2288
- role: 'assistant',
2289
- content: this.budgetExhaustedBubble(this.budgetWallDetail),
2290
- });
2303
+ this.appendDriverNotice(this.budgetExhaustedBubble(this.budgetWallDetail));
2291
2304
  }
2292
2305
  // Carried onto the result so `loopEndDetail` publishes the refusing
2293
2306
  // vendor rather than falling through to `lastResolvedProvider`, and the
@@ -2355,9 +2368,9 @@ export class ChatDriver extends EventTarget {
2355
2368
  // byte-stable for every agent.
2356
2369
  const foldSuffix = this.buildFoldSystemPromptSuffix();
2357
2370
  const retryNudge = malformedAttempts > 0
2358
- ? '\n\nIMPORTANT: Use only the structured function-call API to invoke tools. Do not write Python code or use Python-style syntax to call tools.'
2371
+ ? `\n\n${MALFORMED_CALL_NUDGE}`
2359
2372
  : emptyResponseAttempts > 0
2360
- ? "\n\nIMPORTANT: You must respond to the user's message. Call the appropriate tool or provide a text response — do not return an empty response."
2373
+ ? `\n\n${EMPTY_RESPONSE_NUDGE}`
2361
2374
  : '';
2362
2375
  const frameworkSystemSuffix = `${foldSuffix}${retryNudge}`;
2363
2376
  // Normalize the primer at the same chokepoint as the driver's own history
@@ -2523,11 +2536,8 @@ export class ChatDriver extends EventTarget {
2523
2536
  this.failSubAgent('context_exhausted');
2524
2537
  }
2525
2538
  else {
2526
- this.appendToHistory({
2527
- role: 'assistant',
2528
- content: 'I had to stop here — this conversation has filled the available context. ' +
2529
- 'Compact it to free up room, then ask me to continue.',
2530
- });
2539
+ this.appendDriverNotice('I had to stop here — this conversation has filled the available context. ' +
2540
+ 'Compact it to free up room, then ask me to continue.');
2531
2541
  }
2532
2542
  return this.turnDone('context-exhausted');
2533
2543
  }
@@ -2564,10 +2574,7 @@ export class ChatDriver extends EventTarget {
2564
2574
  this.failSubAgent('malformed_tool_call');
2565
2575
  }
2566
2576
  else {
2567
- this.appendToHistory({
2568
- role: 'assistant',
2569
- content: 'While working on your request, I repeatedly called my tools incorrectly. This often works on a second try — would you like me to try again? If it happens again, try breaking your request into smaller steps.',
2570
- });
2577
+ this.appendDriverNotice('While working on your request, I repeatedly called my tools incorrectly. This often works on a second try — would you like me to try again? If it happens again, try breaking your request into smaller steps.');
2571
2578
  }
2572
2579
  return this.turnDone('malformed-function-call');
2573
2580
  }
@@ -2593,10 +2600,7 @@ export class ChatDriver extends EventTarget {
2593
2600
  this.failSubAgent('response_truncated');
2594
2601
  }
2595
2602
  else {
2596
- this.appendToHistory({
2597
- role: 'assistant',
2598
- content: 'My response was cut off because a single step reached the model output limit. This usually means one step tried to produce too much at once — try breaking your request into smaller steps.',
2599
- });
2603
+ this.appendDriverNotice('My response was cut off because a single step reached the model output limit. This usually means one step tried to produce too much at once — try breaking your request into smaller steps.');
2600
2604
  }
2601
2605
  return this.turnDone('response-truncated');
2602
2606
  }
@@ -2642,10 +2646,7 @@ export class ChatDriver extends EventTarget {
2642
2646
  this.failSubAgent('context_exhausted');
2643
2647
  }
2644
2648
  else {
2645
- this.appendToHistory({
2646
- role: 'assistant',
2647
- content: DEFAULT_CONTEXT_OVERFLOW_MESSAGE,
2648
- });
2649
+ this.appendDriverNotice(DEFAULT_CONTEXT_OVERFLOW_MESSAGE);
2649
2650
  }
2650
2651
  return this.turnDone('context-exhausted');
2651
2652
  }
@@ -2721,10 +2722,7 @@ export class ChatDriver extends EventTarget {
2721
2722
  this.failSubAgent('timeout');
2722
2723
  }
2723
2724
  else {
2724
- this.appendToHistory({
2725
- role: 'assistant',
2726
- content: 'The request timed out. You can ask me to try again, or break this into a smaller step.',
2727
- });
2725
+ this.appendDriverNotice('The request timed out. You can ask me to try again, or break this into a smaller step.');
2728
2726
  }
2729
2727
  // Recorded as `exception` above (there is no separate `timeout` member of
2730
2728
  // TurnFailureReason for the main turn); surface the same reason here.
@@ -2800,7 +2798,12 @@ export class ChatDriver extends EventTarget {
2800
2798
  emptyResponseAttempts += 1;
2801
2799
  if (!isRefusal && emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
2802
2800
  logger.warn(`ChatDriver: empty model response, retrying (${emptyResponseAttempts}/${MAX_EMPTY_RESPONSE_RETRIES})`);
2803
- recordTurnRetry(this.sessionKey, 'empty-response', Object.assign({ agent: this.activeAgentName, provider: this.lastResolvedProviderName, attempt: emptyResponseAttempts, maxAttempts: MAX_EMPTY_RESPONSE_RETRIES }, response.responseMeta));
2801
+ recordTurnRetry(this.sessionKey, 'empty-response', Object.assign({ agent: this.activeAgentName, provider: this.lastResolvedProviderName, attempt: emptyResponseAttempts, maxAttempts: MAX_EMPTY_RESPONSE_RETRIES,
2802
+ // How many tools the agent was holding. Every empty response in the session that
2803
+ // motivated this (GENC-1573) came from an agent with ZERO — a tool-less agent asked
2804
+ // something its prompt gives it no instruction for has nothing it is allowed to do,
2805
+ // and reads as a model fault unless this number is on the record.
2806
+ toolCount: this.toolDefinitions.length }, response.responseMeta));
2804
2807
  iterations -= 1;
2805
2808
  continue;
2806
2809
  }
@@ -2808,17 +2811,17 @@ export class ChatDriver extends EventTarget {
2808
2811
  logger.error(isRefusal
2809
2812
  ? 'ChatDriver: model refused the request (safety decline) — not retrying'
2810
2813
  : 'ChatDriver: empty model response after all retries');
2811
- recordTurnError(this.sessionKey, failureReason, Object.assign({ agent: this.activeAgentName, provider: this.lastResolvedProviderName, attempts: emptyResponseAttempts, isSubAgent: this.isSubAgent }, response.responseMeta));
2814
+ recordTurnError(this.sessionKey, failureReason, Object.assign({ agent: this.activeAgentName, provider: this.lastResolvedProviderName, attempts: emptyResponseAttempts,
2815
+ // See the retry above: a zero here says the agent had no tools, which is most of the
2816
+ // explanation for a blank turn and is otherwise invisible.
2817
+ toolCount: this.toolDefinitions.length, isSubAgent: this.isSubAgent }, response.responseMeta));
2812
2818
  if (this.isSubAgent) {
2813
2819
  this.failSubAgent(isRefusal ? 'refusal' : 'empty_response');
2814
2820
  }
2815
2821
  else {
2816
- this.appendToHistory({
2817
- role: 'assistant',
2818
- content: isRefusal
2819
- ? 'This request was declined. Try rephrasing it, or breaking it into smaller steps.'
2820
- : 'While working on your request, I repeatedly generated a blank response. This often works on a second try — would you like me to try again? If it happens again, try breaking your request into smaller steps.',
2821
- });
2822
+ this.appendDriverNotice(isRefusal
2823
+ ? 'This request was declined. Try rephrasing it, or breaking it into smaller steps.'
2824
+ : 'While working on your request, I repeatedly generated a blank response. This often works on a second try — would you like me to try again? If it happens again, try breaking your request into smaller steps.');
2822
2825
  }
2823
2826
  return this.turnDone(failureReason);
2824
2827
  }
@@ -3168,10 +3171,7 @@ export class ChatDriver extends EventTarget {
3168
3171
  this.failSubAgent('unknown_tool_limit');
3169
3172
  }
3170
3173
  else {
3171
- this.appendToHistory({
3172
- role: 'assistant',
3173
- content: "I'm sorry, I repeatedly tried to use tools that aren't available to me, so I couldn't complete that. If a 'Download agent log' option appears in the Settings (cog) menu, you can download the log and share it with whoever set up this assistant to help fix the issue.",
3174
- });
3174
+ this.appendDriverNotice("I'm sorry, I repeatedly tried to use tools that aren't available to me, so I couldn't complete that. If a 'Download agent log' option appears in the Settings (cog) menu, you can download the log and share it with whoever set up this assistant to help fix the issue.");
3175
3175
  }
3176
3176
  return this.turnDone('unknown-tool-limit');
3177
3177
  }
@@ -3202,16 +3202,32 @@ export class ChatDriver extends EventTarget {
3202
3202
  this.failSubAgent('max_iterations');
3203
3203
  }
3204
3204
  else {
3205
- this.appendToHistory({
3206
- role: 'assistant',
3207
- content: "I've reached my limit for this response. You can ask me to continue and I'll pick up where I left off.",
3208
- });
3205
+ this.appendDriverNotice("I've reached my limit for this response. You can ask me to continue and I'll pick up where I left off.");
3209
3206
  }
3210
3207
  failureReason = 'max-iterations';
3211
3208
  }
3212
3209
  return this.turnDone(failureReason);
3213
3210
  });
3214
3211
  }
3212
+ /**
3213
+ * Append prose the DRIVER wrote rather than the model — a failure notice, a limit explanation,
3214
+ * the budget wall. Renders as an ordinary assistant bubble and is flagged
3215
+ * `excludeFromProvider`, so it never re-enters the next request.
3216
+ *
3217
+ * Every such notice must go through here. Written as one funnel rather than a flag repeated at
3218
+ * eleven call sites because the failure mode is silent: a notice that keeps the flag reads
3219
+ * identically in the transcript to one that loses it, and the damage only shows up a turn later
3220
+ * as the model echoing its own error message. Measured (GENC-1573): with the empty-response
3221
+ * notice in history, the next turn reproduced it verbatim in 45 output tokens — succeeding,
3222
+ * with no retry and no `turn.error`, while still showing the user a failure. From there the
3223
+ * loop sustains itself whether or not the model answers, which is why "try again" never worked.
3224
+ *
3225
+ * Not for anything the model produced, and not for a widget/interaction message: those are real
3226
+ * turn content and the model must keep seeing them.
3227
+ */
3228
+ appendDriverNotice(content) {
3229
+ this.appendToHistory({ role: 'assistant', content, excludeFromProvider: true });
3230
+ }
3215
3231
  appendToHistory(message) {
3216
3232
  var _a;
3217
3233
  const tagged = Object.assign(Object.assign(Object.assign({}, message), {
@@ -1 +1 @@
1
- export { OrchestratingDriver } from './orchestrating-driver';
1
+ export { OrchestratingDriver, UNROUTABLE_INSTRUCTION, UNROUTABLE_PLACEHOLDER, } from './orchestrating-driver';