Skip to content

fix: auto-continue circuit breaker + node timeout - #244

Merged
avoidwork merged 8 commits into
mainfrom
fix/auto-continue-circuit-breaker
Jun 15, 2026
Merged

fix: auto-continue circuit breaker + node timeout#244
avoidwork merged 8 commits into
mainfrom
fix/auto-continue-circuit-breaker

Conversation

@avoidwork

@avoidwork avoidwork commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Description

When the model generates thinking content but hits the output token limit, the auto-continue logic fires repeatedly. With auto-compaction active, context bloat is not a concern, but the model can still get stuck in a reasoning loop producing no text output.

Auto-Continue Circuit Breaker:

  • Add a circuit breaker (configurable via agent.autoContinueLimit, default 1000) that stops auto-continue and alerts the user
  • Update committedContent during auto-continue (was only updating responseContent, causing the final message to render empty)
  • Track auto-continue state with isAutoContinuingRef to prevent premature counter reset
  • Show a system message when the circuit breaker triggers with the configured threshold

Node Timeout:

  • Add agent.nodeTimeout (default 600000ms / 10 minutes) to config.yaml and the config schema
  • Wire the timeout through createReactAgent as a stepTimeout on the compiled LangGraph agent
  • Prevents nodes from hanging indefinitely by capping superstep execution time

Temperature Adjustment:

  • Lower default temperature from 0.7 to 0.4 for more deterministic responses

Documentation:

  • Document AGENT_AUTO_CONTINUE_LIMIT and AGENT_NODE_TIMEOUT environment variables
  • Add entries to both the Docker env var table and the Config Reference table

The circuit breaker threshold is configurable in config.yaml under agent.autoContinueLimit to allow tuning without code changes.

Inspired by LangGraph fault tolerance primitives: RetryPolicy, TimeoutPolicy, and error_handler.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional change)
  • Performance improvement
  • CI / build / tooling

Testing

  • Verified all 1,126 existing tests pass
  • Lint (oxlint) passes with 0 warnings and 0 errors
  • Confirmed the fix applies to both code paths (skill execution and user message)

Coverage

  • 100% line coverage maintained

Checklist

  • npm run lint passes
  • Tests pass with 100% line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

When the model generates thinking content but hits the output token
limit, committedContent remains empty and the auto-continue logic
fires repeatedly, adding more context and making it harder for the
model to produce text. This creates a feedback loop that results in
empty messages in the TUI.

Fix:
- Track consecutive auto-continue attempts with a ref counter
- Circuit breaker: stop after 3 consecutive empty responses
- Update committedContent during auto-continue (was only updating
  responseContent, causing the final message to render empty)
- Add isAutoContinuingRef to distinguish auto-continue text from
  the initial response, preventing premature counter reset
- Show a system message when the circuit breaker triggers, alerting
  the user that the model may be stuck in a reasoning loop

Inspired by LangGraph's fault tolerance primitives: RetryPolicy,
TimeoutPolicy, and error_handler patterns.
@avoidwork avoidwork self-assigned this Jun 14, 2026
With auto-compaction active, context bloat is not a concern.
Increase the circuit breaker from 3 to 1000 to allow the model
more room to work through complex reasoning cycles.
@avoidwork avoidwork changed the title fix: circuit breaker for auto-continue to prevent empty messages fix: auto-continue circuit breaker (threshold: 1000) Jun 14, 2026
Add agent.nodeTimeout (default 600000ms / 10 minutes) to
config.yaml and the config schema. This will be used to set
the superstep timeout on the LangGraph agent.
Add agent.nodeTimeout: 600000 (10 minutes) to config.yaml.
Add optional timeout parameter (default 10 minutes) to createReactAgent.
Sets stepTimeout on the compiled graph to prevent nodes from hanging
indefinitely. This is LangGraph's mechanism for capping superstep
execution time.
Pass config.agent.nodeTimeout to createReactAgent so the LangGraph
agent gets a 10-minute superstep timeout by default. This prevents
nodes from hanging indefinitely.
@avoidwork avoidwork changed the title fix: auto-continue circuit breaker (threshold: 1000) fix: auto-continue circuit breaker + node timeout Jun 14, 2026
@avoidwork
avoidwork enabled auto-merge (squash) June 15, 2026 00:18
@avoidwork
avoidwork merged commit 235a119 into main Jun 15, 2026
2 checks passed
@avoidwork
avoidwork deleted the fix/auto-continue-circuit-breaker branch June 15, 2026 00:18
@avoidwork avoidwork mentioned this pull request Jun 15, 2026
11 tasks
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