Skip to content

fix(agents): pre-acknowledge Claude Code's cost-threshold notice - #587

Merged
aixle-com[bot] merged 2 commits into
developfrom
feature/claude-cost-threshold-ack
Oct 27, 2026
Merged

aixle-com[bot] merged 2 commits into
developfrom
feature/claude-cost-threshold-ack

Conversation

@aixle-com

@aixle-com aixle-com Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Board task #184.

Problem

An API-billed Claude Code session that crosses $5 shows a blocking notice ("You've spent $5 on the Anthropic API this session.") and waits for a keypress. In an automatic step nobody answers, the pane goes silent and Sessions::NoOutputWatchdog kills the session after 30 minutes, failing the run even when its work was done (runs 3390, 5341).

Changes

  • Agents::ClaudeCodeAdapter#generate_config writes "hasAcknowledgedCostThreshold" => true next to hasSeenAutoDefaultNudge, with a comment. No other config key changes.
  • InteractivePromptDetector gets a :claude_cost_threshold signature (claude_code only). Markers: the notice title and its single option Got it, thanks!. Footer: Enter to confirm · Esc to cancel. That footer is shared by all Claude Code select dialogs, so the markers carry the specificity. If a later CLI shows the notice anyway, the session fails right away with a message naming the notice and the config flag.
  • Tests: generate_config asserts the key. Detector tests cover detection and the message, moving past the notice, another dialog with the same footer, and another agent type.

How the key was confirmed against the pinned version

The pin is cli_version: "2.1.310" in config/agent_runtimes.json (the CLI_VERSION build arg of docker/claude-code/Dockerfile).

  1. Downloaded https://downloads.claude.ai/claude-code-releases/2.1.310/linux-x64/claude. Its sha256 b7367643…47df56 matches the release manifest, and claude --version reports 2.1.310 (Claude Code).
  2. Read the bundled JS. The cost-threshold notification skips the dialog when ue().hasAcknowledgedCostThreshold (the global ~/.claude.json config) is set. Its threshold is 5 USD (Gh() = costLedger.totalCostUSD()), and acknowledging runs Re(H => ({...H, hasAcknowledgedCostThreshold: !0})).
  3. Reproduced it end to end. 2.1.310 ran in a 120x30 tmux pane against a local mock Messages API that reports 3M input tokens per turn, with an API key and an admin oauthAccount (the notice's WBr() gate needs this). After one turn the notice appeared. The detector test fixture is that capture. Pressing Enter wrote hasAcknowledgedCostThreshold: true to ~/.claude.json. A fresh run with the key preset and the same cost showed no notice.

How to test

bin/rails test test/services/agents/claude_code_adapter_test.rb test/services/interactive_prompt_detector_test.rb, then the full suite.

Aixle Flow added 2 commits October 27, 2026 15:15
An API-billed Claude Code session that crosses $5 shows a blocking
"You've spent $5 on the Anthropic API this session." notice. Nobody
answers it in an automatic step, so the pane goes silent and the
no-output watchdog kills the session after 30 minutes (runs 3390, 5341).

Write hasAcknowledgedCostThreshold into ~/.claude.json, the flag the
CLI itself records once the notice is answered (confirmed on 2.1.310),
and teach InteractivePromptDetector the notice so a CLI that shows it
anyway fails at once with a message that names it.

Signed-off-by: Aixle Flow <[email protected]>
@aixle-com
aixle-com Bot merged commit 5ef4637 into develop Oct 27, 2026
16 checks passed
artempartos added a commit to Hitin/flow that referenced this pull request Oct 28, 2026
* origin/develop:
  docs(workflows): describe workflows as sessions made of steps (AixleHQ#595)
  feat(workflows): open archived workflows read-only in the builder (AixleHQ#594)
  feat(task-comments): let authors delete their own recent comments (AixleHQ#593)
  feat(mcp): log the JSON-RPC method and tool name of each MCP call (AixleHQ#592)
  fix(board): show a run waiting for a session slot as Queued on its card (AixleHQ#591)
  feat(brand): use the new Aixle Flow lockup and route fonts through tokens (AixleHQ#590)
  feat(overview): show tokens used and session time instead of token cost (AixleHQ#589)
  fix(agents): pre-acknowledge Claude Code's cost-threshold notice (AixleHQ#587)
  test(playwright): QA helpers batch 2 (appRequest, readInertiaPage, shot, probeRoutes, signOut) (AixleHQ#586)
  test(playwright): plain-JS QA helpers for browser_run_code on staging (AixleHQ#584)
  feat(runners): add the runners table and the Runner model (AixleHQ#583)
  refactor(feature-flags): plain cached reads, no usage tooling (AixleHQ#579)

# Conflicts:
#	CHANGELOG.md
artempartos added a commit to Hitin/flow that referenced this pull request Oct 28, 2026
* origin/develop:
  docs(workflows): describe workflows as sessions made of steps (AixleHQ#595)
  feat(workflows): open archived workflows read-only in the builder (AixleHQ#594)
  feat(task-comments): let authors delete their own recent comments (AixleHQ#593)
  feat(mcp): log the JSON-RPC method and tool name of each MCP call (AixleHQ#592)
  fix(board): show a run waiting for a session slot as Queued on its card (AixleHQ#591)
  feat(brand): use the new Aixle Flow lockup and route fonts through tokens (AixleHQ#590)
  feat(overview): show tokens used and session time instead of token cost (AixleHQ#589)
  fix(agents): pre-acknowledge Claude Code's cost-threshold notice (AixleHQ#587)
  test(playwright): QA helpers batch 2 (appRequest, readInertiaPage, shot, probeRoutes, signOut) (AixleHQ#586)
  test(playwright): plain-JS QA helpers for browser_run_code on staging (AixleHQ#584)
  feat(runners): add the runners table and the Runner model (AixleHQ#583)
  refactor(feature-flags): plain cached reads, no usage tooling (AixleHQ#579)

# Conflicts:
#	CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant