Skip to content

feat(loop): make flash→pro escalation threshold configurable#699

Merged
esengine merged 1 commit into
esengine:mainfrom
dimasd-angga:fix/issue-628-make-flash-pro-escalation-threshold-conf
May 12, 2026
Merged

feat(loop): make flash→pro escalation threshold configurable#699
esengine merged 1 commit into
esengine:mainfrom
dimasd-angga:fix/issue-628-make-flash-pro-escalation-threshold-conf

Conversation

@dimasd-angga

Copy link
Copy Markdown

Summary

The flash→pro escalation threshold has been hardcoded to 3 repair signals per turn, which trips too early on long subagent runs where transient tool failures are expected and recoverable on flash. This PR makes the threshold configurable through escalation.failureThreshold in ~/.reasonix/config.json and a --escalate-after <n> flag on chat / code / run, while preserving the existing default of 3.

Changes

  • src/loop/turn-failure-tracker.ts: TurnFailureTracker now takes an optional threshold in its constructor (defaulting to the exported FAILURE_ESCALATION_THRESHOLD = 3) and compares against the instance value in noteAndCrossedThreshold.
  • src/loop.ts: add failureThreshold?: number to CacheFirstLoopOptions, validate (integer in [1,20], else stderr warning + fall back to default), and pass the resolved value into the TurnFailureTracker constructor.
  • src/config.ts: add the optional escalation?: { failureThreshold?: number } shape to ReasonixConfig.
  • src/cli/index.ts: add --escalate-after <n> to the chat, code, and run subcommands; parseEscalateAfterFlag mirrors parseBudgetFlag (lenient — bad value warns + returns undefined), and resolveFailureThreshold picks flag > config > default, honouring --no-config.
  • src/cli/commands/chat.tsx, code.tsx, run.ts, src/cli/ui/App.tsx: thread failureThreshold from CLI options through to the loop constructor; included in the AppInner memo deps.
  • tests/loop.test.ts: cover threshold=5 (no escalation until the 5th signal), default behaviour (threshold=3 preserved), and invalid values falling back to 3 with a stderr warning.

Testing

npm test -- tests/loop.test.ts — passes locally. The new cases exercise the tracker via the existing private-access helper used for the threshold=3 baseline.

Notes

  • Range bounds are [1,20] — generous enough for the long-subagent-run case (the issue suggests values around 5–10) without letting a typo disable escalation effectively forever.
  • No persistence helper was added — escalation.failureThreshold is hand-edited in ~/.reasonix/config.json, matching how budget is handled today.
  • The warning channel is stderr for both the flag and the config-key fallback; happy to switch to the structured logger if you'd prefer.

Closes #628

The hardcoded threshold of 3 repair signals escalates too eagerly on long subagent runs where transient tool failures are expected and recoverable on flash. Exposing this via `escalation.failureThreshold` in config and `--escalate-after` on the CLI lets users tune escalation to their workload without forking the loop, while preserving the existing default and behaviour for everyone else.
@esengine esengine merged commit 9cfe3d3 into esengine:main May 12, 2026
3 checks passed
esengine added a commit that referenced this pull request May 12, 2026
…il, CardStream fix (#705)

npm-only release. The Tauri desktop source is in the repo and the CLI
subcommand works, but installer bundles for macOS / Windows / Linux
don't ship this round (separate release once signing's settled).

Highlights:
- Tauri desktop client with multi-tab concurrent runtimes (#689)
  plus a near-full polish pass: wallet balance, version chip, active-
  plan rail, abortable pause-gates, edit-gate pill, en + zh-CN i18n,
  shared pause-policy module dedup'd with the CLI TUI (#701)
- checkpoint API + git-changes panel in the embedded dashboard (#682)
- outside-sandbox file access approval modal (#696)
- MCP loading pill + readiness gate on tool dispatch (#687)
- escalate-after flag for flash → pro threshold (#699)

Fixes:
- CardStream Maximum-update-depth crash, quantize window so boundary
  cards stop oscillating (#700, #702)
- `reasonix code` bridges config key to env + lazy subagent client so
  fresh installs can reach the setup wizard (#703)
- pinned-mode scroll shrinks coalesced (#666), generic CSI key decode
  (#692), shell-confirm preview clamp (#691), frontmatter BOM/folded
  lines (#690), MCP error classification (#688), and more
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…e#699)

The hardcoded threshold of 3 repair signals escalates too eagerly on long subagent runs where transient tool failures are expected and recoverable on flash. Exposing this via `escalation.failureThreshold` in config and `--escalate-after` on the CLI lets users tune escalation to their workload without forking the loop, while preserving the existing default and behaviour for everyone else.
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…il, CardStream fix (esengine#705)

npm-only release. The Tauri desktop source is in the repo and the CLI
subcommand works, but installer bundles for macOS / Windows / Linux
don't ship this round (separate release once signing's settled).

Highlights:
- Tauri desktop client with multi-tab concurrent runtimes (esengine#689)
  plus a near-full polish pass: wallet balance, version chip, active-
  plan rail, abortable pause-gates, edit-gate pill, en + zh-CN i18n,
  shared pause-policy module dedup'd with the CLI TUI (esengine#701)
- checkpoint API + git-changes panel in the embedded dashboard (esengine#682)
- outside-sandbox file access approval modal (esengine#696)
- MCP loading pill + readiness gate on tool dispatch (esengine#687)
- escalate-after flag for flash → pro threshold (esengine#699)

Fixes:
- CardStream Maximum-update-depth crash, quantize window so boundary
  cards stop oscillating (esengine#700, esengine#702)
- `reasonix code` bridges config key to env + lazy subagent client so
  fresh installs can reach the setup wizard (esengine#703)
- pinned-mode scroll shrinks coalesced (esengine#666), generic CSI key decode
  (esengine#692), shell-confirm preview clamp (esengine#691), frontmatter BOM/folded
  lines (esengine#690), MCP error classification (esengine#688), and more
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.

Make flash->pro escalation threshold configurable (default 3 fires too early on long subagent runs)

2 participants