You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4fd53a6
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: EVENTS.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -583,8 +583,10 @@ value in the terminal event below.
583
583
584
584
### `structured_output_rejected`
585
585
586
-
Emitted once per rejected StructuredOutput attempt, including an unusable result
587
-
file and a model turn that finishes in prose without a final tool call:
586
+
Emitted once per rejected attempt against the corrective budget: a rejected
587
+
StructuredOutput call (including an unusable result file), a model turn that
588
+
finishes in prose without a final tool call, or a step stopped by a rejected
589
+
tool call (such as a headless permission rejection):
588
590
589
591
```json
590
592
{
@@ -622,6 +624,17 @@ asks it to fix the file at the JSON-encoded path. Malformed tool arguments (not
622
624
A prose-only finish emits the fixed diagnostic
623
625
`{ "path": "", "keyword": "missing", "message": "write the final result as JSON to a file in the working directory, then call StructuredOutput with its path" }`
624
626
and receives an ephemeral reminder before the next turn while budget remains.
627
+
A step that stops on a rejected tool call is handled the same way. In headless
628
+
mode this is a permission auto-rejected because there is no user to approve it
629
+
(see `permission_rejected`); through the SDK it can also be a dismissed
630
+
question. It emits the fixed diagnostic
631
+
`{ "path": "", "keyword": "rejected", "message": "a tool call was rejected; write the final result as JSON to a file in the working directory, then call StructuredOutput with its path" }`.
632
+
The reminder names the rejected tools, not their arguments, and asks the model to
633
+
finish with what it already has. If the same step contains a rejected
634
+
StructuredOutput call, that call is the step's attempt: no `rejected` diagnostic
635
+
is added, but the corrective reminder still follows. Both corrective turns force
636
+
the StructuredOutput tool choice. Without `--output-schema`, a rejected tool
637
+
call still ends the run.
625
638
Other tools remain usable until a valid final result; their outputs are not final
626
639
results. Only the `{ path }` tool schema is sent to the provider; local validation
627
640
of the file always uses the canonical schema.
@@ -642,19 +655,21 @@ or:
642
655
```
643
656
644
657
`attempts` counts StructuredOutput calls, including rejected/unparseable ones,
645
-
and prose-only finishes without a final call. Other tool calls do not count.
658
+
prose-only finishes without a final call, and steps stopped by a rejected tool
659
+
call without a StructuredOutput call. Other tool calls do not count.
646
660
Compaction turns do not consume a missing-result attempt. Discarded provider
647
661
streams restore the budget and captured result; their rejection events remain
648
662
as telemetry. A valid call in a parallel step wins regardless of call order if
649
663
that step started with budget remaining. The attempt count includes every call
650
664
in that step and can exceed `maxAttempts`; the N+1 bound applies to corrective
651
665
turns.
652
666
When the budget is spent, the last rejection determines the reason: `missing`
653
-
for a prose-only finish, otherwise `exhausted`. Failure reasons are:
667
+
for a prose-only finish or a rejected tool call, otherwise `exhausted`.
668
+
Failure reasons are:
654
669
655
670
-`exhausted`: invalid or unparseable calls spent the corrective budget.
656
-
-`missing`: prose finishes spent the budget, or the session ended normally
657
-
without an accepted result (including headless permission rejection).
671
+
-`missing`: prose finishes or rejected tool calls spent the budget, or the
672
+
session ended normally without an accepted result.
658
673
-`step_limit`: the agent reached its configured step cap without a result.
659
674
-`aborted`: the invocation was cancelled, including SIGINT/SIGTERM.
660
675
-`error`: a provider or session error, including stream idle timeout or an
@@ -668,4 +683,5 @@ Exit codes are **0** on accepted results, **2** for schema configuration errors,
668
683
**3** for exhausted attempts, missing output and step limits. Provider errors and
669
684
timeouts keep **1**; SIGINT and SIGTERM keep **130** and **143**.
670
685
`StructuredOutputError.data.retries` records the number of corrective
671
-
attempts used (initial attempt excluded), including prose-only corrective turns.
686
+
attempts used (initial attempt excluded), including corrective turns after a
Copy file name to clipboardExpand all lines: packages/cli/src/session/prompt.ts
+30-10Lines changed: 30 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,8 @@ IMPORTANT:
58
58
constSTRUCTURED_OUTPUT_MISSING=
59
59
"write the final result as JSON to a file in the working directory, then call StructuredOutput with its path"
60
60
61
+
constSTRUCTURED_OUTPUT_REJECTED=`a tool call was rejected; ${STRUCTURED_OUTPUT_MISSING}`
62
+
61
63
constSTRUCTURED_OUTPUT_SYSTEM_PROMPT=`IMPORTANT: The user has requested structured output. Write your final result as JSON to a file in the working directory, then call the StructuredOutput tool with that file's path. Do NOT respond with plain text.`
@@ -762,22 +763,78 @@ test("JSON mode without output-result carries the accepted value only in termina
762
763
])
763
764
},25000)
764
765
765
-
test("headless permission rejection reports missing output with no session error",async()=>{
766
+
constREJECTED_REMINDER=
767
+
"<system-reminder>Tool call rejected: read. Using what you already have, write the final result as JSON to a file in the working directory, then call StructuredOutput with its path</system-reminder>"
768
+
769
+
test("headless permission rejection gets a corrective turn that can still succeed",async()=>{
0 commit comments