From 13287bcf46cfe6b2237b89aac52a01b0348956dd Mon Sep 17 00:00:00 2001 From: CarlesUIPath Date: Tue, 24 Nov 2026 13:09:41 +0000 Subject: [PATCH 1/5] feat(codex): pin an explicit tool output cap, default 10000 tokens Codex caps each tool output by the model's catalog entry. A model the catalog does not know gets a fallback cap of 10,000 bytes, about a quarter of the 10,000-token cap that catalog models get, so results changed with Codex's catalog rather than with the task. Add agent.tool_output_token_limit (Codex only, default 10000, null keeps the Codex default) and pass it as tool_output_token_limit in the thread config. The value is recorded in the run's agent_config. Co-Authored-By: Claude Opus 5.5 --- docs/agents/CODEX.md | 11 +++++ src/coder_eval/agents/codex_agent.py | 3 ++ src/coder_eval/models/agent_config.py | 11 +++++ tests/test_codex_tool_output_cap.py | 69 +++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 tests/test_codex_tool_output_cap.py diff --git a/docs/agents/CODEX.md b/docs/agents/CODEX.md index 367f39a4..e07d185d 100644 --- a/docs/agents/CODEX.md +++ b/docs/agents/CODEX.md @@ -201,6 +201,17 @@ uses it as the model's context window, capped to the model's catalog maximum, an auto-compacts at 90% of it. See [Harness parity](HARNESS_PARITY.md#the-context-window-cap-per-harness). +### Tool Output Cap + +`agent.tool_output_token_limit` (Codex only, default `10000`) is passed as +`tool_output_token_limit` in the thread `config`. Codex cuts each tool output it shows the +model to this many tokens, keeping the head and the tail. The default is the cap that Codex +gives the models in its own catalog. Without it, a model that the catalog does not know gets +a fallback cap of 10,000 bytes, about a quarter of the size, so a newer model would see less +of each command output than an older one. The value is recorded in the run's `agent_config`. +Set it to `null` to use the Codex default for the model, or override it per run with +`-D agent.tool_output_token_limit=20000`. + ### Skills Discovery The agent sets up SKILL.md files (Agent Skills open standard) in `.agents/skills/` directory: diff --git a/src/coder_eval/agents/codex_agent.py b/src/coder_eval/agents/codex_agent.py index b57998dd..95ab7d84 100644 --- a/src/coder_eval/agents/codex_agent.py +++ b/src/coder_eval/agents/codex_agent.py @@ -1791,6 +1791,9 @@ def _build_thread_options(self) -> dict[str, Any]: # Codex then auto-compacts at 90% of this window. tool_config["model_context_window"] = self.config.context_window + if self.config.tool_output_token_limit is not None: + tool_config["tool_output_token_limit"] = self.config.tool_output_token_limit + if tool_config: options["config"] = tool_config diff --git a/src/coder_eval/models/agent_config.py b/src/coder_eval/models/agent_config.py index 2ff68cb7..594f7a14 100644 --- a/src/coder_eval/models/agent_config.py +++ b/src/coder_eval/models/agent_config.py @@ -377,6 +377,17 @@ class CodexAgentConfig(BaseAgentConfig): # `yes` that loads as 1. _context_window_range: ClassVar[tuple[int, int | None] | None] = (32_768, None) + tool_output_token_limit: int | None = Field( + default=10_000, + gt=0, + description=( + "Cap, in tokens, on each tool output Codex shows the model, passed as Codex's " + "tool_output_token_limit. The default is the cap Codex gives the models in its own " + "catalog; without it, a model the catalog does not know gets a much smaller fallback " + "cap (10,000 bytes). None leaves Codex's own per-model default." + ), + ) + def egress_hosts(self, env: Mapping[str, str]) -> tuple[str, ...]: """The ``CODEX_BASE_URL`` host when it is forwarded, else ``api.openai.com``. diff --git a/tests/test_codex_tool_output_cap.py b/tests/test_codex_tool_output_cap.py new file mode 100644 index 00000000..80fc02e8 --- /dev/null +++ b/tests/test_codex_tool_output_cap.py @@ -0,0 +1,69 @@ +"""``agent.tool_output_token_limit``: an explicit Codex tool-output cap, not one from Codex's model catalog.""" + +from __future__ import annotations + +from typing import Any + +import pytest +from pydantic import ValidationError + +from coder_eval.models import AgentKind, TaskDefinition, parse_agent_config +from coder_eval.orchestration.config_merge import Layer, resolve_root +from coder_eval.orchestration.overrides import apply_overrides, parse_override + + +def _thread_config(**config_kwargs: Any) -> dict[str, Any]: + pytest.importorskip("openai_codex") + from coder_eval.agents.codex_agent import CodexAgent + + agent = CodexAgent(parse_agent_config(type=AgentKind.CODEX, model="example-model", **config_kwargs)) + return agent._build_thread_options().get("config", {}) + + +def _task(agent: dict[str, Any]) -> TaskDefinition: + return TaskDefinition.model_validate( + {"task_id": "cap", "description": "d", "initial_prompt": "p", "agent": agent, "success_criteria": []} + ) + + +class TestThreadOptions: + def test_the_default_cap_reaches_codex(self): + assert _thread_config()["tool_output_token_limit"] == 10_000 + + def test_an_override_reaches_codex(self): + assert _thread_config(tool_output_token_limit=25_000)["tool_output_token_limit"] == 25_000 + + def test_none_leaves_the_codex_default(self): + assert "tool_output_token_limit" not in _thread_config(tool_output_token_limit=None) + + +class TestConfig: + @pytest.mark.parametrize("limit", [0, -1]) + def test_a_non_positive_cap_fails_at_load(self, limit): + with pytest.raises(ValidationError): + parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=limit) + + def test_another_harness_rejects_the_field(self): + with pytest.raises(ValidationError): + parse_agent_config(type=AgentKind.CLAUDE_CODE, tool_output_token_limit=10_000) + + def test_the_run_records_the_default(self): + assert parse_agent_config(type=AgentKind.CODEX).model_dump()["tool_output_token_limit"] == 10_000 + + def test_yaml_null_survives_the_merge(self): + resolved = resolve_root( + "agent", + [ + Layer(source="experiment-defaults", patch={"type": "codex"}), + Layer(source="variant", patch={"tool_output_token_limit": None}), + ], + ) + assert resolved is not None + assert resolved.model_dump()["tool_output_token_limit"] is None + + @pytest.mark.parametrize(("raw", "expected"), [("20000", 20_000), ("null", None)]) + def test_a_cli_override_sets_the_cap(self, raw, expected): + task = _task({"type": "codex"}) + apply_overrides(task, dict([parse_override(f"agent.tool_output_token_limit={raw}")])) + assert task.agent is not None + assert task.agent.model_dump()["tool_output_token_limit"] == expected From ccee881f708f4d00995a8f8c7358b255dc47eff7 Mon Sep 17 00:00:00 2001 From: CarlesUIPath Date: Tue, 24 Nov 2026 13:23:07 +0000 Subject: [PATCH 2/5] fix(codex): bound tool_output_token_limit and document the exec ceiling Codex's exec tool also cuts each command output to the max_output_tokens the model may pass per call, 10000 tokens by default, with no config key to raise it. A tool_output_token_limit above 10000 therefore widens only MCP and other tool outputs, and exec calls where the model asks for more. Log a warning at load for such a value and document the ceiling. Reject a bool (a YAML yes loads as 1) and values outside 1024-1000000, as the context_window floor does. Document that the value overrides a tool_output_token_limit in $CODEX_HOME/config.toml, with a parity note beside context_window, and that rows written before the field existed re-load with the default. Per-command output for models outside Codex's catalog grows from 10,000 bytes to about 40 KB; codex runs before and after are not comparable for those models. Co-Authored-By: Claude Opus 5.5 --- docs/agents/CODEX.md | 22 +++++++++++++--- docs/agents/HARNESS_PARITY.md | 7 +++++ src/coder_eval/models/agent_config.py | 37 +++++++++++++++++++++++++-- tests/test_codex_tool_output_cap.py | 30 +++++++++++++++++++--- 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/docs/agents/CODEX.md b/docs/agents/CODEX.md index e07d185d..1adaba70 100644 --- a/docs/agents/CODEX.md +++ b/docs/agents/CODEX.md @@ -203,14 +203,28 @@ auto-compacts at 90% of it. See ### Tool Output Cap -`agent.tool_output_token_limit` (Codex only, default `10000`) is passed as -`tool_output_token_limit` in the thread `config`. Codex cuts each tool output it shows the +`agent.tool_output_token_limit` (Codex only, default `10000`, range 1024-1000000) is passed +as `tool_output_token_limit` in the thread `config`. Codex cuts each tool output it shows the model to this many tokens, keeping the head and the tail. The default is the cap that Codex gives the models in its own catalog. Without it, a model that the catalog does not know gets a fallback cap of 10,000 bytes, about a quarter of the size, so a newer model would see less of each command output than an older one. The value is recorded in the run's `agent_config`. -Set it to `null` to use the Codex default for the model, or override it per run with -`-D agent.tool_output_token_limit=20000`. + +Command output has a second cap. The exec tool cuts it to the `max_output_tokens` the model +may pass in each call, 10000 tokens when the model passes none, and no Codex config key +raises that default. Command output is therefore capped at the smaller of the two, so a value +above `10000` widens it only in calls where the model asks for more; it applies in full to MCP +and other tool outputs. Such a value logs a warning when the config loads. + +The value overrides a `tool_output_token_limit` in `$CODEX_HOME/config.toml`. Set it to +`null` to let that host value, or else the Codex default for the model, apply. Override it +per run with `-D agent.tool_output_token_limit=5000`. + +Codex runs from before this option existed ran with the Codex default, so for a model outside +the catalog each command output grew from 10,000 bytes to about 40 KB: those runs are not +comparable with later ones. Their rows have no `tool_output_token_limit` key in +`agent_config`, and a re-load (`evaluate`, resume, reports) fills in the default `10000`, +which those runs did not have. ### Skills Discovery diff --git a/docs/agents/HARNESS_PARITY.md b/docs/agents/HARNESS_PARITY.md index a39a4e12..249adcb1 100644 --- a/docs/agents/HARNESS_PARITY.md +++ b/docs/agents/HARNESS_PARITY.md @@ -681,6 +681,13 @@ uncapped under a "capped" label is a wrong measurement. - Neither harness reports when the model's own window has lowered the cap. A cap above the model's window runs at the model's window. +`agent.tool_output_token_limit` is a related Codex-only knob and is not shared: it caps, +in tokens, each tool output Codex shows the model (default `10000`, passed in the thread +config). Unlike `context_window`, it is set by default, so a `tool_output_token_limit` in +`$CODEX_HOME/config.toml` is overridden; set it to `null` to let the host value apply. +Claude Code caps Bash output with its own mechanism, so the same number does not mean the +same cap there. See [Codex](CODEX.md#tool-output-cap). + ## `agent.plugins[].path` accepts different depths per harness Not a run limit, but the same promise: one task file, three harnesses, same meaning. diff --git a/src/coder_eval/models/agent_config.py b/src/coder_eval/models/agent_config.py index 594f7a14..339f7b7a 100644 --- a/src/coder_eval/models/agent_config.py +++ b/src/coder_eval/models/agent_config.py @@ -3,6 +3,7 @@ from __future__ import annotations import dataclasses +import logging from collections.abc import Mapping from typing import Annotated, Any, ClassVar, Literal, Self, TypedDict @@ -23,6 +24,8 @@ from coder_eval.models.sandbox import url_egress_target +logger = logging.getLogger(__name__) + type SettingSource = Literal["user", "project", "local"] """Vendor-neutral mirror of claude_agent_sdk.SettingSource (no SDK dependency).""" @@ -379,15 +382,45 @@ class CodexAgentConfig(BaseAgentConfig): tool_output_token_limit: int | None = Field( default=10_000, - gt=0, + ge=1_024, + le=1_000_000, description=( "Cap, in tokens, on each tool output Codex shows the model, passed as Codex's " "tool_output_token_limit. The default is the cap Codex gives the models in its own " "catalog; without it, a model the catalog does not know gets a much smaller fallback " - "cap (10,000 bytes). None leaves Codex's own per-model default." + "cap (10,000 bytes). Command output is also capped by the exec tool's own per-call " + "limit (10000 tokens unless the model asks for more), so a higher value applies in " + "full only to MCP and other tool outputs. None leaves Codex's own per-model default." ), ) + # Codex's exec tool caps each command output at the per-call max_output_tokens the model may + # pass, 10000 tokens when it passes none; no Codex config key raises that default. + _exec_output_token_ceiling: ClassVar[int] = 10_000 + + @field_validator("tool_output_token_limit", mode="before") + @classmethod + def _reject_bool_tool_output_token_limit(cls, value: object) -> object: + """Reject a bool, which would otherwise load as 0 or 1 (a YAML ``yes``).""" + if isinstance(value, bool): + raise ValueError("tool_output_token_limit must be a number of tokens or null, not a boolean") + return value + + @model_validator(mode="after") + def warn_tool_output_token_limit_above_exec_ceiling(self) -> Self: + """Warn that a cap above the exec ceiling does not widen command output on its own.""" + ceiling = type(self)._exec_output_token_ceiling + if self.tool_output_token_limit is not None and self.tool_output_token_limit > ceiling: + logger.warning( + "tool_output_token_limit %d is above %d: Codex still caps command output at %d tokens " + + "unless the model asks for more in the call; the value applies in full to MCP and " + + "other tool outputs.", + self.tool_output_token_limit, + ceiling, + ceiling, + ) + return self + def egress_hosts(self, env: Mapping[str, str]) -> tuple[str, ...]: """The ``CODEX_BASE_URL`` host when it is forwarded, else ``api.openai.com``. diff --git a/tests/test_codex_tool_output_cap.py b/tests/test_codex_tool_output_cap.py index 80fc02e8..57bddf55 100644 --- a/tests/test_codex_tool_output_cap.py +++ b/tests/test_codex_tool_output_cap.py @@ -2,6 +2,7 @@ from __future__ import annotations +import logging from typing import Any import pytest @@ -38,10 +39,31 @@ def test_none_leaves_the_codex_default(self): class TestConfig: - @pytest.mark.parametrize("limit", [0, -1]) - def test_a_non_positive_cap_fails_at_load(self, limit): - with pytest.raises(ValidationError): + @pytest.mark.parametrize("limit", [0, -1, 10, 1_023, 1_000_001, True, False]) + def test_a_cap_out_of_range_or_a_bool_fails_at_load(self, limit): + with pytest.raises(ValidationError, match="tool_output_token_limit"): + parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=limit) + + @pytest.mark.parametrize("limit", [1_024, 1_000_000]) + def test_the_bounds_load(self, limit): + assert ( + parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=limit).model_dump()[ + "tool_output_token_limit" + ] + == limit + ) + + def test_a_cap_above_the_exec_ceiling_warns(self, caplog): + with caplog.at_level(logging.WARNING, logger="coder_eval.models.agent_config"): + config = parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=50_000) + assert config.model_dump()["tool_output_token_limit"] == 50_000 + assert any("still caps command output at 10000" in r.getMessage() for r in caplog.records) + + @pytest.mark.parametrize("limit", [None, 5_000, 10_000]) + def test_a_cap_at_or_below_the_exec_ceiling_does_not_warn(self, caplog, limit): + with caplog.at_level(logging.WARNING, logger="coder_eval.models.agent_config"): parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=limit) + assert not any("tool_output_token_limit" in r.getMessage() for r in caplog.records) def test_another_harness_rejects_the_field(self): with pytest.raises(ValidationError): @@ -61,7 +83,7 @@ def test_yaml_null_survives_the_merge(self): assert resolved is not None assert resolved.model_dump()["tool_output_token_limit"] is None - @pytest.mark.parametrize(("raw", "expected"), [("20000", 20_000), ("null", None)]) + @pytest.mark.parametrize(("raw", "expected"), [("5000", 5_000), ("null", None)]) def test_a_cli_override_sets_the_cap(self, raw, expected): task = _task({"type": "codex"}) apply_overrides(task, dict([parse_override(f"agent.tool_output_token_limit={raw}")])) From 886551daa935001a3447840fbcb5ea92440a30b7 Mon Sep 17 00:00:00 2001 From: CarlesUIPath Date: Tue, 24 Nov 2026 21:17:14 +0000 Subject: [PATCH 3/5] fix(codex): warn about the exec ceiling at agent start The exec-ceiling advisory was a logger.warning in a models/ validator, so it fired again on every reload of a record (report, evaluate, resume) with no task context. Move it to CodexAgent._log_config_enforcement, which runs once per start on the task-prefixed logger. Drop the bool validator: ge=1024 already rejects True and False. Say in the field description that null defers to $CODEX_HOME/config.toml first. Tests: the warning fires at start and not at load, an out-of-range -D override reads as a clean OverrideError, the other-harness rejection names the field, and a variant that switches away from codex neither keeps a set cap nor inherits the default. Co-Authored-By: Claude Opus 5.5 --- docs/agents/CODEX.md | 2 +- src/coder_eval/agents/codex_agent.py | 11 ++++ src/coder_eval/models/agent_config.py | 33 +----------- tests/test_codex_tool_output_cap.py | 72 +++++++++++++++++++++------ 4 files changed, 71 insertions(+), 47 deletions(-) diff --git a/docs/agents/CODEX.md b/docs/agents/CODEX.md index 1adaba70..7b5750a1 100644 --- a/docs/agents/CODEX.md +++ b/docs/agents/CODEX.md @@ -214,7 +214,7 @@ Command output has a second cap. The exec tool cuts it to the `max_output_tokens may pass in each call, 10000 tokens when the model passes none, and no Codex config key raises that default. Command output is therefore capped at the smaller of the two, so a value above `10000` widens it only in calls where the model asks for more; it applies in full to MCP -and other tool outputs. Such a value logs a warning when the config loads. +and other tool outputs. Such a value logs a warning when the agent starts. The value overrides a `tool_output_token_limit` in `$CODEX_HOME/config.toml`. Set it to `null` to let that host value, or else the Codex default for the model, apply. Override it diff --git a/src/coder_eval/agents/codex_agent.py b/src/coder_eval/agents/codex_agent.py index 95ab7d84..b90b297b 100644 --- a/src/coder_eval/agents/codex_agent.py +++ b/src/coder_eval/agents/codex_agent.py @@ -88,6 +88,10 @@ # routes to a custom endpoint. _CUSTOM_PROVIDER_ID = "custom" +# Codex's exec tool caps each command output at the per-call max_output_tokens the model may +# pass, 10000 tokens when it passes none; no Codex config key raises that default. +_EXEC_OUTPUT_TOKEN_CEILING = 10_000 + # apply_patch statuses meaning the patch did not apply. Used ONLY to classify the # Write telemetry honestly, never to fail or retry the turn: "declined" needs an # approval reviewer, which no permission mode configures, and "failed" (a diff @@ -1808,6 +1812,13 @@ def _log_config_enforcement(self) -> None: self._log.debug(f"Disallowed tools: {', '.join(self.config.disallowed_tools)}") self._log.debug(f"Permission mode: {self.config.permission_mode.value}") + limit = self.config.tool_output_token_limit + if limit is not None and limit > _EXEC_OUTPUT_TOKEN_CEILING: + self._log.warning( + f"tool_output_token_limit {limit} is above {_EXEC_OUTPUT_TOKEN_CEILING}: Codex still caps " + + f"command output at {_EXEC_OUTPUT_TOKEN_CEILING} tokens unless the model asks for more in " + + "the call; the value applies in full to MCP and other tool outputs." + ) # Fires for EVERY mode, not just bypassPermissions, so operators are not # misled that plan/acceptEdits/default confine Codex — none of them do. self._log.warning( diff --git a/src/coder_eval/models/agent_config.py b/src/coder_eval/models/agent_config.py index 339f7b7a..65734894 100644 --- a/src/coder_eval/models/agent_config.py +++ b/src/coder_eval/models/agent_config.py @@ -3,7 +3,6 @@ from __future__ import annotations import dataclasses -import logging from collections.abc import Mapping from typing import Annotated, Any, ClassVar, Literal, Self, TypedDict @@ -24,8 +23,6 @@ from coder_eval.models.sandbox import url_egress_target -logger = logging.getLogger(__name__) - type SettingSource = Literal["user", "project", "local"] """Vendor-neutral mirror of claude_agent_sdk.SettingSource (no SDK dependency).""" @@ -390,37 +387,11 @@ class CodexAgentConfig(BaseAgentConfig): "catalog; without it, a model the catalog does not know gets a much smaller fallback " "cap (10,000 bytes). Command output is also capped by the exec tool's own per-call " "limit (10000 tokens unless the model asks for more), so a higher value applies in " - "full only to MCP and other tool outputs. None leaves Codex's own per-model default." + "full only to MCP and other tool outputs. None leaves the tool_output_token_limit in the " + "host $CODEX_HOME/config.toml, or else Codex's own per-model default." ), ) - # Codex's exec tool caps each command output at the per-call max_output_tokens the model may - # pass, 10000 tokens when it passes none; no Codex config key raises that default. - _exec_output_token_ceiling: ClassVar[int] = 10_000 - - @field_validator("tool_output_token_limit", mode="before") - @classmethod - def _reject_bool_tool_output_token_limit(cls, value: object) -> object: - """Reject a bool, which would otherwise load as 0 or 1 (a YAML ``yes``).""" - if isinstance(value, bool): - raise ValueError("tool_output_token_limit must be a number of tokens or null, not a boolean") - return value - - @model_validator(mode="after") - def warn_tool_output_token_limit_above_exec_ceiling(self) -> Self: - """Warn that a cap above the exec ceiling does not widen command output on its own.""" - ceiling = type(self)._exec_output_token_ceiling - if self.tool_output_token_limit is not None and self.tool_output_token_limit > ceiling: - logger.warning( - "tool_output_token_limit %d is above %d: Codex still caps command output at %d tokens " - + "unless the model asks for more in the call; the value applies in full to MCP and " - + "other tool outputs.", - self.tool_output_token_limit, - ceiling, - ceiling, - ) - return self - def egress_hosts(self, env: Mapping[str, str]) -> tuple[str, ...]: """The ``CODEX_BASE_URL`` host when it is forwarded, else ``api.openai.com``. diff --git a/tests/test_codex_tool_output_cap.py b/tests/test_codex_tool_output_cap.py index 57bddf55..ad3ae8df 100644 --- a/tests/test_codex_tool_output_cap.py +++ b/tests/test_codex_tool_output_cap.py @@ -1,4 +1,10 @@ -"""``agent.tool_output_token_limit``: an explicit Codex tool-output cap, not one from Codex's model catalog.""" +"""``agent.tool_output_token_limit``: an explicit Codex tool-output cap, not one from Codex's model catalog. + +These tests stop at the thread ``config`` coder_eval builds. The openai_codex SDK passes that dict +through unchecked, and the stub app-server in test_codex_provider_binary.py does not report the +effective config or truncate tool output, so a Codex release that renamed or dropped the key +would go unnoticed here. +""" from __future__ import annotations @@ -10,15 +16,18 @@ from coder_eval.models import AgentKind, TaskDefinition, parse_agent_config from coder_eval.orchestration.config_merge import Layer, resolve_root -from coder_eval.orchestration.overrides import apply_overrides, parse_override +from coder_eval.orchestration.overrides import OverrideError, apply_overrides, parse_override -def _thread_config(**config_kwargs: Any) -> dict[str, Any]: +def _agent(**config_kwargs: Any) -> Any: pytest.importorskip("openai_codex") from coder_eval.agents.codex_agent import CodexAgent - agent = CodexAgent(parse_agent_config(type=AgentKind.CODEX, model="example-model", **config_kwargs)) - return agent._build_thread_options().get("config", {}) + return CodexAgent(parse_agent_config(type=AgentKind.CODEX, model="example-model", **config_kwargs)) + + +def _thread_config(**config_kwargs: Any) -> dict[str, Any]: + return _agent(**config_kwargs)._build_thread_options().get("config", {}) def _task(agent: dict[str, Any]) -> TaskDefinition: @@ -38,6 +47,22 @@ def test_none_leaves_the_codex_default(self): assert "tool_output_token_limit" not in _thread_config(tool_output_token_limit=None) +class TestStartWarning: + def test_a_cap_above_the_exec_ceiling_warns_when_the_agent_starts(self, caplog): + agent = _agent(tool_output_token_limit=50_000) + caplog.clear() + with caplog.at_level(logging.WARNING, logger="coder_eval.agents.codex_agent"): + agent._log_config_enforcement() + assert any("still caps command output at 10000" in r.getMessage() for r in caplog.records) + + @pytest.mark.parametrize("limit", [None, 5_000, 10_000]) + def test_a_cap_at_or_below_the_exec_ceiling_does_not_warn(self, caplog, limit): + agent = _agent(tool_output_token_limit=limit) + with caplog.at_level(logging.WARNING, logger="coder_eval.agents.codex_agent"): + agent._log_config_enforcement() + assert not any("tool_output_token_limit" in r.getMessage() for r in caplog.records) + + class TestConfig: @pytest.mark.parametrize("limit", [0, -1, 10, 1_023, 1_000_001, True, False]) def test_a_cap_out_of_range_or_a_bool_fails_at_load(self, limit): @@ -53,20 +78,14 @@ def test_the_bounds_load(self, limit): == limit ) - def test_a_cap_above_the_exec_ceiling_warns(self, caplog): - with caplog.at_level(logging.WARNING, logger="coder_eval.models.agent_config"): + def test_loading_a_cap_above_the_exec_ceiling_does_not_warn(self, caplog): + with caplog.at_level(logging.WARNING): config = parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=50_000) - assert config.model_dump()["tool_output_token_limit"] == 50_000 - assert any("still caps command output at 10000" in r.getMessage() for r in caplog.records) - - @pytest.mark.parametrize("limit", [None, 5_000, 10_000]) - def test_a_cap_at_or_below_the_exec_ceiling_does_not_warn(self, caplog, limit): - with caplog.at_level(logging.WARNING, logger="coder_eval.models.agent_config"): - parse_agent_config(type=AgentKind.CODEX, tool_output_token_limit=limit) + parse_agent_config(**config.model_dump()) assert not any("tool_output_token_limit" in r.getMessage() for r in caplog.records) def test_another_harness_rejects_the_field(self): - with pytest.raises(ValidationError): + with pytest.raises(ValidationError, match="tool_output_token_limit"): parse_agent_config(type=AgentKind.CLAUDE_CODE, tool_output_token_limit=10_000) def test_the_run_records_the_default(self): @@ -83,9 +102,32 @@ def test_yaml_null_survives_the_merge(self): assert resolved is not None assert resolved.model_dump()["tool_output_token_limit"] is None + def test_a_variant_switching_away_from_codex_rejects_a_set_cap(self): + with pytest.raises(ValidationError, match="tool_output_token_limit"): + resolve_root( + "agent", + [ + Layer(source="task", patch={"type": "codex", "tool_output_token_limit": 20_000}), + Layer(source="variant", patch={"type": "claude-code"}), + ], + ) + + def test_a_variant_switching_away_from_codex_does_not_inherit_the_default(self): + resolved = resolve_root( + "agent", + [Layer(source="task", patch={"type": "codex"}), Layer(source="variant", patch={"type": "claude-code"})], + ) + assert resolved is not None + assert "tool_output_token_limit" not in resolved.model_dump() + @pytest.mark.parametrize(("raw", "expected"), [("5000", 5_000), ("null", None)]) def test_a_cli_override_sets_the_cap(self, raw, expected): task = _task({"type": "codex"}) apply_overrides(task, dict([parse_override(f"agent.tool_output_token_limit={raw}")])) assert task.agent is not None assert task.agent.model_dump()["tool_output_token_limit"] == expected + + def test_a_cli_override_out_of_range_reads_as_a_clean_error(self): + task = _task({"type": "codex"}) + with pytest.raises(OverrideError, match=r"-D agent\.tool_output_token_limit: .*greater than or equal to 1024"): + apply_overrides(task, dict([parse_override("agent.tool_output_token_limit=10")])) From d9974d9e8c99120d86ca00d21385dd5359c7124a Mon Sep 17 00:00:00 2001 From: CarlesUIPath Date: Tue, 24 Nov 2026 19:04:44 +0000 Subject: [PATCH 4/5] docs: point the task guide at agent.tool_output_token_limit Co-Authored-By: Claude Opus 5.5 --- docs/TASK_DEFINITION_GUIDE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/TASK_DEFINITION_GUIDE.md b/docs/TASK_DEFINITION_GUIDE.md index 8c948156..1153735c 100644 --- a/docs/TASK_DEFINITION_GUIDE.md +++ b/docs/TASK_DEFINITION_GUIDE.md @@ -207,6 +207,10 @@ types accept it, in what range, what each does with it and what an unset value m [Run-Limit Parity](agents/HARNESS_PARITY.md#the-context-window-cap-per-harness). An agent type that cannot apply it rejects it at load. +**`tool_output_token_limit`** (codex only, default `10000`) caps, in tokens, each tool +output Codex shows the model. Override via CLI with `-D agent.tool_output_token_limit=5000`. +See [Codex](agents/CODEX.md#tool-output-cap). + **Permission Modes:** - `default` — Default permission handling - `acceptEdits` — Auto-accept file edits (recommended for evaluations) From 6e2a90134f1ee650308e2801730ba0850490160b Mon Sep 17 00:00:00 2001 From: CarlesUIPath Date: Tue, 24 Nov 2026 21:17:14 +0000 Subject: [PATCH 5/5] docs(codex): note that pre-cap records reload with the 10000 default Records from before tool_output_token_limit existed have no such key and reload with the field default, which those runs did not have: Codex then applied its own default (10000 tokens in its catalog, 10,000 bytes outside it). Say so where the cap is described, so trend lines across this commit are read with that in mind, instead of rewriting legacy records on reload. Co-Authored-By: Claude Opus 5.5 --- docs/agents/CODEX.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/agents/CODEX.md b/docs/agents/CODEX.md index 7b5750a1..47e6f280 100644 --- a/docs/agents/CODEX.md +++ b/docs/agents/CODEX.md @@ -220,11 +220,10 @@ The value overrides a `tool_output_token_limit` in `$CODEX_HOME/config.toml`. Se `null` to let that host value, or else the Codex default for the model, apply. Override it per run with `-D agent.tool_output_token_limit=5000`. -Codex runs from before this option existed ran with the Codex default, so for a model outside -the catalog each command output grew from 10,000 bytes to about 40 KB: those runs are not -comparable with later ones. Their rows have no `tool_output_token_limit` key in -`agent_config`, and a re-load (`evaluate`, resume, reports) fills in the default `10000`, -which those runs did not have. +Records written before this change reload with `tool_output_token_limit` `10000` (the field +default). Before this change Codex applied its own default (10000 tokens for catalog models, +10,000 bytes for models outside its bundled catalog such as `gpt-6.1-sol`), so compare trend +lines across this commit with that in mind. ### Skills Discovery