agentfootprint 7.25.0 → 7.26.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 (150) hide show
  1. package/AGENTS.md +1 -1
  2. package/CLAUDE.md +5 -3
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/dist/adapters/llm/AnthropicProvider.js +10 -0
  5. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  6. package/dist/adapters/llm/BedrockProvider.js +13 -1
  7. package/dist/adapters/llm/BedrockProvider.js.map +1 -1
  8. package/dist/adapters/llm/BrowserAnthropicProvider.js +6 -0
  9. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  10. package/dist/adapters/llm/BrowserOpenAIProvider.js +18 -0
  11. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  12. package/dist/adapters/llm/MockProvider.js +9 -0
  13. package/dist/adapters/llm/MockProvider.js.map +1 -1
  14. package/dist/adapters/llm/OpenAIProvider.js +21 -0
  15. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  16. package/dist/conventions.js +12 -0
  17. package/dist/conventions.js.map +1 -1
  18. package/dist/core/Agent.js +56 -2
  19. package/dist/core/Agent.js.map +1 -1
  20. package/dist/core/agent/AgentBuilder.js +98 -1
  21. package/dist/core/agent/AgentBuilder.js.map +1 -1
  22. package/dist/core/agent/buildAgentChart.js +12 -2
  23. package/dist/core/agent/buildAgentChart.js.map +1 -1
  24. package/dist/core/agent/buildDynamicAgentChart.js +12 -3
  25. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  26. package/dist/core/agent/outputEnforcement.js +192 -0
  27. package/dist/core/agent/outputEnforcement.js.map +1 -0
  28. package/dist/core/agent/stages/callLLM.js +31 -1
  29. package/dist/core/agent/stages/callLLM.js.map +1 -1
  30. package/dist/core/agent/stages/outputRetry.js +102 -0
  31. package/dist/core/agent/stages/outputRetry.js.map +1 -0
  32. package/dist/core/agent/stages/route.js +111 -6
  33. package/dist/core/agent/stages/route.js.map +1 -1
  34. package/dist/core/outputSchema.js.map +1 -1
  35. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +10 -0
  36. package/dist/esm/adapters/llm/AnthropicProvider.js +10 -0
  37. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  38. package/dist/esm/adapters/llm/BedrockProvider.d.ts +9 -0
  39. package/dist/esm/adapters/llm/BedrockProvider.js +13 -1
  40. package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
  41. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +1 -0
  42. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +6 -0
  43. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  44. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +4 -0
  45. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +18 -0
  46. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  47. package/dist/esm/adapters/llm/MockProvider.d.ts +9 -0
  48. package/dist/esm/adapters/llm/MockProvider.js +9 -0
  49. package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
  50. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +12 -0
  51. package/dist/esm/adapters/llm/OpenAIProvider.js +21 -0
  52. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  53. package/dist/esm/adapters/types.d.ts +46 -0
  54. package/dist/esm/conventions.d.ts +4 -0
  55. package/dist/esm/conventions.js +12 -0
  56. package/dist/esm/conventions.js.map +1 -1
  57. package/dist/esm/core/Agent.d.ts +26 -1
  58. package/dist/esm/core/Agent.js +56 -2
  59. package/dist/esm/core/Agent.js.map +1 -1
  60. package/dist/esm/core/agent/AgentBuilder.d.ts +15 -0
  61. package/dist/esm/core/agent/AgentBuilder.js +98 -1
  62. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  63. package/dist/esm/core/agent/buildAgentChart.d.ts +13 -1
  64. package/dist/esm/core/agent/buildAgentChart.js +12 -2
  65. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  66. package/dist/esm/core/agent/buildDynamicAgentChart.js +12 -3
  67. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  68. package/dist/esm/core/agent/outputEnforcement.d.ts +173 -0
  69. package/dist/esm/core/agent/outputEnforcement.js +180 -0
  70. package/dist/esm/core/agent/outputEnforcement.js.map +1 -0
  71. package/dist/esm/core/agent/stages/callLLM.d.ts +15 -0
  72. package/dist/esm/core/agent/stages/callLLM.js +31 -1
  73. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  74. package/dist/esm/core/agent/stages/outputRetry.d.ts +34 -0
  75. package/dist/esm/core/agent/stages/outputRetry.js +98 -0
  76. package/dist/esm/core/agent/stages/outputRetry.js.map +1 -0
  77. package/dist/esm/core/agent/stages/route.d.ts +18 -2
  78. package/dist/esm/core/agent/stages/route.js +111 -6
  79. package/dist/esm/core/agent/stages/route.js.map +1 -1
  80. package/dist/esm/core/agent/types.d.ts +18 -0
  81. package/dist/esm/core/outputSchema.d.ts +51 -0
  82. package/dist/esm/core/outputSchema.js.map +1 -1
  83. package/dist/esm/events/payloads.d.ts +47 -1
  84. package/dist/esm/events/registry.d.ts +3 -1
  85. package/dist/esm/events/registry.js +2 -0
  86. package/dist/esm/events/registry.js.map +1 -1
  87. package/dist/esm/index.d.ts +2 -1
  88. package/dist/esm/index.js +5 -0
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/resilience/withCircuitBreaker.js +5 -0
  91. package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
  92. package/dist/esm/resilience/withFallback.js +5 -0
  93. package/dist/esm/resilience/withFallback.js.map +1 -1
  94. package/dist/esm/resilience/withRetry.js +6 -0
  95. package/dist/esm/resilience/withRetry.js.map +1 -1
  96. package/dist/events/registry.js +2 -0
  97. package/dist/events/registry.js.map +1 -1
  98. package/dist/index.js +9 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/resilience/withCircuitBreaker.js +5 -0
  101. package/dist/resilience/withCircuitBreaker.js.map +1 -1
  102. package/dist/resilience/withFallback.js +5 -0
  103. package/dist/resilience/withFallback.js.map +1 -1
  104. package/dist/resilience/withRetry.js +6 -0
  105. package/dist/resilience/withRetry.js.map +1 -1
  106. package/dist/types/adapters/llm/AnthropicProvider.d.ts +10 -0
  107. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  108. package/dist/types/adapters/llm/BedrockProvider.d.ts +9 -0
  109. package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
  110. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +1 -0
  111. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  112. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +4 -0
  113. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  114. package/dist/types/adapters/llm/MockProvider.d.ts +9 -0
  115. package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
  116. package/dist/types/adapters/llm/OpenAIProvider.d.ts +12 -0
  117. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  118. package/dist/types/adapters/types.d.ts +46 -0
  119. package/dist/types/adapters/types.d.ts.map +1 -1
  120. package/dist/types/conventions.d.ts +4 -0
  121. package/dist/types/conventions.d.ts.map +1 -1
  122. package/dist/types/core/Agent.d.ts +26 -1
  123. package/dist/types/core/Agent.d.ts.map +1 -1
  124. package/dist/types/core/agent/AgentBuilder.d.ts +15 -0
  125. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  126. package/dist/types/core/agent/buildAgentChart.d.ts +13 -1
  127. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  128. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  129. package/dist/types/core/agent/outputEnforcement.d.ts +174 -0
  130. package/dist/types/core/agent/outputEnforcement.d.ts.map +1 -0
  131. package/dist/types/core/agent/stages/callLLM.d.ts +15 -0
  132. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  133. package/dist/types/core/agent/stages/outputRetry.d.ts +35 -0
  134. package/dist/types/core/agent/stages/outputRetry.d.ts.map +1 -0
  135. package/dist/types/core/agent/stages/route.d.ts +18 -2
  136. package/dist/types/core/agent/stages/route.d.ts.map +1 -1
  137. package/dist/types/core/agent/types.d.ts +18 -0
  138. package/dist/types/core/agent/types.d.ts.map +1 -1
  139. package/dist/types/core/outputSchema.d.ts +51 -0
  140. package/dist/types/core/outputSchema.d.ts.map +1 -1
  141. package/dist/types/events/payloads.d.ts +47 -1
  142. package/dist/types/events/payloads.d.ts.map +1 -1
  143. package/dist/types/events/registry.d.ts +3 -1
  144. package/dist/types/events/registry.d.ts.map +1 -1
  145. package/dist/types/index.d.ts +2 -1
  146. package/dist/types/index.d.ts.map +1 -1
  147. package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
  148. package/dist/types/resilience/withFallback.d.ts.map +1 -1
  149. package/dist/types/resilience/withRetry.d.ts.map +1 -1
  150. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AgentBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/AgentBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4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A0B,GAAG,IAAI;IAQ/C,WAAW,CAAC,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAmBhD;;;;;;;OAOG;IACH,OAAO,CAAC,wBAAwB;IAyDhC,KAAK,IAAI,KAAK;CAuFf"}
@@ -44,6 +44,7 @@
44
44
  import type { FlowChart, StructureRecorder } from 'footprintjs';
45
45
  import type { CachePolicy } from '../../cache/types.js';
46
46
  import type { MemoryDefinition } from '../../memory/define.types.js';
47
+ import type { RouteBranch } from './stages/route.js';
47
48
  /**
48
49
  * Stage handlers + slot subflows the chart composer needs. Mostly
49
50
  * passed through verbatim from Agent.buildChart() — the chart shape
@@ -65,8 +66,19 @@ export interface AgentChartDeps {
65
66
  readonly maxIterations: number;
66
67
  readonly seed: (scope: never) => void | Promise<void>;
67
68
  readonly callLLM: (scope: never) => Promise<void>;
68
- readonly routeDecider: (scope: never) => 'tool-calls' | 'final' | Promise<'tool-calls' | 'final'>;
69
+ readonly routeDecider: (scope: never) => RouteBranch | Promise<RouteBranch>;
69
70
  readonly toolCallsHandler: import('footprintjs').PausableHandler<never>;
71
+ /**
72
+ * The schema re-ask branch (7.26). Present ONLY when the agent was built
73
+ * with `.outputSchema(parser, { retries })` — and when present it is a
74
+ * THIRD branch of the Route decider carrying the same `{ loopTo }` the
75
+ * tool branch does, because a re-ask is one more ordinary turn.
76
+ *
77
+ * Conditional mount, for the reason every conditional mount here exists:
78
+ * an agent that did not opt in gets no branch, no stage, no scope key and
79
+ * no event — its chart and its commit log are the ones it always had.
80
+ */
81
+ readonly outputRetryStage?: (scope: never) => void;
70
82
  readonly injectionEngineSubflow: FlowChart;
71
83
  /** Relevance entry router (`entryByRelevance`) — a once-per-turn function stage
72
84
  * mounted before the InjectionEngine (off the ReAct loop). Present only when the
@@ -1 +1 @@
1
- {"version":3,"file":"buildAgentChart.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC;IAC/C,QAAQ,CAAC,mBAAmB,EAAE,SAAS,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,CAAC;IAMrC,QAAQ,CAAC,uBAAuB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEzD;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAG3C;;;;0CAIsC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAqa/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildDynamicAgentChart.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildDynamicAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAezD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4D3D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAkbtE"}
1
+ {"version":3,"file":"buildDynamicAgentChart.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildDynamicAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAezD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4D3D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAmctE"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * outputEnforcement — what the `outputSchema` contract does INSIDE the run.
3
+ *
4
+ * Pattern: an authored envelope around an untrusted payload (the same shape
5
+ * `window/summarize` uses), plus one writer for one committed key
6
+ * (the same rule `middleware/ledger` follows).
7
+ * Role: core/ layer. Until 7.26 the schema was checked once, after the run
8
+ * was over, by `runTyped()`. That is a fine place to JUDGE an answer
9
+ * and a useless place to FIX one: the loop has stopped, the model is
10
+ * gone, and all the caller can do is throw. This module holds the
11
+ * pieces that let the loop ask again — the corrective message, the
12
+ * ledger row, and the synthetic tool the `'tool-forced'` strategy
13
+ * puts on the wire.
14
+ * Emits: N/A — the Route decider and the retry stage emit; this file only
15
+ * builds values and commits rows.
16
+ *
17
+ * ## Why the failed answer is put into the conversation
18
+ *
19
+ * Nothing writes the answering turn back into `scope.history` — the loop
20
+ * appends an assistant turn only when it carries tool calls. So a corrective
21
+ * message sent on its own would arrive at a model that cannot see what it
22
+ * said, and "your answer failed the schema" would be teaching into the void.
23
+ * The retry stage appends BOTH: the answer that failed, then the correction.
24
+ * That is also what makes the retry legible afterwards — the conversation
25
+ * says what was answered, what was wrong with it, and what came back.
26
+ *
27
+ * ## Why the frame comes first and nothing follows the error
28
+ *
29
+ * The validator's message is DATA. A schema authored elsewhere (or a parser
30
+ * that formats an error out of model output) can put anything in it,
31
+ * including text shaped like an instruction. So the library's own words come
32
+ * FIRST, say what the following text is, and nothing authored is appended
33
+ * after it — there is no trailing sentence for injected text to pre-empt.
34
+ * Identical reasoning, identical shape, to the compaction frame.
35
+ */
36
+ import type { LLMMessage, LLMResponse, LLMToolSchema } from '../../adapters/types.js';
37
+ import { type OutputSchemaParser } from '../outputSchema.js';
38
+ /**
39
+ * One row per final-answer attempt an enforcing agent made, in order.
40
+ *
41
+ * Rows exist ONLY on an agent that opted into `retries`. Without the option
42
+ * the schema is judged after the run as it always was, nothing in the loop
43
+ * looks at it, and this key is never written.
44
+ */
45
+ export interface OutputAttempt {
46
+ /** 1-based attempt number within this run. */
47
+ readonly attempt: number;
48
+ /** The ReAct iteration that produced the answer. */
49
+ readonly iteration: number;
50
+ /**
51
+ * What became of this attempt:
52
+ * • `'passed'` — the answer satisfied the schema; the run returns it.
53
+ * • `'retried'` — it failed and a corrective turn was sent.
54
+ * • `'exhausted'` — it failed with no retries left; this answer stands,
55
+ * and `runTyped()` throws on it exactly as it always did.
56
+ */
57
+ readonly outcome: 'passed' | 'retried' | 'exhausted';
58
+ /** Which half of validation failed. Absent on a passing row. */
59
+ readonly stage?: 'json-parse' | 'schema-validate';
60
+ /** The validator's own message, verbatim. Absent on a passing row. */
61
+ readonly error?: string;
62
+ /** Failing field path when the parser exposes one (Zod-style issues). */
63
+ readonly path?: string;
64
+ /** `fnv1a` of the corrective message this row's failure produced. Present
65
+ * only on a `'retried'` row — it is the join back to the message in the
66
+ * conversation and to the `output_schema_retry` event's payload. */
67
+ readonly correctiveMessageHash?: string;
68
+ }
69
+ /** The scope surface this file needs. Structurally a `TypedScope<AgentState>`. */
70
+ export interface OutputLedgerScope {
71
+ outputAttempts?: readonly OutputAttempt[];
72
+ }
73
+ /**
74
+ * Append one row to the run's output-attempt ledger.
75
+ *
76
+ * The ONLY writer of `outputAttempts`, so the decider (which files the
77
+ * terminal outcomes) and the retry stage (which files its own, carrying the
78
+ * message it wrote) cannot record the same fact two different ways.
79
+ */
80
+ export declare function recordOutputAttempt(scope: OutputLedgerScope, row: OutputAttempt): void;
81
+ /** A validation failure, flattened to the plain strings a row and an event
82
+ * payload both need. */
83
+ export interface OutputFailure {
84
+ readonly stage: 'json-parse' | 'schema-validate';
85
+ /** The validator's message. Prefer the underlying cause's message (Zod and
86
+ * friends attach the real error there); fall back to the wrapper's. */
87
+ readonly error: string;
88
+ readonly path?: string;
89
+ }
90
+ /**
91
+ * Flatten whatever the parser threw into {@link OutputFailure}.
92
+ *
93
+ * Mirrors the extraction `callLLM`'s reliability validator already does, so
94
+ * the two paths report a failure the same way.
95
+ */
96
+ export declare function describeFailure(err: unknown): OutputFailure;
97
+ /** Opening of the authored frame. Stable — tests and readers match on it. */
98
+ export declare const SCHEMA_CHECK_FRAME_PREFIX = "[schema check";
99
+ /**
100
+ * The two messages a failed attempt adds to the conversation: the answer
101
+ * that failed, and the correction.
102
+ *
103
+ * The frame is authored and comes first; `failure.error` is appended to it
104
+ * verbatim and nothing is written after. The library never edits the
105
+ * validator's words, and it never lets them speak in the library's voice
106
+ * either.
107
+ */
108
+ export declare function buildCorrectiveTurn(failedAnswer: string, failure: OutputFailure, facts: {
109
+ readonly attempt: number;
110
+ readonly totalAttempts: number;
111
+ }): readonly [LLMMessage, LLMMessage];
112
+ /** True when this message is a correction a previous attempt wrote. */
113
+ export declare function isSchemaCheckMessage(msg: LLMMessage | undefined): boolean;
114
+ /** The join between a corrective message, its ledger row and its event. */
115
+ export declare function correctiveMessageHash(content: string): string;
116
+ /**
117
+ * Name of the tool the schema is presented as.
118
+ *
119
+ * It is the STRATEGY's mechanism, never the agent's surface: it is built at
120
+ * request-assembly time, so it cannot reach `.tools()`, the tools slot, the
121
+ * `tools.offered` event, an MCP server's served list, or the dispatcher that
122
+ * runs tools and files middleware rows. The only places it exists are the
123
+ * wire and the `llm_start` event — and it belongs in that event, whose whole
124
+ * claim is that it reports what the model actually saw.
125
+ */
126
+ export declare const SCHEMA_TOOL_NAME = "respond_with_schema";
127
+ /** Build the synthetic tool from the resolved JSON Schema. */
128
+ export declare function buildSchemaTool(jsonSchema: Readonly<Record<string, unknown>>, description?: string): LLMToolSchema;
129
+ /**
130
+ * Pull the answer out of a forced tool call.
131
+ *
132
+ * Returns the JSON text the rest of the run treats as the final answer, or
133
+ * `undefined` when this response did not answer through the synthetic tool
134
+ * (which is what a still-working turn looks like, and is left alone).
135
+ */
136
+ export declare function readSchemaToolAnswer(response: LLMResponse): string | undefined;
137
+ /**
138
+ * Resolve the JSON Schema for the synthetic tool.
139
+ *
140
+ * Duck-typed, in the same spirit as the parser itself: a schema object that
141
+ * can render itself as JSON Schema (ArkType's `toJsonSchema()`) is asked to;
142
+ * anything else must be handed the shape explicitly. Returns `undefined`
143
+ * when neither is available — the builder turns that into a refusal naming
144
+ * exactly what to pass.
145
+ */
146
+ export declare function resolveJsonSchema(parser: OutputSchemaParser<unknown>, explicit?: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>> | undefined;
147
+ /**
148
+ * What the builder resolved once, and the chart carries for the whole run.
149
+ *
150
+ * `parser` is here (not in scope) for the ordinary reason: scope values must
151
+ * survive `structuredClone`, and a parser is functions.
152
+ *
153
+ * @internal
154
+ */
155
+ export interface ResolvedOutputEnforcement {
156
+ readonly parser: OutputSchemaParser<unknown>;
157
+ /** Corrective re-asks allowed. `> 0` whenever this object exists — an
158
+ * agent that did not opt in has no enforcement mounted at all. */
159
+ readonly retries: number;
160
+ /** The synthetic tool, pre-built. Present only under `'tool-forced'`. */
161
+ readonly schemaTool?: LLMToolSchema;
162
+ }
163
+ /**
164
+ * Validate an answer against the contract, as the loop sees it. Returns
165
+ * `undefined` when the answer passed.
166
+ *
167
+ * Deliberately calls the SAME `applyOutputSchema` the caller-facing
168
+ * `runTyped()` calls — one validator, two call sites, so the loop can never
169
+ * accept an answer the boundary would go on to reject. A parser that throws
170
+ * something other than `OutputSchemaError` still failed the answer, and is
171
+ * reported as a failure rather than allowed to escape and kill the run.
172
+ */
173
+ export declare function judgeAnswer(answer: string, parser: OutputSchemaParser<unknown>): OutputFailure | undefined;
174
+ //# sourceMappingURL=outputEnforcement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputEnforcement.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/outputEnforcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WA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AAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAClC,aAAa,GAAG,SAAS,CAO3B"}
@@ -61,6 +61,21 @@ export interface CallLLMStageDeps {
61
61
  * NOT set, validation only happens at `agent.parseOutput()` boundary
62
62
  * (existing v2.4 behavior). */
63
63
  readonly outputSchemaParser?: OutputSchemaParser<unknown>;
64
+ /**
65
+ * The synthetic tool the `'tool-forced'` output strategy puts on the wire
66
+ * (7.26). Present ONLY under that strategy; under `'instruct'` — the
67
+ * default — this is undefined and not one line below it runs.
68
+ *
69
+ * When present, the tool is appended to the request's tool list and the
70
+ * request carries `toolChoice`, so the provider constrains generation to
71
+ * this shape instead of the model being asked in prose to comply. It is
72
+ * added HERE, at request assembly, and nowhere else: that is what keeps it
73
+ * off `.tools()`, out of the tools slot and its `tools.offered` event, off
74
+ * any MCP server's served list, and away from the dispatcher that runs
75
+ * tools and files middleware rows. It is the strategy's mechanism, not the
76
+ * agent's surface.
77
+ */
78
+ readonly schemaTool?: LLMToolSchema;
64
79
  /** v2.14+ — request-side thinking budget. When set, every LLMRequest
65
80
  * carries `thinking: { budget }` so the provider activates extended
66
81
  * thinking. Undefined = no activation (default). */
@@ -1 +1 @@
1
- {"version":3,"file":"callLLM.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/callLLM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAEV,WAAW,EAGX,aAAa,EACb,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAMnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoB9C,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,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,GACrB,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAyRlD"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * outputRetry — the branch that asks again when the answer failed the schema.
3
+ *
4
+ * Mounted as a THIRD branch of the Route decider, and only on an agent that
5
+ * opted into `.outputSchema(parser, { retries })`. It carries `{ loopTo }`
6
+ * to the same target the `tool-calls` branch loops to, which is the whole
7
+ * mechanism: a retry is not a special mode, it is one more ordinary turn of
8
+ * the ReAct loop. The injection engine re-evaluates, the slots recompose,
9
+ * the cache decides, the model is called — so the attempt gets its own
10
+ * `iteration_start` / `llm_start` / `llm_end` bracket and its own `cost.tick`
11
+ * against `costBudget`.
12
+ *
13
+ * That is the difference from the in-stage schema retry the reliability gate
14
+ * has done since v2.13. There, N attempts happen inside ONE `call-llm` stage:
15
+ * one bracket for all of them, and one cost tick carrying only the last
16
+ * attempt's usage — attempts that were genuinely billed and are invisible in
17
+ * the recording. Here every attempt is a turn, and the recording says so.
18
+ *
19
+ * The two layers compose rather than collide. With `.reliability()` also
20
+ * configured, its in-stage rules run FIRST and decide what to do with a
21
+ * response before it is committed; `retries` governs answers that WERE
22
+ * committed and turned out invalid.
23
+ *
24
+ * Pure function apart from its enforcement config — no closure over Agent
25
+ * class state.
26
+ */
27
+ import type { TypedScope } from 'footprintjs';
28
+ import { type ResolvedOutputEnforcement } from '../outputEnforcement.js';
29
+ import type { AgentState } from '../types.js';
30
+ /**
31
+ * Build the retry stage. `enforcement.retries` is the cap the decider already
32
+ * checked before routing here — this stage does the work of asking again.
33
+ */
34
+ export declare function buildOutputRetryStage(enforcement: ResolvedOutputEnforcement): (scope: TypedScope<AgentState>) => void;
35
+ //# sourceMappingURL=outputRetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputRetry.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/outputRetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAIL,KAAK,yBAAyB,EAC/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,yBAAyB,GACrC,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAsEzC"}
@@ -15,7 +15,8 @@
15
15
  import type { TypedScope } from 'footprintjs';
16
16
  import type { AgentState } from '../types.js';
17
17
  import type { MessageMiddleware } from '../middleware/types.js';
18
- export type RouteBranch = 'tool-calls' | 'final';
18
+ import { type ResolvedOutputEnforcement } from '../outputEnforcement.js';
19
+ export type RouteBranch = 'tool-calls' | 'final' | 'output-retry';
19
20
  export declare const routeDeciderStage: (scope: TypedScope<AgentState>) => RouteBranch;
20
21
  /**
21
22
  * Build the Route decider, optionally carrying the `'output'` half of the
@@ -43,6 +44,21 @@ export declare const routeDeciderStage: (scope: TypedScope<AgentState>) => Route
43
44
  * would be running it over something that is not the output.
44
45
  *
45
46
  * Empty chain → the exact synchronous decider this file has always exported.
47
+ *
48
+ * ## Why the schema is judged HERE too
49
+ *
50
+ * The same property that made this the output seam makes it the enforcement
51
+ * seam. `outputSchema` used to be judged only at the caller's boundary, after
52
+ * the run — a fine place to reject an answer and a useless place to fix one,
53
+ * because the loop has already stopped. Judged here, one stage before the
54
+ * Final branch, the run still HAS a loop: a failed answer can route to
55
+ * `'output-retry'`, which loops back for one more real turn.
56
+ *
57
+ * The judging runs AFTER the message chain, over the content the chain
58
+ * produced, because that is the string the caller will receive — validating
59
+ * the pre-chain value would judge an answer nobody gets. A DENIED answer is
60
+ * never judged or retried: it was withheld on purpose, and re-asking for it
61
+ * would be the library working around a rule the app wrote.
46
62
  */
47
- export declare function buildRouteDeciderStage(messageMiddleware?: readonly MessageMiddleware[]): (scope: TypedScope<AgentState>) => RouteBranch | Promise<RouteBranch>;
63
+ export declare function buildRouteDeciderStage(messageMiddleware?: readonly MessageMiddleware[], enforcement?: ResolvedOutputEnforcement): (scope: TypedScope<AgentState>) => RouteBranch | Promise<RouteBranch>;
48
64
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAW,WAAW,UAAU,CAAC,KAAG,WAmBjE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CACpC,iBAAiB,CAAC,EAAE,SAAS,iBAAiB,EAAE,GAC/C,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CA6BvE"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,cAAc,CAAC;AAqClE,eAAO,MAAM,iBAAiB,UAAW,WAAW,UAAU,CAAC,KAAG,WAIjE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,sBAAsB,CACpC,iBAAiB,CAAC,EAAE,SAAS,iBAAiB,EAAE,EAChD,WAAW,CAAC,EAAE,yBAAyB,GACtC,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BvE"}
@@ -21,6 +21,7 @@ import type { ReliabilityScope } from '../../reliability/types.js';
21
21
  import type { WindowRecord } from './window/types.js';
22
22
  import type { MessagesDelivery } from './delivery/types.js';
23
23
  import type { MiddlewareDecision } from './middleware/types.js';
24
+ import type { OutputAttempt } from './outputEnforcement.js';
24
25
  /**
25
26
  * Dials for the deferred observer queue (RFC-001) — only meaningful with
26
27
  * `observerDelivery: 'deferred'` (passing them without it throws at
@@ -360,6 +361,23 @@ export interface AgentState {
360
361
  * taken later can find the moment the text changed and who changed it.
361
362
  * Written only by an agent that configured a chain; absent otherwise. */
362
363
  middlewareDecisions?: readonly MiddlewareDecision[];
364
+ /** One row per final-answer attempt, in order: what was answered, whether
365
+ * it satisfied the schema, and — when it did not — the validator's own
366
+ * words and the correction that went back. Read it from
367
+ * `snapshot.sharedState` to see why a run took three turns to answer.
368
+ * Written only by an agent that opted into `retries`; absent otherwise. */
369
+ outputAttempts?: readonly OutputAttempt[];
370
+ /** In-flight hand-off from the Route decider (which judges the answer and
371
+ * picks the branch) to the retry stage (which writes the correction). Not
372
+ * a record — the record is `outputAttempts`. Always freshly written by the
373
+ * decider immediately before the retry branch runs, so it is never read
374
+ * stale. */
375
+ outputSchemaFailure?: {
376
+ readonly attempt: number;
377
+ readonly stage: 'json-parse' | 'schema-validate';
378
+ readonly error: string;
379
+ readonly path?: string;
380
+ };
363
381
  /** Set by the seed / prepare-final stage when a `messageMiddleware` returned
364
382
  * `deny`. Read at the API boundary, where it becomes a `MessageDeniedError`.
365
383
  * Never carries the refused content — see MessageDeniedError. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE;;;;;;;;GAQG;AACH,MAAM,MAA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IAC9D,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC"}
@@ -69,6 +69,21 @@ export interface OutputSchemaParser<T> {
69
69
  */
70
70
  readonly description?: string;
71
71
  }
72
+ /**
73
+ * How the schema reaches the model.
74
+ *
75
+ * • `'instruct'` (default) — the shape is described in the system prompt
76
+ * and the model is asked for JSON. Works on every provider, because it
77
+ * is only words.
78
+ * • `'tool-forced'` — the shape is presented as a synthetic tool and the
79
+ * provider's tool choice is FORCED to it, so generation is constrained
80
+ * at the source instead of requested in prose. Requires a provider that
81
+ * declares `carriesForcedToolChoice`; a provider that does not is
82
+ * refused BY NAME at run start rather than quietly downgraded, because
83
+ * a strategy that silently falls back to the other one is config that
84
+ * lies.
85
+ */
86
+ export type OutputSchemaStrategy = 'instruct' | 'tool-forced';
72
87
  /**
73
88
  * Optional configuration for `outputSchema`.
74
89
  */
@@ -88,6 +103,42 @@ export interface OutputSchemaOptions {
88
103
  * domain-specific framing.
89
104
  */
90
105
  readonly instruction?: string;
106
+ /**
107
+ * How many corrective re-asks the run may spend when the final answer
108
+ * fails the schema. Default `0` — the historical behaviour, where the
109
+ * first answer is the only answer and `runTyped()` throws on a bad one.
110
+ *
111
+ * Each retry is a REAL turn: the failed answer and an authored corrective
112
+ * message join the conversation, the ReAct loop re-enters, and the next
113
+ * attempt gets its own `llm_start`/`llm_end` bracket and its own
114
+ * `cost.tick` against `costBudget`. A retry therefore consumes one
115
+ * iteration of the agent's budget, the same way a tool call does.
116
+ *
117
+ * When the cap is spent the last answer stands and `runTyped()` throws
118
+ * `OutputSchemaError` exactly as it always has — `.outputFallback()`
119
+ * composes on top, unchanged.
120
+ */
121
+ readonly retries?: number;
122
+ /**
123
+ * How the schema reaches the model. Default `'instruct'`.
124
+ * See {@link OutputSchemaStrategy}.
125
+ */
126
+ readonly strategy?: OutputSchemaStrategy;
127
+ /**
128
+ * The JSON Schema for the synthetic tool, required by
129
+ * `strategy: 'tool-forced'` unless the parser can produce one itself
130
+ * (a `toJsonSchema()` method, which ArkType has). The library will not
131
+ * infer a shape from a `parse()` function — guessing what your schema
132
+ * means is not a thing it gets to do.
133
+ *
134
+ * This value and the parser CAN disagree. Nothing here prevents that,
135
+ * and nothing needs to: the forced shape satisfies the wire, the parser
136
+ * still judges the answer, and a disagreement surfaces as an ordinary
137
+ * validation failure that the retry loop corrects using the validator's
138
+ * own words. The schema constrains generation; the parser remains the
139
+ * judge.
140
+ */
141
+ readonly jsonSchema?: Readonly<Record<string, unknown>>;
91
142
  }
92
143
  /**
93
144
  * Thrown by `agent.parseOutput(...)` / `agent.runTyped(...)` when the
@@ -1 +1 @@
1
- {"version":3,"file":"outputSchema.d.ts","sourceRoot":"","sources":["../../../src/core/outputSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC;IACjD,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,YAAY,GA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C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC;IACjD,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAQxF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,MAAM,CAOnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAmBlF"}
@@ -106,7 +106,13 @@ export interface AgentIterationEndPayload {
106
106
  export interface AgentRouteDecidedPayload {
107
107
  readonly turnIndex: number;
108
108
  readonly iterIndex: number;
109
- readonly chosen: 'tool-calls' | 'final';
109
+ /**
110
+ * The branch the turn took. `'output-retry'` (7.26) appears only on an
111
+ * agent built with `.outputSchema(parser, { retries })`, and only on a
112
+ * turn whose answer failed the schema with retries left — the loop is
113
+ * about to ask again rather than finish.
114
+ */
115
+ readonly chosen: 'tool-calls' | 'final' | 'output-retry';
110
116
  readonly rationale?: string;
111
117
  }
112
118
  export interface AgentHandoffPayload {
@@ -621,6 +627,46 @@ export interface EvalThresholdCrossedPayload {
621
627
  * Fires BEFORE PostDecide rules evaluate, so observability sees the
622
628
  * failure even if a buggy rule routes to fail-fast or swallows it.
623
629
  */
630
+ /**
631
+ * Emitted (7.26) once per failed final answer that the run is about to
632
+ * ASK AGAIN about, on an agent built with
633
+ * `.outputSchema(parser, { retries })`.
634
+ *
635
+ * Its sibling `agent.output_schema_validation_failed` reports a failure the
636
+ * reliability gate is handling INSIDE one `call-llm` stage. This one reports
637
+ * a failure the LOOP is handling: the corrective message named here joins the
638
+ * conversation, the ReAct loop re-enters, and the next attempt arrives with
639
+ * its own `stream.llm_start` / `stream.llm_end` bracket and its own
640
+ * `cost.tick`. Subscribe to it to see how often a model needs a second ask —
641
+ * a leading indicator of drift, and of a schema that is harder to hit than
642
+ * its author thinks.
643
+ *
644
+ * Fires from the retry branch, after the corrective turn is committed, so a
645
+ * consumer that reads `snapshot.sharedState.outputAttempts` finds the
646
+ * matching row (joined by `correctiveMessageHash`) already there.
647
+ */
648
+ export interface AgentOutputSchemaRetryPayload {
649
+ /** 1-based attempt that just failed. `1` is the first answer. */
650
+ readonly attempt: number;
651
+ /** Corrective asks left AFTER this one. `0` means this is the last. */
652
+ readonly retriesRemaining: number;
653
+ /** The ReAct iteration the failed answer came from. A retry consumes an
654
+ * iteration, so the next attempt reports `iteration + 1`. */
655
+ readonly iteration: number;
656
+ /** Which half of validation failed — `'json-parse'` (the model emitted
657
+ * prose) vs `'schema-validate'` (JSON, wrong shape). They trend
658
+ * differently under model drift. */
659
+ readonly stage: 'json-parse' | 'schema-validate';
660
+ /** The validator's own message, verbatim. DATA, not narrative: it is
661
+ * quoted into the corrective message after an authored frame, and it is
662
+ * quoted here the same way. */
663
+ readonly error: string;
664
+ /** Failing field path when the parser exposes one (Zod-style issues). */
665
+ readonly path?: string;
666
+ /** `fnv1a` of the corrective message that went back to the model — the
667
+ * join to the message in `history` and to the `outputAttempts` row. */
668
+ readonly correctiveMessageHash: string;
669
+ }
624
670
  export interface AgentOutputSchemaValidationFailedPayload {
625
671
  /** Validation error message (from Zod / parser). */
626
672
  readonly message: string;