agent: show partial results when a run hits its credit limit - #299
Merged
Merged
Conversation
When a run fails with stopReason "credit_limit_reached", print a clear notice with the run's message, output the partial result (JSON keeps partial, partialSchemaValid and stopReason; human output labels it incomplete and shows schema validity), and say how to continue: follow up on the thread or rerun with a higher --max-credits. Waited runs still exit 1. Thread listings show per-run partials and a continue hint when the latest turn stopped at its credit limit. The pinned SDK (4.40.0) does not type these fields yet, so they are read defensively; with the fields absent, output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rakshith48
marked this pull request as ready for review
October 2, 2026 14:44
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
- The credit-limit failure path now sets process.exitCode = 1 and returns instead of calling process.exit(1), so a large JSON result piped to another program is no longer cut off at 64 KiB. Exit status stays 1. - `agent thread --json` (and --output) now prints the continuation hint on stderr when the latest turn stopped at its credit limit; stdout stays pure JSON. - Tests: --output sends the "in <path>" notice to stderr and the result to the file; plain text mode keeps the notice off stderr; thread --json hint goes to stderr; a large piped JSON result arrives whole with exit 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds credit-limit stop handling to the agent CLI: failed runs now surface the recovered partial, stop reason, and continue hints in human, JSON, and thread output, guarded so older servers are unchanged. Bounded, well-tested output improvement.
Re-trigger cubic
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.
What this does
When an agent run stops because it hit its credit limit, the CLI now shows what the agent found so far, instead of just printing an error.
--json: the output includespartial,partialSchemaValidandstopReason, plussuccess: falseanderror.--max-credits.--waitruns still exit 1, the same as any other failed run.firecrawl agent thread <id>shows each run's partial and adds a "continue" hint when the latest turn stopped at its credit limit.When the new fields are missing, nothing changes. That covers older servers and the default setup, since the server flag starts off. Other failed runs still print
Error: ...and exit 1 exactly as before.Notes
firecrawl@4.40.0) does not have these fields in its types yet, so the CLI reads them defensively from the raw response. It does not bump to an unreleased SDK.firecrawl agent <job-id>, without--wait) still exits 0 for a failed run, as it does today. It now also shows the notice and the partial.--jsonmode, or with-o, the notice goes to stderr so the JSON or file output stays clean.Merge order
Merge this after firecrawl/firecrawl#4812 is deployed. Source PRs:
partial/partialSchemaValid/stopReasononGET /v2/agent/{id}and thread runsTesting
pnpm run format:check,pnpm run type-check,pnpm run buildandpnpm testall pass (663 tests).🤖 Generated with Claude Code
Summary by cubic
Shows what an agent found so far when a run stops at its credit limit, instead of just printing an error.
--max-credits.partial,partialSchemaValid, andstopReason; human output labels the partial "Partial Result (incomplete)" and notes schema validity when the server sends it.firecrawl agent thread <id>shows each run's partial and adds a continue hint when the latest turn stopped at its credit limit.--jsonor--outputmode, the notice goes to stderr to keep stdout pure JSON or the file clean.Written for commit d6c6ac8. Summary will update on new commits.