From 6ce6a014da47fdacabbe0b1f004e1d8144435648 Mon Sep 17 00:00:00 2001 From: Rakshith Ramprakash Date: Sat, 3 Oct 2026 01:51:42 +1000 Subject: [PATCH] agent: don't report 0 credits on a refunded credit stop; release 1.25.2 Failed runs are refunded, so the API reports creditsUsed 0 for a run that did work and hit its limit. Omit the figure unless it is positive. Bumps the version so the credit-limit handling from #299 ships. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- src/__tests__/alexandria-beta.test.ts | 18 ++++++++++++++++++ src/commands/agent.ts | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bba4b7addf..5884aa87b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "firecrawl-cli", - "version": "1.25.1", + "version": "1.25.2", "publishConfig": { "tag": "latest" }, diff --git a/src/__tests__/alexandria-beta.test.ts b/src/__tests__/alexandria-beta.test.ts index 055ef60ab8..5ee27d7057 100644 --- a/src/__tests__/alexandria-beta.test.ts +++ b/src/__tests__/alexandria-beta.test.ts @@ -1124,6 +1124,24 @@ function runThenPoll(statusResponse: Record) { : statusResponse; } +it('does not report 0 credits for a refunded credit stop', async () => { + runThenPoll({ ...creditStopped, creditsUsed: 0 }); + const result = await cli([ + 'agent', + 'Find companies.', + '--max-credits', + '25', + '--wait', + '--poll-interval', + '0.01', + ]); + expect(result.code).toBe(1); + expect(result.stdout).toContain( + 'Stopped at credit limit: the agent reached its credit limit before finishing.' + ); + expect(result.stdout).not.toContain('used 0 credits'); +}); + it('returns the partial result when a waited run hits its credit limit', async () => { runThenPoll(creditStopped); const args = ['agent', 'Find companies.', '--max-credits', '25', '--wait']; diff --git a/src/commands/agent.ts b/src/commands/agent.ts index 022cc2bb6d..139dabb7f0 100644 --- a/src/commands/agent.ts +++ b/src/commands/agent.ts @@ -460,8 +460,9 @@ function partialHeading(data: AgentIncompleteFields): string { * First line of the credit-limit notice. */ function creditLimitHeadline(data: { creditsUsed?: number | null }): string { + // Failed runs are refunded, so the API can report 0 for a run that did work. const used = - data.creditsUsed !== undefined && data.creditsUsed !== null + typeof data.creditsUsed === 'number' && data.creditsUsed > 0 ? `used ${data.creditsUsed} credits and ` : ''; return `Stopped at credit limit: the agent ${used}reached its credit limit before finishing.`;