Repository navigation
Conversation
A reply that stops at its output limit no longer ends the turn. fx tells the model in the same turn what was cut and lets it continue, at most twice in a row; the third cut in a row ends the turn with a clear notice. Tool calls that finished before the cut run, and a call the limit cut off never runs. A reply cut while writing text keeps its text and the model picks up where it stopped. A reply cut before any text asks the model to take a smaller step.
When the last cut reply of a turn streamed no text, the end of the turn showed the earlier parts of the answer again. It now shows only that reply's text and keeps the whole answer for the saved turn. Also log when tool activity ends an answer fx was joining, and drop an unused total of output-limit stops.
fx holds the first letters of a reply until it can check the reply's language, and only a finished reply gets that check. A part cut off before the check never showed, so the screen and the JSON output lost it while the saved answer kept it. A cut reply now shows that text before fx asks the model to go on.
main raised the wasm budgets for provider compaction. With the cut reply recovery on top, fx-core.wasm is 2,508,068 bytes and fx-term.wasm is 4,310,326 bytes after wasm-opt, so both budgets now sit just above those.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
output_limitto its parent instead ofagent_turn_failed, and/tracelists each cut as anoutput_limitproblem.write_fileandedit_filedescriptions ask the model to keep each call small.fx-core.wasmfrom 2,475,000 to 2,490,000 bytes andfx-term.wasmfrom 4,276,000 to 4,292,000. Both files grew about 15 to 17 KB overmain.ResendDiffersandNoResendOfResendgive way toAtMostTwoNotesInARowandNeverLowTwiceInARow, each with a planted bug that must break it.tests/tla/agent_runtime/OutputLimit.tla, describes the recovery, with planted bugs that its rules must catch. Its driver,tests/tla/drivers/agent_runtime/output_limit.ts, runs the built fx along it, and a new CI step runs that driver.Before and after
Before:
flowchart TD R[Reply stops at the output limit] --> T{Tool calls in it?} T -- yes --> F[Turn fails, calls dropped: send your message again] T -- no --> E{Any text?} E -- yes --> C[Turn ends as completed with the cut text] E -- no --> S{Can fx change the request?} S -- yes --> RS[Resend once, silently, with a higher limit or low effort] S -- no --> C2[Turn ends as completed: ran out of output tokens before any text]After:
flowchart TD R[Reply stops at the output limit] --> N{Third cut in a row, or no step left?} N -- yes --> F[Turn fails with output_limit and a notice] N -- no --> K{What did the reply have?} K -- whole tool calls --> RC[Run them, then a note after their results] K -- only cut calls --> SS[Note: do it in smaller steps] K -- text --> CT[Keep the text, note: continue where it stopped] K -- nothing --> AN[Note: think less, take a small step] RC --> NX[Next request, with a limit fx chose raised once] SS --> NX CT --> NX AN --> NX CT -.-> J[The reply that finishes the answer joins every part]The AI SDK finishes a tool call only when its arguments are whole, so fx records the order in which calls started. A call counts as whole only when a later call started after it, so the call that started last never runs.
A cut reply is a successful response on the network, so
/tracewould not list it. A small ring of the last 16 cuts, with counts and names only, lets/traceshow each one and what fx did.Docs: vercel-labs/fx-web#367