@genesislcap/ai-assistant 14.469.0 → 14.470.0

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 (33) hide show
  1. package/dist/ai-assistant.api.json +272 -3
  2. package/dist/ai-assistant.d.ts +95 -1
  3. package/dist/dts/components/chat-driver/chat-driver.d.ts +34 -1
  4. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  5. package/dist/dts/components/chat-driver/chat-driver.test.d.ts.map +1 -1
  6. package/dist/dts/config/config.d.ts +42 -2
  7. package/dist/dts/config/config.d.ts.map +1 -1
  8. package/dist/dts/config/define-stateful-agent.d.ts +14 -1
  9. package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
  10. package/dist/dts/main/main.d.ts +3 -0
  11. package/dist/dts/main/main.d.ts.map +1 -1
  12. package/dist/dts/state/debug-event-log.d.ts +3 -1
  13. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  14. package/dist/dts/utils/condense-history.d.ts +10 -0
  15. package/dist/dts/utils/condense-history.d.ts.map +1 -1
  16. package/dist/dts/utils/strip-agent-handlers.d.ts +2 -1
  17. package/dist/dts/utils/strip-agent-handlers.d.ts.map +1 -1
  18. package/dist/esm/components/chat-driver/chat-driver.js +87 -13
  19. package/dist/esm/components/chat-driver/chat-driver.test.js +95 -1
  20. package/dist/esm/config/define-stateful-agent.js +18 -0
  21. package/dist/esm/state/debug-event-log.js +1 -1
  22. package/dist/esm/utils/condense-history.js +11 -1
  23. package/dist/esm/utils/condense-history.test.js +43 -2
  24. package/dist/esm/utils/strip-agent-handlers.js +2 -1
  25. package/package.json +16 -16
  26. package/src/components/chat-driver/chat-driver.test.ts +115 -1
  27. package/src/components/chat-driver/chat-driver.ts +121 -18
  28. package/src/config/config.ts +46 -1
  29. package/src/config/define-stateful-agent.ts +47 -0
  30. package/src/state/debug-event-log.ts +5 -2
  31. package/src/utils/condense-history.test.ts +65 -2
  32. package/src/utils/condense-history.ts +18 -1
  33. package/src/utils/strip-agent-handlers.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,4BAA4B,EAAE,cAAc,EAAE,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,UAAU,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yDAAyD;IACzD,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACpC,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,mBAAmB,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAElG;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAC5B,kBAAkB,EAAE,GACpB,CAAC,CAAC,GAAG,EAAE,mBAAmB,KAAK,kBAAkB,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;AAEzF;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,CAAC,CAAC,GAAG,EAAE,mBAAmB,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC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C;IACpE;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAErE"}
@@ -1,4 +1,4 @@
1
- import type { ChatMessage, ChatToolChoice, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
1
+ import type { CachePolicy, ChatMessage, ChatToolChoice, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
2
2
  import type { AgentConfig, AgentLifecycleContext, ChatInputDuringExecutionMode, ManualSelectionConfig, SystemPromptContext, UnresolvedToolContext } from './config';
3
3
  /**
4
4
  * Context passed to per-turn resolvers on a stateful agent — the standard
@@ -123,6 +123,19 @@ export interface StatefulAgentInit<S> {
123
123
  * for the default.
124
124
  */
125
125
  toolChoice?: ChatToolChoice | ((ctx: StatefulAgentContext<S>) => ChatToolChoice | Promise<ChatToolChoice>);
126
+ /**
127
+ * Prompt-cache policy. Either a static `CachePolicy` or a function resolved each tool-loop
128
+ * iteration with the current `state` — pick the function form to vary it per machine state
129
+ * (e.g. `'history'` in a long generating phase, `'default'` in short low-touch ones). Omit to
130
+ * request no caching.
131
+ */
132
+ cachePolicy?: CachePolicy | ((ctx: StatefulAgentContext<S>) => CachePolicy | Promise<CachePolicy>);
133
+ /**
134
+ * Volatile per-turn tail context (current file/spec, diagnostics, live state). Either a static
135
+ * string or a function resolved each tool-loop iteration with the current `state`. Provide raw
136
+ * content; the framework frames it. Omit, or return an empty string, for none.
137
+ */
138
+ tailContext?: string | ((ctx: StatefulAgentContext<S>) => string | Promise<string>);
126
139
  /**
127
140
  * Hook consulted when the model calls a tool that isn't dispatchable in the
128
141
  * current state — a *stale* tool (valid in an earlier state of this agent) or
@@ -1 +1 @@
1
- {"version":3,"file":"define-stateful-agent.d.ts","sourceRoot":"","sources":["../../../src/config/define-stateful-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EAErB,mBAAmB,EAMnB,qBAAqB,EAEtB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,mBAAmB,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,2GAA2G;IAC3G,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,gFAAgF;IAChF,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1B,oDAAoD;IACpD,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,qEAAqE;IACrE,wBAAwB,CAAC,EAAE,4BAA4B,CAAC;IAExD;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AAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAEjF;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,CACjB,GAAG,EAAE,qBAAqB,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,KACtC,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEtD;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CAC1C;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,WAAW,CAmL9E"}
1
+ {"version":3,"file":"define-stateful-agent.d.ts","sourceRoot":"","sources":["../../../src/config/define-stateful-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EAErB,4BAA4B,EAC5B,qBAAqB,EAErB,mBAAmB,EAOnB,qBAAqB,EAEtB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,mBAAmB,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,2GAA2G;IAC3G,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,gFAAgF;IA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AE,oBAAoB,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpF;;;;;;OAMG;IACH,UAAU,CAAC,EACP,cAAc,GACd,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAEjF;;;;;OAKG;IACH,WAAW,CAAC,EACR,WAAW,GACX,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAE3E;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpF;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,CACjB,GAAG,EAAE,qBAAqB,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,KACtC,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEtD;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CAC1C;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,WAAW,CA8M9E"}
@@ -417,6 +417,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
417
417
  turnIndex: string;
418
418
  timestamp: string;
419
419
  agentName?: string;
420
+ tailContext?: string;
420
421
  toolNames: string[];
421
422
  temperature?: number;
422
423
  toolChoice?: import("@genesislcap/foundation-ai").ChatToolChoice;
@@ -445,6 +446,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
445
446
  systemPrompt?: import("../config/config").SystemPromptInput;
446
447
  temperature?: import("../config/config").TemperatureInput;
447
448
  toolChoice?: import("../config/config").ToolChoiceInput;
449
+ cachePolicy?: import("../config/config").CachePolicyInput;
450
+ tailContext?: import("../config/config").TailContextInput;
448
451
  onUnresolvedTool?: import("../config/config").UnresolvedToolInput;
449
452
  primerHistory?: ChatMessage[];
450
453
  subAgents?: AgentConfig[];
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main/main.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,UAAU,EACV,4BAA4B,EAC5B,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAkC,MAAM,4BAA4B,CAAC;AAEhG,OAAO,EAGL,cAAc,EAIf,MAAM,uBAAuB,CAAC;AAe/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAiBtB,8FAA8F;AAC9F,eAAO,MAAM,cAAc,ugBAAqf,CAAC;AAEjhB,+CAA+C;AAC/C,eAAO,MAAM,WAAW,0OAAgO,CAAC;AAEzP,sFAAsF;AACtF,eAAO,MAAM,cAAc,yrBAA+qB,CAAC;AA2C3sB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAOa,qBAAsB,SAAQ,cAAc;IACnC,gBAAgB,EAAG,kBAAkB,CAAC;IAE9C,kBAAkB,EAAE,MAAM,CAAW;IACZ,WAAW,EAAE,MAAM,CAAuB;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IAE7D;;;;;;OAMG;IACS,aAAa,CAAC,EA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C,UAAU,EAAE,cAAc,GAAG,IAAI;IAIlD,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAU5C,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,cAAc;YASR,YAAY;YAoCZ,iBAAiB;IAe/B,eAAe;IAIf;;;;OAIG;IACH,eAAe;IAOf,qBAAqB,CAAC,UAAU,EAAE,MAAM;IAKxC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,aAAa,CAAC,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;YA0C7E,gBAAgB;YA6DhB,IAAI;IAgDlB,qBAAqB,CAAC,CAAC,EAAE,UAAU;IAYnC,0BAA0B,CAAC,CAAC,EAAE,KAAK;IASnC;iFAC6E;IAC7E,IAAI,mBAAmB,IAAI,OAAO,CAEjC;IAED;;;iCAG6B;IAC7B,IAAI,mBAAmB,IAAI,MAAM,CAIhC;IAED;iEAC6D;IAC7D,qBAAqB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAoB5C;;;qDAGiD;IACjD,oBAAoB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAS3C,yDAAyD;IACzD,mBAAmB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;CAI3C"}
@@ -77,8 +77,10 @@ export declare function recordMetaEvent(key: string, type: MetaEventType, detail
77
77
  * - `unknown-tool-limit` — the model repeatedly called tools it couldn't dispatch,
78
78
  * whether hallucinated or stale (real earlier, retired now).
79
79
  * - `max-iterations` — the tool loop hit its iteration cap.
80
+ * - `response-truncated` — a turn stopped at the provider's output-token cap with an
81
+ * incomplete tool call; deterministic, so it bails without retry.
80
82
  */
81
- export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations';
83
+ export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated';
82
84
  /**
83
85
  * Record a turn-ending failure (`turn.error`, importance `high`). The `reason`
84
86
  * is typed so the high-importance triage surface stays consistent; pass any
@@ -1 +1 @@
1
- {"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;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,GAEtB,iBAAiB,GACjB,2BAA2B,GAC3B,mBAAmB,GAEnB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,CAAC;AAEzB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAiC5E,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,IAAI,EAAE,aAAa,CAAC;IACpB,6EAA6E;IAC7E,UAAU,EAAE,mBAAmB,CAAC;IAChC,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAmBD;;;;;;GAMG;AACH,w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AM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,CAAC,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;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAc7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -40,6 +40,8 @@ export interface RegisteredCondensePolicy {
40
40
  turn: number;
41
41
  /** Agent-activation sequence when the call was made — the `agentEnd` clock. */
42
42
  activation: number;
43
+ /** App-controlled phase epoch when the call was made — the `phaseEnd` clock. */
44
+ phaseEpoch: number;
43
45
  /** `context.condensed` already emitted for the args payload (fire-once). */
44
46
  reportedArgs?: boolean;
45
47
  /** `context.condensed` already emitted for the response payload (fire-once). */
@@ -57,6 +59,11 @@ export interface CondenseContext {
57
59
  turn: number;
58
60
  /** Whether the agent activation that made a call has since ended — the `agentEnd` clock. */
59
61
  activationEnded: (activation: number) => boolean;
62
+ /**
63
+ * Whether a later phase epoch is current than the one a call was made in — the
64
+ * `phaseEnd` clock. True once `endPhase()` has been called since the call.
65
+ */
66
+ phaseEnded: (phaseEpoch: number) => boolean;
60
67
  }
61
68
  /**
62
69
  * Structured detail for a `context.condensed` meta-event. The index signature
@@ -101,6 +108,9 @@ export interface CondensedEventDetail {
101
108
  * - `agentEnd` — collapses once the agent activation that made the call has ended
102
109
  * (a swap to another agent, or `releaseAgent`/`completeSubAgent`): kept across
103
110
  * all of the agent's turns, dropped when its flow finishes.
111
+ * - `phaseEnd` — collapses once the app advances its phase epoch via `endPhase()`
112
+ * after the call (a sub-`agentEnd` boundary the author declares), OR at
113
+ * `agentEnd` as a backstop if no boundary is ever declared.
104
114
  *
105
115
  * The tool-call/result envelope is never removed (providers reject orphaned
106
116
  * calls/results) — only the args object or the result content is replaced.
@@ -1 +1 @@
1
- {"version":3,"file":"condense-history.d.ts","sourceRoot":"","sources":["../../../src/utils/condense-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAmB,MAAM,4BAA4B,CAAC;AAE/F;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAQ9C;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,cAAc,CAAC;IACvB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAClD;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IAC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E,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD;;;OAGG;IACH,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;CACrB;AA8CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,EAC/C,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,GAClD,WAAW,EAAE,CAyIf"}
@@ -6,7 +6,8 @@ import type { AgentConfig } from '../config/config';
6
6
  * 1. **Directly function-valued** — the lifecycle/dispatch hooks (`onActivate`,
7
7
  * `onDeactivate`, `getDebugSnapshot`, `onUnresolvedTool`) and the function
8
8
  * form of the per-turn resolvers (`systemPrompt`, `toolDefinitions`,
9
- * `displayName`, `provider`, `temperature`, `toolChoice`, `toolHandlers`).
9
+ * `displayName`, `provider`, `temperature`, `toolChoice`, `cachePolicy`,
10
+ * `toolHandlers`).
10
11
  * 2. **Object "handler bags" whose *values* are functions** — `toolHandlers` in
11
12
  * its object form is `{ name: handler }`, so `typeof` is `'object'`, not
12
13
  * `'function'`. A by-value check on the field alone misses it, leaking a live
@@ -1 +1 @@
1
- {"version":3,"file":"strip-agent-handlers.d.ts","sourceRoot":"","sources":["../../../src/utils/strip-agent-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAuBxF"}
1
+ {"version":3,"file":"strip-agent-handlers.d.ts","sourceRoot":"","sources":["../../../src/utils/strip-agent-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAuBxF"}
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from "tslib";
2
- import { isObservableAIProviderRegistry, MalformedFunctionCallError, } from '@genesislcap/foundation-ai';
2
+ import { isObservableAIProviderRegistry, MalformedFunctionCallError, ResponseTruncatedError, } from '@genesislcap/foundation-ai';
3
3
  import { agenticActivityBus } from '../../channel/ai-activity-bus';
4
4
  import { resolveChatProvider } from '../../config/validate-providers';
5
5
  import { clearSession, getMetaEvents, mergeMetaEvents, recordMetaEvent, recordTurnError, recordTurnRetry, } from '../../state/debug-event-log';
@@ -110,6 +110,15 @@ export class ChatDriver extends EventTarget {
110
110
  * collapsed until IT ends.
111
111
  */
112
112
  this.currentActivation = 0;
113
+ /**
114
+ * Monotonic phase-epoch counter — the `phaseEnd` clock. Advanced by the
115
+ * handler-context `endPhase()` (an app-declared phase boundary within one
116
+ * activation), never reset. Unlike `currentActivation` it is NOT tied to agent
117
+ * swaps or releases — it ticks only when the agent itself declares a phase
118
+ * done. `phaseEnd` fires for a payload once a LATER epoch is current
119
+ * (`callPhaseEpoch < currentPhaseEpoch`), with an `agentEnd` backstop.
120
+ */
121
+ this.currentPhaseEpoch = 0;
113
122
  /** Stack of fold frames — grows when a fold opens, shrinks when it closes. */
114
123
  this.foldStack = [];
115
124
  /** Consecutive fold open/close ops without a real tool call. Reset on real tool execution. */
@@ -355,6 +364,8 @@ export class ChatDriver extends EventTarget {
355
364
  this.activeProviderInput = config.provider;
356
365
  this.activeTemperatureInput = config.temperature;
357
366
  this.activeToolChoiceInput = config.toolChoice;
367
+ this.activeCachePolicyInput = config.cachePolicy;
368
+ this.activeTailContextInput = config.tailContext;
358
369
  this.activeOnUnresolvedTool = config.onUnresolvedTool;
359
370
  this.resolvedProviderCache.clear();
360
371
  this.lastResolvedProviderName = undefined;
@@ -591,7 +602,7 @@ export class ChatDriver extends EventTarget {
591
602
  * before each LLM call — that's the latest point where the prompt, tool
592
603
  * surface, and agent state line up with what the model is about to see.
593
604
  */
594
- recordTurnSnapshot(resolvedSystemPrompt, temperature, toolChoice) {
605
+ recordTurnSnapshot(resolvedSystemPrompt, temperature, toolChoice, tailContext) {
595
606
  let agentSnapshot;
596
607
  if (this.debugSnapshotter) {
597
608
  try {
@@ -612,6 +623,7 @@ export class ChatDriver extends EventTarget {
612
623
  agentName: this.activeAgentName,
613
624
  agentLabel: this.activeAgentLabel,
614
625
  systemPrompt: resolvedSystemPrompt,
626
+ tailContext,
615
627
  toolNames: this.toolDefinitions.map((t) => t.name),
616
628
  temperature,
617
629
  toolChoice,
@@ -997,6 +1009,12 @@ export class ChatDriver extends EventTarget {
997
1009
  // The stateful flow has wrapped up — advance the clock so its `agentEnd`
998
1010
  // payloads collapse and a re-run starts a fresh activation.
999
1011
  this.currentActivation += 1;
1012
+ }, endPhase: () => {
1013
+ // Advance the phase epoch so payloads registered with `{ on: phaseEnd }`
1014
+ // during the phase that just ended collapse on the next provider call.
1015
+ // Repeatable (no once-only guard, unlike releaseAgent/completeSubAgent):
1016
+ // each call opens a fresh phase for subsequent reads to accumulate in.
1017
+ this.currentPhaseEpoch += 1;
1000
1018
  }, condenseWhen: (policy) => {
1001
1019
  var _a, _b, _c;
1002
1020
  // No addressable tool call (e.g. fold-close handler) — nothing to attach to.
@@ -1011,7 +1029,7 @@ export class ChatDriver extends EventTarget {
1011
1029
  ? typeof t.by === 'string' && t.by.length > 0
1012
1030
  : (t === null || t === void 0 ? void 0 : t.kind) === 'age'
1013
1031
  ? typeof t.turns === 'number' && t.turns >= 1
1014
- : (t === null || t === void 0 ? void 0 : t.kind) === 'turnEnd' || (t === null || t === void 0 ? void 0 : t.kind) === 'agentEnd';
1032
+ : (t === null || t === void 0 ? void 0 : t.kind) === 'turnEnd' || (t === null || t === void 0 ? void 0 : t.kind) === 'agentEnd' || (t === null || t === void 0 ? void 0 : t.kind) === 'phaseEnd';
1015
1033
  if (triggers.length === 0 || !triggers.every(validTrigger)) {
1016
1034
  logger.warn(`ChatDriver(${(_b = this.activeAgentName) !== null && _b !== void 0 ? _b : 'unknown'}): condenseWhen called with an invalid trigger — ignoring`);
1017
1035
  return;
@@ -1029,6 +1047,7 @@ export class ChatDriver extends EventTarget {
1029
1047
  iteration: this.modelCallSeq,
1030
1048
  turn: this.turnSeq,
1031
1049
  activation: this.currentActivation,
1050
+ phaseEpoch: this.currentPhaseEpoch,
1032
1051
  });
1033
1052
  } });
1034
1053
  }
@@ -1496,10 +1515,17 @@ export class ChatDriver extends EventTarget {
1496
1515
  // oxlint-disable-next-line no-await-in-loop
1497
1516
  this.activeAgentLabel = yield this.displayName(promptCtx);
1498
1517
  }
1518
+ // Volatile framework additions — the fold-surface suffix and the per-attempt malformed/empty
1519
+ // retry nudge — that would otherwise destabilize a cached system prompt. They are routed to
1520
+ // the framed tail (below), never appended to the system string, so the system prompt stays
1521
+ // byte-stable for every agent.
1499
1522
  const foldSuffix = this.buildFoldSystemPromptSuffix();
1500
- const baseSystemPrompt = resolvedSystemPrompt
1501
- ? `${resolvedSystemPrompt}${foldSuffix}`
1502
- : foldSuffix || undefined;
1523
+ const retryNudge = malformedAttempts > 0
1524
+ ? '\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.'
1525
+ : emptyResponseAttempts > 0
1526
+ ? "\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."
1527
+ : '';
1528
+ const frameworkSystemSuffix = `${foldSuffix}${retryNudge}`;
1503
1529
  const primer = [...((_b = this.primerHistory) !== null && _b !== void 0 ? _b : []), ...(transientPrimer !== null && transientPrimer !== void 0 ? transientPrimer : [])];
1504
1530
  const baseHistory = firstLlmCall ? this.history.slice(0, -1) : this.history;
1505
1531
  firstLlmCall = false;
@@ -1512,31 +1538,45 @@ export class ChatDriver extends EventTarget {
1512
1538
  // A call's activation has ended once a later activation is current — a
1513
1539
  // swap or release/complete both advance the counter.
1514
1540
  activationEnded: (activation) => activation < this.currentActivation,
1541
+ // A call's phase has ended once the app declared a later phase epoch
1542
+ // current via `endPhase()`.
1543
+ phaseEnded: (phaseEpoch) => phaseEpoch < this.currentPhaseEpoch,
1515
1544
  }, (detail) => recordMetaEvent(this.sessionKey, 'context.condensed', detail));
1516
1545
  const historyForProvider = this.providerHistoryTransform
1517
1546
  ? this.providerHistoryTransform(condensedHistory)
1518
1547
  : condensedHistory;
1519
1548
  const historyForCall = [...primer, ...historyForProvider];
1520
- const systemPrompt = malformedAttempts > 0
1521
- ? `${baseSystemPrompt !== null && baseSystemPrompt !== void 0 ? baseSystemPrompt : ''}\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.`
1522
- : emptyResponseAttempts > 0
1523
- ? `${baseSystemPrompt !== null && baseSystemPrompt !== void 0 ? baseSystemPrompt : ''}\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.`
1524
- : baseSystemPrompt;
1525
1549
  // Resolve the per-turn temperature and tool-call mode the same way the
1526
1550
  // provider is resolved — static value or a function of the turn context
1527
1551
  // (which carries the live state for stateful agents). Resolved before the
1528
1552
  // snapshot so the debug log records the exact request config the model saw.
1553
+ const [resolvedTemperature, resolvedToolChoice, resolvedCachePolicy, resolvedTailContext] =
1529
1554
  // oxlint-disable-next-line no-await-in-loop
1530
- const [resolvedTemperature, resolvedToolChoice] = yield Promise.all([
1555
+ yield Promise.all([
1531
1556
  this.resolveTurnInput(this.activeTemperatureInput, promptCtx),
1532
1557
  this.resolveTurnInput(this.activeToolChoiceInput, promptCtx),
1558
+ this.resolveTurnInput(this.activeCachePolicyInput, promptCtx),
1559
+ this.resolveTurnInput(this.activeTailContextInput, promptCtx),
1533
1560
  ]);
1561
+ // The system prompt is always just the agent's resolved prompt — byte-stable, so it can be
1562
+ // cached. The framework's volatile additions (fold suffix, retry nudge) and the agent's tail
1563
+ // context all go to the framed tail: one uniform channel, no cache-scope branch. On a normal
1564
+ // turn `frameworkSystemSuffix` is empty, so the tail is empty too — a no-op. The framework
1565
+ // owns the framing; the corrective retry nudge lands last (recency).
1566
+ const systemPrompt = resolvedSystemPrompt || undefined;
1567
+ const tailBody = [resolvedTailContext, frameworkSystemSuffix]
1568
+ .map((part) => (part !== null && part !== void 0 ? part : '').trim())
1569
+ .filter((part) => part.length > 0)
1570
+ .join('\n\n');
1571
+ const tailContext = tailBody
1572
+ ? `<system-reminder>\n${tailBody}\n</system-reminder>`
1573
+ : undefined;
1534
1574
  // An agent/state-configured tool-call mode wins. Otherwise sub-agents must
1535
1575
  // finish by calling a tool (their completion tool) so the turn can't end
1536
1576
  // on a free-text answer; top-level agents stay 'auto'. (Transports no-op a
1537
1577
  // force when no tools are advertised.)
1538
1578
  const effectiveToolChoice = resolvedToolChoice !== null && resolvedToolChoice !== void 0 ? resolvedToolChoice : (this.isSubAgent ? 'required' : undefined);
1539
- this.recordTurnSnapshot(systemPrompt, resolvedTemperature, effectiveToolChoice);
1579
+ this.recordTurnSnapshot(systemPrompt, resolvedTemperature, effectiveToolChoice, tailContext);
1540
1580
  // Capture the pending user input, then clear the slots BEFORE the chat
1541
1581
  // call. `sendMessage` already appended the user message to `this.history`,
1542
1582
  // so on retries (empty / malformed) we must rely on history alone —
@@ -1559,6 +1599,11 @@ export class ChatDriver extends EventTarget {
1559
1599
  // Agent/state-configured sampling temperature (normalized 0–1); each
1560
1600
  // transport translates it to its native range. Undefined → provider default.
1561
1601
  temperature: resolvedTemperature,
1602
+ // Prompt-cache policy for this turn (Anthropic places breakpoints per scope; Gemini
1603
+ // caches implicitly regardless). Undefined → no caching requested.
1604
+ cachePolicy: resolvedCachePolicy,
1605
+ // Framed volatile context injected at the message tail (never stored). Undefined → none.
1606
+ tailContext,
1562
1607
  };
1563
1608
  // Resolve the active provider for this turn. Static names were validated
1564
1609
  // in `applyAgent`; function-form names are validated on first resolution
@@ -1605,6 +1650,35 @@ export class ChatDriver extends EventTarget {
1605
1650
  }
1606
1651
  return { reason: 'done' };
1607
1652
  }
1653
+ // The response was truncated at the provider's output-token cap while it
1654
+ // still carried a tool call — its arguments are incomplete and unusable.
1655
+ // Unlike a malformed call this is DETERMINISTIC: re-issuing the same
1656
+ // request hits the same cap, so a silent retry just loops. Bail with a
1657
+ // clear, actionable signal instead. The remedy is config (raise the
1658
+ // provider maxTokens) or a smaller step — neither is fixed by retrying.
1659
+ if (e instanceof ResponseTruncatedError) {
1660
+ logger.error('ChatDriver: response truncated at the output-token cap', e);
1661
+ recordTurnError(this.sessionKey, 'response-truncated', {
1662
+ agent: this.activeAgentName,
1663
+ provider: this.lastResolvedProviderName,
1664
+ model: e.model,
1665
+ maxTokens: e.maxTokens,
1666
+ outputTokens: e.outputTokens,
1667
+ tools: e.toolNames,
1668
+ isSubAgent: this.isSubAgent,
1669
+ });
1670
+ if (this.isSubAgent) {
1671
+ // Bubble a typed failure to the parent instead of speaking to the user.
1672
+ this.failSubAgent('response_truncated');
1673
+ }
1674
+ else {
1675
+ this.appendToHistory({
1676
+ role: 'assistant',
1677
+ 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.',
1678
+ });
1679
+ }
1680
+ return { reason: 'done' };
1681
+ }
1608
1682
  // A request timeout from the transport (tagged `TimeoutError`) is not a
1609
1683
  // bug on our end — surface it distinctly instead of letting it fall
1610
1684
  // through to the generic "something went wrong" catch. No auto-retry:
@@ -14,17 +14,26 @@ const scriptedProvider = (responses) => {
14
14
  const advertisedPerCall = [];
15
15
  const toolChoicePerCall = [];
16
16
  const temperaturePerCall = [];
17
+ const cachePolicyPerCall = [];
18
+ const tailContextPerCall = [];
19
+ const systemPromptPerCall = [];
17
20
  const historyPerCall = [];
18
21
  return {
19
22
  advertisedPerCall,
20
23
  toolChoicePerCall,
21
24
  temperaturePerCall,
25
+ cachePolicyPerCall,
26
+ tailContextPerCall,
27
+ systemPromptPerCall,
22
28
  historyPerCall,
23
29
  chat: (history, _userMessage, options) => __awaiter(void 0, void 0, void 0, function* () {
24
30
  var _a, _b;
25
31
  advertisedPerCall.push(((_a = options === null || options === void 0 ? void 0 : options.tools) !== null && _a !== void 0 ? _a : []).map((t) => t.name));
26
32
  toolChoicePerCall.push(options === null || options === void 0 ? void 0 : options.toolChoice);
27
33
  temperaturePerCall.push(options === null || options === void 0 ? void 0 : options.temperature);
34
+ cachePolicyPerCall.push(options === null || options === void 0 ? void 0 : options.cachePolicy);
35
+ tailContextPerCall.push(options === null || options === void 0 ? void 0 : options.tailContext);
36
+ systemPromptPerCall.push(options === null || options === void 0 ? void 0 : options.systemPrompt);
28
37
  // Snapshot the slice (condensation produces fresh objects per call and never
29
38
  // mutates stored history, so a shallow array copy is a stable per-call view).
30
39
  historyPerCall.push([...history]);
@@ -774,14 +783,26 @@ subagent.run();
774
783
  const settings = createLogicSuite('ChatDriver temperature & toolChoice');
775
784
  settings('passes a static agent temperature and tool-call mode to the provider', () => __awaiter(void 0, void 0, void 0, function* () {
776
785
  const provider = scriptedProvider([]);
777
- const driver = makeDriver(agent({ name: 'a', temperature: 0.3, toolChoice: 'none' }), provider);
786
+ const driver = makeDriver(agent({
787
+ name: 'a',
788
+ temperature: 0.3,
789
+ toolChoice: 'none',
790
+ cachePolicy: { scope: 'prompt' },
791
+ tailContext: 'STATE',
792
+ }), provider);
778
793
  yield driver.sendMessage('hi');
779
794
  assert.is(provider.temperaturePerCall[0], 0.3);
780
795
  assert.equal(provider.toolChoicePerCall[0], 'none');
796
+ assert.equal(provider.cachePolicyPerCall[0], { scope: 'prompt' });
797
+ // The driver frames the raw tail content in a <system-reminder> marker.
798
+ assert.is(provider.tailContextPerCall[0], '<system-reminder>\nSTATE\n</system-reminder>');
781
799
  // ...and surfaced in the per-turn debug snapshot (the effective values sent).
782
800
  const snap = driver.getTurnSnapshots()[0];
783
801
  assert.is(snap.temperature, 0.3);
784
802
  assert.equal(snap.toolChoice, 'none');
803
+ // The framed tail is captured on the snapshot too — it is never stored in
804
+ // history, so the snapshot is the only record of what the model actually saw.
805
+ assert.is(snap.tailContext, '<system-reminder>\nSTATE\n</system-reminder>');
785
806
  }));
786
807
  settings('re-resolves the function form per turn (carrying turn context)', () => __awaiter(void 0, void 0, void 0, function* () {
787
808
  const provider = scriptedProvider([callsTool('tool_a', 't1')]);
@@ -792,20 +813,50 @@ settings('re-resolves the function form per turn (carrying turn context)', () =>
792
813
  // turnIndex: 0 on the first LLM call, > 0 on subsequent tool-loop iterations.
793
814
  temperature: (ctx) => (ctx.turnIndex === 0 ? 0.1 : 0.9),
794
815
  toolChoice: (ctx) => (ctx.turnIndex === 0 ? { tool: 'tool_a' } : 'auto'),
816
+ cachePolicy: (ctx) => (ctx.turnIndex === 0 ? { scope: 'history' } : { scope: 'tools' }),
795
817
  });
796
818
  yield makeDriver(config, provider).sendMessage('go');
797
819
  // First call forces the named tool at a low temperature...
798
820
  assert.is(provider.temperaturePerCall[0], 0.1);
799
821
  assert.equal(provider.toolChoicePerCall[0], { tool: 'tool_a' });
822
+ assert.equal(provider.cachePolicyPerCall[0], { scope: 'history' });
800
823
  // ...the follow-up call (after the tool result) sees the other branch.
801
824
  assert.is(provider.temperaturePerCall[1], 0.9);
802
825
  assert.equal(provider.toolChoicePerCall[1], 'auto');
826
+ assert.equal(provider.cachePolicyPerCall[1], { scope: 'tools' });
803
827
  }));
804
828
  settings('leaves temperature and toolChoice unset when the agent does not configure them', () => __awaiter(void 0, void 0, void 0, function* () {
805
829
  const provider = scriptedProvider([]);
806
830
  yield makeDriver(agent({ name: 'c' }), provider).sendMessage('hi');
807
831
  assert.is(provider.temperaturePerCall[0], undefined);
808
832
  assert.is(provider.toolChoicePerCall[0], undefined);
833
+ assert.is(provider.cachePolicyPerCall[0], undefined);
834
+ assert.is(provider.tailContextPerCall[0], undefined);
835
+ }));
836
+ // GENC-1380 A3b: the framework's malformed/empty retry nudge is routed to the framed tail (so the
837
+ // system prompt stays byte-stable for caching), not appended to the system string.
838
+ settings('routes the empty-response retry nudge into the framed tail, not the system prompt', () => __awaiter(void 0, void 0, void 0, function* () {
839
+ var _a, _b, _c;
840
+ // First call returns empty → the driver retries; the second exhausts the queue and ends the turn.
841
+ const provider = scriptedProvider([{ role: 'assistant', content: '' }]);
842
+ const driver = makeDriver(agent({ name: 'r', systemPrompt: 'BASE' }), provider);
843
+ yield driver.sendMessage('go');
844
+ // The retry call (index 1) carries the nudge in the framed tail...
845
+ assert.ok((_a = provider.tailContextPerCall[1]) === null || _a === void 0 ? void 0 : _a.startsWith('<system-reminder>'), 'tail is framed');
846
+ assert.ok((_b = provider.tailContextPerCall[1]) === null || _b === void 0 ? void 0 : _b.includes('You must respond'), 'retry nudge is in the tail');
847
+ // ...and the system prompt stays the bare agent prompt on both calls (nudge moved, not copied).
848
+ assert.is(provider.systemPromptPerCall[0], 'BASE');
849
+ assert.is(provider.systemPromptPerCall[1], 'BASE');
850
+ // Regression guard (debug-log reconstruction): the tail is never stored in
851
+ // history, so the per-turn snapshot must capture it — otherwise the retry
852
+ // nudge the model actually received would be invisible in the export. The
853
+ // snapshot's (systemPrompt + tailContext) must equal what the provider saw.
854
+ const retrySnap = driver.getTurnSnapshots()[1];
855
+ assert.is(retrySnap.systemPrompt, provider.systemPromptPerCall[1]);
856
+ assert.is(retrySnap.tailContext, provider.tailContextPerCall[1]);
857
+ assert.ok((_c = retrySnap.tailContext) === null || _c === void 0 ? void 0 : _c.includes('You must respond'), 'nudge reconstructable');
858
+ // The first (non-retry) call had no framework suffix and no agent tail → empty.
859
+ assert.is(driver.getTurnSnapshots()[0].tailContext, undefined);
809
860
  }));
810
861
  settings.run();
811
862
  // ---------------------------------------------------------------------------
@@ -1386,4 +1437,47 @@ condense('agentEnd: collapses once the agent releases (flow complete)', () => __
1386
1437
  assert.is(events.length, 1);
1387
1438
  assert.is((_a = events[0].detail) === null || _a === void 0 ? void 0 : _a.trigger, 'agentEnd');
1388
1439
  }));
1440
+ condense('phaseEnd: collapses at endPhase() while the agent keeps running', () => __awaiter(void 0, void 0, void 0, function* () {
1441
+ var _a;
1442
+ const sessionKey = 'condense-phase-end';
1443
+ clearMetaEventRegistry();
1444
+ const provider = scriptedProvider([
1445
+ { role: 'assistant', content: '', toolCalls: [{ id: 's1', name: 'load', args: {} }] }, // call 1
1446
+ { role: 'assistant', content: '', toolCalls: [{ id: 'a1', name: 'advance', args: {} }] }, // call 2 — ends the phase
1447
+ { role: 'assistant', content: 'continuing' }, // call 3 — agent still active, just answers
1448
+ ]);
1449
+ const config = agent({
1450
+ name: 'journey',
1451
+ systemPrompt: 'a multi-phase flow',
1452
+ toolDefinitions: [def('load'), def('advance')],
1453
+ toolHandlers: {
1454
+ load: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
1455
+ ctx.condenseWhen({ on: { kind: 'phaseEnd' }, response: 'pointer' });
1456
+ return bigBody;
1457
+ }),
1458
+ advance: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
1459
+ var _a;
1460
+ // Declares a phase boundary WITHOUT ending the agent (no releaseAgent).
1461
+ (_a = ctx.endPhase) === null || _a === void 0 ? void 0 : _a.call(ctx);
1462
+ return 'next phase';
1463
+ }),
1464
+ },
1465
+ });
1466
+ const driver = makeDriver(config, provider, sessionKey);
1467
+ const result = yield driver.sendMessage('run the flow');
1468
+ // The agent never released — the turn ends normally on the text response.
1469
+ assert.is(result.reason, 'done');
1470
+ // call #2 (index 1) ran before `advance` ended the phase — result still full.
1471
+ const beforePhaseEnd = provider.historyPerCall[1].find((m) => { var _a; return ((_a = m.toolResult) === null || _a === void 0 ? void 0 : _a.toolCallId) === 's1'; });
1472
+ assert.is(beforePhaseEnd.toolResult.content, bigBody, 'full while the phase is current');
1473
+ // call #3 (index 2) ran after endPhase() — collapsed. The activation never ended
1474
+ // (no release/swap), so this collapse can ONLY be the phase boundary, not the
1475
+ // agentEnd backstop.
1476
+ const afterPhaseEnd = provider.historyPerCall[2].find((m) => { var _a; return ((_a = m.toolResult) === null || _a === void 0 ? void 0 : _a.toolCallId) === 's1'; });
1477
+ assert.match(afterPhaseEnd.toolResult.content, /re-call to restore/, 'collapsed at phase end');
1478
+ assert.match(afterPhaseEnd.toolResult.content, /phase ended/);
1479
+ const events = getMetaEvents(sessionKey).filter((e) => e.type === 'context.condensed');
1480
+ assert.is(events.length, 1);
1481
+ assert.is((_a = events[0].detail) === null || _a === void 0 ? void 0 : _a.trigger, 'phaseEnd');
1482
+ }));
1389
1483
  condense.run();
@@ -136,6 +136,22 @@ export function defineStatefulAgent(opts) {
136
136
  return opts.toolChoice(Object.assign(Object.assign({}, ctx), { state }));
137
137
  })
138
138
  : opts.toolChoice;
139
+ const wrappedCachePolicy = typeof opts.cachePolicy === 'function'
140
+ ? (ctx) => __awaiter(this, void 0, void 0, function* () {
141
+ if (!state) {
142
+ throw new Error(`Stateful agent "${opts.name}" cachePolicy called before init`);
143
+ }
144
+ return opts.cachePolicy(Object.assign(Object.assign({}, ctx), { state }));
145
+ })
146
+ : opts.cachePolicy;
147
+ const wrappedTailContext = typeof opts.tailContext === 'function'
148
+ ? (ctx) => __awaiter(this, void 0, void 0, function* () {
149
+ if (!state) {
150
+ throw new Error(`Stateful agent "${opts.name}" tailContext called before init`);
151
+ }
152
+ return opts.tailContext(Object.assign(Object.assign({}, ctx), { state }));
153
+ })
154
+ : opts.tailContext;
139
155
  // `onUnresolvedTool` threads `state` in like the resolvers above, but unlike
140
156
  // them returns `undefined` before init rather than throwing: it fires on the
141
157
  // tool-dispatch path, so a pre-init call must degrade to the framework
@@ -160,6 +176,8 @@ export function defineStatefulAgent(opts) {
160
176
  provider: wrappedProvider,
161
177
  temperature: wrappedTemperature,
162
178
  toolChoice: wrappedToolChoice,
179
+ cachePolicy: wrappedCachePolicy,
180
+ tailContext: wrappedTailContext,
163
181
  onUnresolvedTool: wrappedOnUnresolvedTool,
164
182
  onActivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
165
183
  state = yield opts.init(ctx);
@@ -190,7 +190,7 @@ export const DEBUG_LOG_README = [
190
190
  "kind:'turn'.`agentSnapshot` — the active agent's own view of its internal state, captured at that turn. An agent opts into this by exposing a `getDebugSnapshot()` that returns JSON-serializable per-state info; stateful/flow agents wire it automatically, so you can watch a flow advance turn-by-turn (e.g. current step, cursor, collected fields, pending changes). Absent for agents that don't expose one.",
191
191
  "kind:'event' — a meta/lifecycle event. `type` names it (see below); `detail` carries structured data. `detail.placement` is the emitting UI instance: 'bubble' (collapsed), 'panel' (popped-out), or 'standalone'.",
192
192
  "Each 'event' also has an `importance`: 'high' (failures/limits — turn.error, tool.failed, subagent.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow — connects, turns, retries, handoffs, agent/provider changes, interactions, sub-agent start/complete), or 'low' (skippable UI/bookkeeping noise — panel.toggled, attachment.added, driver.wired/unwired, context.updated, context.condensed). To skim, ignore importance:'low'; to triage a failure, filter to importance:'high' then read the nearby messages and turns. A 'high' turn.error is often preceded by one or more 'normal' turn.retry events for the same reason — read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance — they are the substance, always read them.",
193
- 'Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation — detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), provider.selected (model/provider for the upcoming turns), interaction.requested/resolved (blocking user widgets — explain quiet gaps; note that when a sub-agent opens a widget, detail.agent — and the agentName on the interaction message — is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver), context.updated/threshold-crossed (token + cost), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool — detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.',
193
+ 'Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation — detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), provider.selected (model/provider for the upcoming turns), interaction.requested/resolved (blocking user widgets — explain quiet gaps; note that when a sub-agent opens a widget, detail.agent — and the agentName on the interaction message — is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver), context.updated/threshold-crossed (token + cost), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool — detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.',
194
194
  'Sub-agent meta events: a sub-agent\'s own turn.retry/turn.error/tool.failed/tool.unresolved events are merged into this same timeline, tagged with `detail.subAgent` — a `"<parent> › <sub-agent>"` breadcrumb that composes when nested (e.g. `"UI Builder › Planner › Grounding"`) — and interleaved by their original timestamps within the subagent.started→completed/failed bracket. These are the per-attempt/per-failure signals that do NOT appear among the sub-agent\'s (hoisted) messages: a malformed/empty attempt that gets retried produces no message, and the stale-vs-hallucinated split and streak counts live only on the event. A sub-agent\'s high-volume, message-derivable events (turn.start/turn.end, provider.selected, context.updated) are intentionally NOT merged — read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run\'s span.',
195
195
  "`meta` holds context captured at export time: agentSummary (full agent configs), context (active model, token usage, session cost), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export — reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.",
196
196
  'To debug a failure: find the last turn.error or tool.failed, then read upward for the user message, the turn(s), and the agent/provider/state events that led into it.',