jcode run has no turn/step limit (--max-turns equivalent)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Summary
jcode run has no way to bound how long the agent loop runs. There is no --max-turns / --max-steps flag, and no equivalent key in config.toml. Grepping the tree at 02439b4, the only max_steps are in jcode-telemetry-core (onboarding trace) and the TUI debug bench — nothing caps the agent loop itself.
Every comparable CLI has one:
| CLI | knob |
|---|---|
| Claude Code | --max-turns |
| goose | --max-turns |
| kimi-cli | --max-steps-per-turn |
| gemini-cli | model.maxSessionTurns |
| mini-swe-agent | agent.step_limit |
Why it matters
For unattended/batch use — CI, evaluation harnesses, anything spawning many jcode run invocations — the cap is what bounds worst-case cost and wall-clock when a task turns out to be unsolvable and the model keeps trying. Right now a single stuck run can loop until it is killed externally.
I run jcode over a benchmark of Word-editing tasks (one jcode run per task, dozens in parallel), and this is the only preset in my harness where I cannot express "give up after N turns" to the CLI itself.
Workaround, for reference
There is a workable stopgap using the existing hooks, which is what I ended up shipping:
JCODE_HOOK_TURN_START→ a script that appends one byte to a counter file per turnJCODE_HOOK_PRE_TOOL→ a gate that reads the counter andexit 2s once it passes the cap
It works because pre_tool is the one hook that can veto, and counting turn_start keeps the unit honest (a single turn may issue several parallel tool calls, so counting calls caps early). But it only denies tools — the loop keeps running and the model has to give up on its own, so it is a budget on tool use rather than a real stop condition.
Suggestion
A --max-turns N on run (and a matching config.toml default) that ends the session with a clear stop reason. For non-interactive use it would also help if the reason were visible in --json output, so a caller can distinguish "finished" from "hit the cap" without parsing prose.
Environment: jcode 0.68.0, Linux x86_64.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the implementation of jcode run and trace the agent loop through the existing JCODE_HOOK_TURN_START and JCODE_HOOK_PRE_TOOL lifecycle. Check how config.toml defaults and --json output are handled. Done means a configurable turn cap stops the session cleanly and exposes a distinct cap stop reason in non-interactive JSON output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100