Skip to content

Commit 16d9ef3

Browse files
john-b-yangclaude
andcommitted
Surface per-step budget in agent observations
Add a global observation_template in configs/mini/default.yaml with a [Step n/limit used - k left] banner, and thread it onto the model via a ClashAgentConfig field pushed in ClashAgent.__init__. Applies to every model backend, tournament type, and arena; models otherwise learn the step limit only once at round start with no running counter. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9906f6a commit 16d9ef3

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

codeclash/agents/minisweagent.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
)
1919

2020

21+
class ClashAgentConfig(AgentConfig):
22+
"""`AgentConfig` plus an optional global observation-format override.
23+
24+
`observation_template` is a model-side field in mini-swe-agent, so putting it in the shared
25+
agent config (`configs/mini/default.yaml`) doesn't reach the model on its own. Declaring it
26+
here lets the one global config drive it; `ClashAgent` pushes it onto the model at init."""
27+
28+
observation_template: str | None = None
29+
30+
2131
class ClashAgent(DefaultAgent):
2232
"""`DefaultAgent` from mini-SWE-agent (https://github.com/SWE-agent/mini-swe-agent)
2333
with per-player debug logging."""
@@ -28,11 +38,15 @@ def __init__(
2838
env: DockerEnvironment,
2939
*,
3040
logger: logging.Logger,
31-
config_class: Callable = AgentConfig,
41+
config_class: Callable = ClashAgentConfig,
3242
**kwargs,
3343
):
3444
super().__init__(model, env, config_class=config_class, **kwargs)
3545
self.logger = logger
46+
# Honor the global observation_template (agent config) by pushing it onto the model,
47+
# which is what actually renders observations. Applies to every backend uniformly.
48+
if getattr(self.config, "observation_template", None):
49+
self.model.config.observation_template = self.config.observation_template
3650

3751
def add_messages(self, *messages: dict) -> list[dict]:
3852
result = super().add_messages(*messages)

configs/mini/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ instance_template: |
102102
You cannot continue working in any way on this task after submitting.
103103
step_limit: 30
104104
cost_limit: 0
105+
# Global observation format for every model/tournament/arena. ClashAgent pushes this onto the
106+
# model config (mini-swe-agent renders observations model-side). The leading banner surfaces the
107+
# per-round step budget so the model can pace itself; the rest is mini's default observation body.
108+
observation_template: "[Step {{n_model_calls}}/{{step_limit}} used - {{step_limit - n_model_calls}} left]\n{% if output.exception_info %}<exception>{{output.exception_info}}</exception>\n{% endif %}<returncode>{{output.returncode}}</returncode>\n<output>\n{{output.output}}</output>"

0 commit comments

Comments
 (0)