1jehuang / 1jehuang/jcode

jcode run has no turn/step limit (--max-turns equivalent)

Open
#803 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no enhancement triage: needs-decision
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 turn
  • JCODE_HOOK_PRE_TOOL → a gate that reads the counter and exit 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.