Commit 7d31dd8
fix(agent): mark server tool calls dynamic so the tool loop continues past them (#15)
* fix(agent): mark server tool calls dynamic so the tool loop continues past them
TurnTranslator emitted chatd's server-side tool calls (web_search, advisor, …)
with providerExecuted: true but without dynamic: true. The AI SDK only
tolerates tool names missing from the client ToolSet on providerExecuted &&
dynamic calls; without the flag each server tool call was marked `invalid`,
which injects a phantom tool-error output and halts the tool loop on that step
(the output/call count check fails). Any turn where a server tool ran alongside
a pending client tool call therefore ended with finishReason "tool-calls"
instead of continuing — the client tool's result was never submitted and the
chat stranded in requires_action.
Observed live on dev.coder.com: a structured_output client tool turn ended
after 1 step whenever chatd fired its advisor/web_search tools. With the flag,
the same turn completes naturally (2 steps, finishReason "stop").
Change-Id: If42835eecc7f6e91153b4dada9b9d36ddc53db61
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
* docs(agent): add structured output guide and runnable example
Distills the structured_output tool pattern (proven in coder-agents-workflows)
for getting schema-typed answers out of a Coder Agent run: the Zod schema
becomes the inputSchema of a client-executed structured_output tool, the model
files its answer by calling it, and the object arrives as the call's typed
input — no JSON-in-prose parsing.
- README "Structured output" section: provider-vs-agent routing, a compact
sketch, and the four robustness rules (no toolChoice force / no hasToolCall
stop, client-side safeParse, one nudge on an idle chat only, settle a turn
that stopped on the call so the chat doesn't strand in requires_action).
- examples/06-structured-output.ts: copyable structuredOutput(schema) helper
implementing the settle + one-nudge ladder, plus archiveQuietly cleanup that
tolerates the post-settle wind-down. Verified live against dev.coder.com.
Change-Id: Ieddce1790812ee15920b13c8a3d89d6f4829fbe7
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
* ci: match the actions/cache pin comment to its exact tag (v5.0.5)
zizmor 1.25.2 fails ref-version-mismatch on every PR since upstream's
moving v5 tag advanced past the pinned commit: 27d5ce7f is tag v5.0.5,
while v5 now points at caa29612. Pin comments must name the exact tag
the hash resolves to.
Change-Id: Ie11f20be5af490177f782009fb876d067e41a41e
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
* fix(agent): mirror dynamic flag on server tool results
Codex review: calls were emitted dynamic:true but their results were not,
so the AI SDK filed the call under dynamicToolCalls and the result in the
static bucket — breaking call/result pairing in steps[*].dynamicToolResults
and UI message streams (streamText propagates the part's own flag).
Change-Id: I11845cc4b9cdaa1947d9d58b2847906c6c78c8ab
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
* docs(agent): note that turn.toolCalls is the final step's calls at the settle site
Codex review round 3 misread the settle as spanning all steps. In ai v6
GenerateTextResult.toolCalls returns finalStep.toolCalls, so the settle
covers exactly the stranded segment; document that where it matters.
Change-Id: I426df9197151aeff5de601970fbc74697c51e38d
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
* fix(agent): harden translate orphan results and structured-output example per max review
Max-effort workflow review findings:
- translate.ts: drop a server tool-result whose call streamed in a previous
segment — emitted call-less it makes ai v6's asContent throw "Tool call
<id> not found" mid-generate (path newly reachable now that mixed
client+server segments continue past the call). Unit-tested.
- example: settle now submits the stranded step's locally-executed results
for ALL client tools (steps.at(-1); the ack for structured_output, real
results for others) and interrupts when a pending call has no local
result or the settle POST fails — the chat is never left wedged for
reuse/cleanup. Replaces the comment-only "single client tool" invariant.
- example: archiveQuietly bounds every attempt (8s race), retries only
wind-down outcomes (409 / attempt timeout), fails fast on 401/403/404.
- example: type the client slice as Pick<CoderChatClient,
"submitToolResults"> instead of a hand-rolled signature copy; use || for
the model env var so a set-but-empty value falls back; set
requestTimeoutMs so a wedged segment fails loudly.
- README: the snippet now fails clearly when the model never called
structured_output instead of throwing an opaque ZodError; rule 4
generalized to settling all client calls with interrupt fallback.
Change-Id: I0bbec405230aa25e265cbc7b8e3d488d5e586dc7
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
* fix(agent): settle submits local tool errors as errors, matching the resume path
Codex review: the settle sent every locally-executed outcome with
is_error: false, but the normal resume path (toolResultOutputToChatd)
marks error-text/error-json/execution-denied outputs as errors. Build the
settle answers from the stranded step's content — tool-result parts as
successes, tool-error parts as is_error: true — so a throwing execute is
recorded as a failure instead of a success (or needlessly interrupting).
Change-Id: I86dca9ae0a7168da70a00d58d7abbf07c1d6e16d
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
---------
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 0ddfedb commit 7d31dd8
7 files changed
Lines changed: 423 additions & 17 deletions
File tree
- .github/workflows
- packages/agent
- examples
- src/model
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
295 | 372 | | |
296 | 373 | | |
297 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
0 commit comments