Repository navigation
feat(opencode): cap the build agent's steps with max_steps - #5716
Open
gwarmstrong wants to merge 4 commits into
Open
gwarmstrong wants to merge 4 commits into
gwarmstrong wants to merge 4 commits into
Conversation
The sandboxed OpenCode agent (opencode_sandboxed_agent) runs OpenCode
1.17.11 with compaction {auto: false, prune: false} and 400 build-agent
steps. A session of opencode_agent accepted only permission and tools in
opencode_config, so the same benchmark kept OpenCode's default
compaction and step limit there, and the two agents were not comparable.
- Session opencode_config also accepts compaction, which OpenCode reads
for automatic compaction and tool-output pruning.
- max_steps (unset by default) writes agent.build.steps in both
execution modes. In a session it joins the request sampling and the
replaced prompt on the build agent rather than overwriting them.
Defaults are unchanged.
Signed-off-by: gwarmstrong <[email protected]>
7 tasks done
7 tasks done
Main (NVIDIA-NeMo#5719, NVIDIA-NeMo#5833) now lets a session's opencode_config set compaction.auto and agent.build.steps, through _session_opencode_config_error. That validator replaces this branch's permission/tools/compaction allowlist, so a session still refuses compaction.prune, which rewrites old tool output and breaks the token prefix. max_steps stays: it sets agent.build.steps in both execution modes, over any value in opencode_config. The session test now uses compaction {auto: false} and checks that max_steps replaces a configured agent.build.steps. Signed-off-by: gwarmstrong <[email protected]>
Contributor
Author
|
/ok to test e149fcc |
Contributor
Signed-off-by: gwarmstrong <[email protected]>
… reports Main's NVIDIA-NeMo#5719 already admits compaction.auto and agent.build.steps in a session's opencode_config, so this PR keeps only max_steps. The new test covers the step-limit metadata with max_steps alone and over a configured agent.build.steps. The README no longer says a session with token capture refuses agent.build.steps: since NVIDIA-NeMo#5833, token capture keeps the calls after OpenCode's step-limit note chained. Signed-off-by: gwarmstrong <[email protected]>
Contributor
Author
|
/ok to test d51936a |
yaoyu-33
reviewed
Dec 2, 2026
yaoyu-33
left a comment
Contributor
There was a problem hiding this comment.
I checked the effective sandbox configuration for both OpenCode versions.
| else: | ||
| config["instructions"] = [f"{state.session.session_dir}/instructions.md"] | ||
| if self.config.max_steps is not None: | ||
| config.setdefault("agent", {}).setdefault("build", {})["steps"] = self.config.max_steps |
Contributor
There was a problem hiding this comment.
This sets the cap in the v1 sandbox launcher. In a v2 session with only max_steps=3, _opencode2_launch still receives the original opencode_config, so the launched config has no step limit and the response has no threshold to report. With nested steps=9, v2 uses 9. Could both launchers use the same effective build settings and cover these two v2 cases?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
opencode_agentgetsmax_steps, the step cap of OpenCode's build agent (agent.build.steps). It is unset by default and works in both execution modes. Other agents take their step budget from a top-levelmax_steps(simple_agent,finance_agent,browsecomp_agentand others), so a benchmark that compares harnesses can set it the same way for OpenCode.max_stepswritesagent.build.stepsin local runs and in agent sessions. It replaces a value set inopencode_config.agent.build.steps. In a session it joins the request sampling and the replaced prompt on the build agent.metadata.harness_step_limit_reachedreads the cap from the launched config, so it appliesmax_stepstoo.agent.build.steps. Since fix(token_capture): keep capture chains through OpenCode's step-limit note and tool-name repair #5833, token capture keeps the calls after OpenCode's step-limit note chained, and the paragraph below it already says so.Narrowed since the first version. This PR used to let sessions set
compactionas well. Main's #5719 now admitscompaction.autoandagent.build.stepsin a session'sopencode_config, so that part is gone, along with its tests.compaction.prune: false, whichopencode_sandboxed_agent's benchmark profile also sets, needs no change: OpenCode 1.17.11 prunes old tool outputs only whencompaction.pruneis true (SessionCompaction.prunereturns early otherwise).No issue: a small option for the harness comparisons in #5552.
Validation
At the head (main merged 2026-11-16):
gym env test +entrypoint=responses_api_agents/opencode_agent: 1005 passed, 1 skipped, 1 failed. The failure,test_the_plugin_registers_its_hooks_and_acts_on_them, comes from the host's default Node 19: with Node 22 onPATH,tests/test_opencode2_session.pypasses (20 passed). It does not touch this change.test_max_steps_is_the_step_limit_the_response_reports: withmax_stepsalone, and with a larger configuredagent.build.steps, a prompt that made 3 model calls at a cap of 3 is marked; a cap of 4 over a configured 2 is not. The launched config carriesmax_stepsin each case. The four earliermax_stepstests cover the session and local configs and reject a non-positive cap.pre-commit runon the changed files: clean. DCO sign-off.Rollouts
Host path at 1d2a3a1, OpenCode 1.17.11,
nvidia/nemotron-3-nano-30b-a3bthrough inference-api. One task: three file writes with separate tool calls, a directory listing, thenDONE. Themax_stepscode has not changed since.DONEcompaction: {auto: false, prune: false},max_steps: 400DONEmax_steps: 1OpenCode accepts the cap and stops at it.
Compatibility
Opt-in only. Existing configs and results are unchanged.