fix(agent): bound structured output generation - #7279
fix(agent): bound structured output generation#7279BillLeoutsakosvl346 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR bounds structured Agent output by default, identifies token-limited structured generations as explicit failures, and preserves their provider diagnostics without exposing successful downstream output.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/executor/execution/block-executor.ts | Detects token-limited structured streams before downstream completion and safely retains scrubbed provider diagnostics on failure. |
| apps/sim/executor/handlers/agent/agent-handler.ts | Applies the structured-output token default and rejects token-limited non-streaming responses. |
| apps/sim/executor/handlers/shared/response-format.ts | Defines the shared default, finish-reason detection, and non-retryable structured-output limit error. |
| apps/sim/providers/stream-pump.ts | Carries terminal provider finish reasons through the stream-drain result. |
| apps/sim/providers/anthropic/utils.ts | Preserves Anthropic stop reasons when completing no-tool streams. |
Sequence Diagram
sequenceDiagram
participant A as Agent handler
participant P as Model provider
participant S as Stream pump
participant E as Block executor
participant W as Workflow state
A->>P: Structured request with explicit/default token limit
P-->>S: Text deltas and terminal finish reason
S-->>E: Final text and finish reason
E->>E: Attach finish reason to provider timing
alt Token-limited structured output
E->>E: Build and redact failure diagnostics
E->>W: Record failed block output
else Complete structured output
E->>E: Parse structured response
E->>W: Record successful block output
end
Reviews (2): Last reviewed commit: "fix(agent): harden structured stream gua..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@BillLeoutsakosvl346 I have started the AI code review. It will take a few minutes to complete. |
Summary
structured_output_token_limiterrorstop_reasoninto existing timing segmentsIncident / root cause
The affected Agent calls had no configured output cap, so Anthropic could continue generating until its provider/model limit. Existing transport deadlines govern connection/body transport rather than intentionally long, continuously progressing generations; there were no Sim retries, restarts, or timeout failures to stop these runs. Malformed structured output then fell through the compatibility fallback as a tiny effective answer.
Validation
bun run test -- executor/handlers/agent/agent-handler.test.ts providers/anthropic/utils.test.ts executor/execution/block-executor.test.ts executor/execution/block-retry.test.ts— 158 passedbun run type-check— passedLive in-app Browser validation was not run because this environment exposed no
iabBrowser target (only a Chrome extension target). The requester explicitly waived that gate before PR creation.Intentionally deferred
This PR adds no universal wall-clock, time-to-first-token, or inter-token idle timeout. Legitimate reasoning and research calls can run for minutes; broader deadline policy should be designed separately.
TEAgent's proposed explicit 1,024-token workflow setting remains a separate workflow configuration change and is not included here.