Skip to content

feat(codex): pin an explicit tool output cap, default 10000 tokens - #267

Merged
CarlesUIPath merged 5 commits into
mainfrom
fix/codex-tool-output-cap
Nov 24, 2026
Merged

CarlesUIPath merged 5 commits into
mainfrom
fix/codex-tool-output-cap

Conversation

@CarlesUIPath

@CarlesUIPath CarlesUIPath commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

Codex agent runs now pass an explicit tool_output_token_limit (new CodexAgentConfig field, default 10000 tokens) in the thread-start config, the same path model_context_window uses.

Why

Codex sizes tool output from its bundled model catalog: catalog models get {mode: tokens, limit: 10000} (~40 KB). A model that matches no catalog slug falls back to a 10,000-byte policy, a quarter of that. With no explicit value, results silently depend on whether the run's model is in the installed codex's catalog. Observed effect: an agent reading a 41.6 KB skill file saw only its head and tail and re-read the middle in slices; more than half of its commands were skill re-reads.

Behaviour

  • Exec command output is capped at min(this value, the per-call max_output_tokens the model may pass, default 10000 = codex's DEFAULT_MAX_OUTPUT_TOKENS, not configurable). Values above 10000 only widen MCP / extension tool results and exec calls where the model asks for more; the agent logs a warning at start when the value is above 10000. Records written before this change reload showing the 10000 default (docs/agents/CODEX.md).
  • null sends nothing: codex's own default, or a host $CODEX_HOME/config.toml value, applies. The default overrides a host config value (documented in CODEX.md and HARNESS_PARITY.md).
  • Validation: 1024 ≤ value ≤ 1,000,000; booleans rejected.
  • Recorded in each codex row's agent_config.

Impact on existing runs

  • Models in codex's catalog: no change (the default equals their catalog value; now pinned so a catalog change cannot move it).
  • Models outside the catalog: per-command output grows from 10,000 bytes to ~40 KB. Codex runs before and after this change are not comparable for those models. Old rows without the key re-load with the default (documented).
  • Downstream readers checked: the nightly runner passes agent_config through; the evalboard reads only agent_config.type.

Checks

ruff format/check clean; pyright 0 errors; codex tests 298 passed; full suite (CI-equivalent env) 7059 passed earlier. Reviewed twice (findings fixed in the second commit).

🤖 Generated with Claude Code

CarlesUIPath and others added 2 commits November 24, 2026 13:09
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Claude finished @CarlesUIPath's task in 1m 25s —— View job


Code Review in Progress

Review Checklist:

  • Read .github/code_review.md for review standards
  • Read CLAUDE.md for project conventions
  • Get full PR diff with git diff origin/main...HEAD
  • Review each changed file with full context:
    • docs/agents/CODEX.md
    • docs/agents/HARNESS_PARITY.md
    • src/coder_eval/agents/codex_agent.py
    • src/coder_eval/models/agent_config.py
    • tests/test_codex_tool_output_cap.py
  • Check cross-file consistency
  • Perform "what's missing" analysis
  • Provide design-level scrutiny

@uipreliga uipreliga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: feat(codex): pin an explicit tool output cap, default 10000 tokens

PR #267 by CarlesUIPath · fix/codex-tool-output-cap → main · OPEN · reviewed against ccee881 · Scope: pr:267 (5 files) axis:1,2,3,4,5,6,7,8 · branch pr-267 (fix/codex-tool-output-cap → main) · ccee881 · 2026-11-24T16:56Z · workflow variant

Change class: complex — adds a validated public config field whose default changes the Codex tool-output cap (and overrides host config) for every Codex run

PR #267 is in good condition: it pins the Codex tool output cap at 10000 tokens with correct bounds, clean CLI override errors and no security or harness problems, and no finding can change a task's score or final_status for identical agent output; the real risks are a load-time warning in a models/ validator that fires again on every reload, and a model default that makes reloaded pre-PR Codex records report a cap they did not run with, so fix these two before merge and treat the rest as small test and doc follow-ups.

Summary

Axis Score 🔴 🟠 🟡 🔵 Top Issue
1. Code Quality & Style 9.9 / 10 0 0 0 1 The bool-rejection validator on tool_output_token_limit duplicates the ge=1_024 bound (and the ceiling ClassVar is a single-use hook); the test cannot tell the two apart
2. Type Safety 10 / 10 0 0 0 0 —
3. Test Health 9.7 / 10 0 0 0 3 The tests check only the dict coder_eval builds. No test shows that the bundled codex binary uses the tool_output_token_limit thread-config key.
4. Security 10 / 10 0 0 0 0 —
5. Architecture & Design 9.5 / 10 0 0 1 0 Codex exec-ceiling advisory is a logging side effect in a models/ validator: it repeats on every validation, has no task context, and bypasses the agent's advisory hook
6. Error Handling & Resilience 10 / 10 0 0 0 0 —
7. API Surface & Maintainability 9.4 / 10 0 0 1 1 The model default of 10_000 makes reloaded legacy Codex records report and re-persist a tool_output_token_limit they did not run with
8. Evaluation Harness Quality 10 / 10 0 0 0 0 —

Overall Score: 9.8 / 10 · Weakest Axis: API Surface & Maintainability at 9.4 / 10
Totals: 🔴 0 · 🟠 0 · 🟡 2 · 🔵 5 across 8 axes.

Blockers

None.

Non-blocking, but please consider before merge

  1. [Axis 5] Codex exec-ceiling advisory is a logging side effect in a models/ validator: it repeats on every validation, has no task context, and bypasses the agent's advisory hook (src/coder_eval/models/agent_config.py:410) — The PR adds logger = logging.getLogger(__name__) (line 27) and a model validator def warn_tool_output_token_limit_above_exec_ceiling(self) -> Self: (line 410), which calls logger.warning("tool_output_token_limit %d is above %d: Codex still caps command output ...") (line 414). models/ is the pure-Pydantic layer. It already holds two load-time advisories, and both use warnings.warn: validate_template_sources in models/sandbox.py and the unknown-field check in models/tasks.py. Python's default warning filter shows such a warning once per location. A logger.warning gets no such de-duplication. The only other logger.warning in models/ is in url_egress_target, which runs at egress resolution, not inside a validator.

The agent's ResolvedAgentConfig re-validates CodexAgentConfig (through _coerce_agent_config → parse_agent_config) every time a persisted agent_config loads: report, evaluate, resume, and the batch reload of task.json. So the warning fires again on each reload.

Measured on the PR head:

  • One parse_agent_config(type="codex", tool_output_token_limit=20000) call emits 1 warning. Five dump/reload round-trips bring the total to 6.
  • coder-eval plan on one Codex task with the value set to 20000 emits it 2 times.
  • So an N-row dataset run repeats it at least N times on every report or evaluate pass. It warns about a past run that the user cannot change any more.

The Codex agent already has the right seam for 'this knob does less than you think' advisories. CodexAgent._log_config_enforcement() (codex_agent.py:1802, called once per start at line 1124) and the disallowed_tools warning in _build_options both use the task-prefixed self._log (PrefixedAdapter, line 1069). The new advisory skips that seam, so the warning is also not linked to its task in per-task logs.

Fix: delete the model validator and the module logger. Move the check into _log_config_enforcement as a self._log.warning(...) next to the existing permission-mode warning, or into _build_options next to the tool_config["tool_output_token_limit"] assignment (codex_agent.py:1794-1795). Keep the field bounds and the bool-rejecting field_validator in the model, because they are real validation. Then update docs/agents/CODEX.md:217 ("Such a value logs a warning when the config loads.") to say the warning fires when the agent starts.
2. [Axis 7] The model default of 10_000 makes reloaded legacy Codex records report and re-persist a tool_output_token_limit they did not run with (src/coder_eval/models/agent_config.py:384) — tool_output_token_limit: int | None = Field(default=10_000, ...) is a Pydantic default, so every pre-PR Codex task.json that is loaded again through ResolvedAgentConfig comes back with tool_output_token_limit=10000. That value was never sent to Codex. CODEX.md:226 admits this ("a re-load (evaluate, resume, reports) fills in the default 10000, which those runs did not have"). It does not say that coder-eval evaluate <old_run> then saves the false value to disk permanently: _write_back calls write_text_atomic(target, result.model_dump_json(...)) (evaluate_command.py:638). After that, the record itself carries the wrong value for downstream consumers (eval-runner, evalboard, run.json via run_record.py:181 result.agent_config.model_dump()). The resume fingerprint (batch.py compute_run_fingerprint, a BatchRunConfig dump) does not cover per-task agent config, so resuming a pre-upgrade run also mixes the old and new caps under one recorded value. This is a cross-repo contract issue: the persisted record now reports a config that did not run. Recommended fix (open question on mechanism): keep the model default None so a legacy record loads truthfully as 'Codex default', and stamp 10000 only on newly resolved configs, for example in the default layer of orchestration/config_merge.py or at task resolution. Then new runs record the pinned value and old runs stay as they were. If the trade-off is kept as it is, at minimum say in CODEX.md that evaluate rewrites task.json with the filled-in value.

Nits

  1. [Axis 1] The bool-rejection validator on tool_output_token_limit duplicates the ge=1_024 bound (and the ceiling ClassVar is a single-use hook); the test cannot tell the two apart (src/coder_eval/models/agent_config.py:401) — _reject_bool_tool_output_token_limit (lines 401-407: if isinstance(value, bool): raise ValueError("tool_output_token_limit must be a number of tokens or null, not a boolean")) guards against something the field constraint already rejects. With ge=1_024, True (1) and False (0) both fail: a probe of x: int | None = Field(default=10_000, ge=1_024) rejects both with Input should be greater than or equal to 1024 [type=greater_than_equal, input_value=True, input_type=bool]. The validator's docstring says a bool 'would otherwise load as 0 or 1', but it would not load. The same class already uses the bound for this on its sibling field: the _context_window_range comment says 'The floor rejects a window too small to work in, such as ... a YAML yes that loads as 1'. There is one small gain: the error message is clearer. Either delete the validator and keep True, False in the out-of-range parametrize, or keep it and make the test assert its specific message. Today test_a_cap_out_of_range_or_a_bool_fails_at_load in tests/test_codex_tool_output_cap.py matches only "tool_output_token_limit", so the test passes with or without the validator and does not pin it.
  2. [Axis 3] The tests check only the dict coder_eval builds. No test shows that the bundled codex binary uses the tool_output_token_limit thread-config key. (tests/test_codex_tool_output_cap.py:31) — TestThreadOptions (lines 31-38) checks only the options that _build_thread_options() returns, for example assert _thread_config()["tool_output_token_limit"] == 10_000. These tests restate the 3-line branch at codex_agent.py:1794-1795 (tool_config["tool_output_token_limit"] = self.config.tool_output_token_limit). The openai_codex SDK passes config on as a plain dict and does not check it. Codex reads ConfigToml through serde, so if a CLI bump renames or drops the key, Codex can ignore it with no error. A run would then record tool_output_token_limit: 10000 in agent_config but use Codex's per-model default, which is the comparability problem that CODEX.md says this PR fixes. The existing integration test tests/test_codex_provider_binary.py sends the production thread options to the real binary, so it catches a hard rejection, but not a key that Codex ignores. Recommendation: add a binary-contract test. One way: start a thread through the stub app-server and read back the effective config, if the app-server exposes it. Another way: make the stub return a tool output that is larger than a small cap (for example 1024) and assert that the next request is truncated. If the app-server cannot show this, record that boundary in the test module docstring.
  3. [Axis 3] The new field's out-of-range CLI override (OverrideError) has no test. The parallel context_window suite tests this case. (tests/test_codex_tool_output_cap.py:86) — test_a_cli_override_sets_the_cap (lines 86-91) tests only the valid values ("5000", 5_000), ("null", None). The parallel suite tests/test_agent_context_window.py has test_a_cli_override_out_of_range_reads_as_a_clean_error, which asserts pytest.raises(OverrideError, match=r"-D agent: .*out of range"). A probe confirms that the new field produces a clean error now: OverrideError -D agent.tool_output_token_limit: Input should be greater than or equal to 1024 (got 10). No test pins this. Add a parametrized case, for example apply_overrides(task, dict([parse_override("agent.tool_output_token_limit=10")])) under pytest.raises(OverrideError, match="tool_output_token_limit"), so that the -D user path for bad values stays covered.
  4. [Axis 3] test_another_harness_rejects_the_field passes on any ValidationError because it has no match (tests/test_codex_tool_output_cap.py:69) — Lines 68-70: with pytest.raises(ValidationError): / parse_agent_config(type=AgentKind.CLAUDE_CODE, tool_output_token_limit=10_000). This has no match=, but the same class uses match="tool_output_token_limit" at line 44. If Claude Code config validation fails for some other reason, the test still passes. It would then not show that the Codex-only field is rejected on another harness. Add match="tool_output_token_limit" (Pydantic's extra_forbidden error names the field).
  5. [Axis 7] Field description for None omits the $CODEX_HOME/config.toml precedence that the docs state (src/coder_eval/models/agent_config.py:393) — The description ends with "None leaves Codex's own per-model default.". CODEX.md:219-220 states the actual contract: "Set it to null to let that host value [$CODEX_HOME/config.toml], or else the Codex default for the model, apply". The code supports the docs: _codex_home() resolves the host ~/.codex, and the field is omitted from the thread config when None. The Pydantic description is the SSOT for the field, so update it to say that None defers first to the host $CODEX_HOME/config.toml tool_output_token_limit and then to Codex's per-model default. Otherwise a user who reads the schema text cannot predict that a host setting leaks into null runs.

What's Missing

Display & mapping dicts:

  • 🔵 The run.md and HTML 'Agent Settings' table does not show the new knob. collect_agent_settings_rows (reports/markdown.py), with resolve_context_window and html.py:1036, adds a 'Context Window' row from agent_config. It has no 'Tool Output Cap' row for tool_output_token_limit. CODEX.md says that runs with different values (or with the pre-PR Codex default) are not comparable, but a reader of a report cannot see which cap a run used without opening task.json. Add the row next to Context Window, and add a test that asserts the row is present. (trigger: src/coder_eval/models/agent_config.py)

Tests:

  • 🔵 CODEX.md documents the legacy-reload behaviour: a pre-PR Codex agent_config with no tool_output_token_limit key loads through ResolvedAgentConfig as 10000. No test pins it. Add a test that loads a pre-PR-shaped EvaluationResult/task.json dict without the key and asserts the resulting value. Then a later fix (for example, a None model default with 10000 stamped at resolution) breaks a test, not just a doc sentence. (trigger: docs/agents/CODEX.md) (restates: Axis 7: The model default of 10_000 makes reloaded legacy Codex records report and re-persist a tool_output_token_limit they did not run with)

Parallel paths:

  • 🔵 docs/TASK_DEFINITION_GUIDE.md § Agent Configuration is the authoritative task-YAML reference. Its example agent: block and its prose list context_window with the harnesses that accept it. The new Codex-only tool_output_token_limit is in CODEX.md and HARNESS_PARITY.md only. It is the first Codex-only user-authored field on CodexAgentConfig. A task author who reads the guide does not find it. Add an optional line to the example block, for example tool_output_token_limit: 10000 # codex only, and a one-line pointer to CODEX.md#tool-output-cap. (trigger: src/coder_eval/models/agent_config.py)

Nightly pipeline:

  • 🔵 The PR body says that the nightly runner passes agent_config through and that the evalboard reads only type. It does not say what happens to a Codex nightly run that is in progress or already finished across the upgrade. --resume does not fingerprint per-task agent config, so the resumed rows run with the new cap while the old rows ran with the catalog or fallback cap, all under one recorded value of 10000. A detached evaluate writes 10000 back into task.json and run.json. For out-of-catalog models, the nightly trend lines change at this commit. Add a sentence to the PR or CHANGELOG to tell nightly consumers about this break in the series. (trigger: src/coder_eval/agents/codex_agent.py) (restates: Axis 7: The model default of 10_000 makes reloaded legacy Codex records report and re-persist a tool_output_token_limit they did not run with)

Harness & Lint Improvements

Static checks (lint / type):

  • [ce-lint] New rule CE072 no-logging-in-pydantic-validator. Scope: the whole src/coder_eval/ tree, not only models/. The rule forbids a call whose receiver is named logger, logging, log or _log (.debug/.info/.warning/.error/.exception) inside a function decorated model_validator or field_validator. A validator runs again every time a persisted record re-validates (ResolvedAgentConfig → _coerce_agent_config → parse_agent_config on report, evaluate, resume and batch reload), so a log call there repeats with no task context. The message tells the author either to use warnings.warn, which de-duplicates per location (models/tasks.py:690 and models/sandbox.py:100 already do this), or to move the advisory to the agent's self._log seam (CodexAgent._log_config_enforcement). Put the file at tests/lint/rules/no_logging_in_validator.py. Add it to ALL_RULES in tests/lint/runner.py, add CE072 to external in pyproject [tool.ruff.lint], and add a TestCE072... class in tests/test_custom_lint.py. Correct the stale 'Claim 069 next' comment in the runner, because 069 and 071 are taken and 070 is the only gap. Before you claim 072, check grep -E '^class Test(CE[0-9]{3})' tests/test_custom_lint.py for in-flight branches. I ran an AST probe of this pattern (tmp/probe_validator_log.py). It finds 0 hits on main across all of src/ and exactly 1 hit on the PR head (src/coder_eval/models/agent_config.py:414, warn_tool_output_token_limit_above_exec_ceiling). The rule therefore lands with zero suppressions. Known blind spot: a validator that calls a helper which then logs. To cover that, follow same-module calls one level deep. Prevents: The A5 medium finding (agent_config.py:410/414): the Codex exec-ceiling advisory is a logger.warning inside a models/ model_validator. It fired 6 times over 5 dump/reload round-trips and 2 times on one coder-eval plan, and it bypasses the agent's task-prefixed advisory seam. The finding is also grouped under A1, A6, A7 and A8 at agent_config.py:409 and :414.
  • [ruff] Add PT011 to [tool.ruff.lint] select and set [tool.ruff.lint.flake8-pytest-style] raises-require-match-for = ["pydantic.ValidationError", "pydantic_core.ValidationError", "*.OverrideError", "ValueError", "Exception", "BaseException", "OSError"]. Ruff matches on qualified names, so the bare name "ValidationError" does NOT match from pydantic import ValidationError. You must use pydantic.ValidationError. I checked this with ruff 0.15.8. On the PR head the setting flags exactly tests/test_codex_tool_output_cap.py:69:28 PT011 pytest.raises(pydantic.ValidationError) is too broad. Across tests/ it flags 58 existing sites for the pydantic names alone. To adopt it, fix those sites or add # noqa: PT011 to each in the same change, so that new code is gated from the start. Prevents: The A3 low finding at tests/test_codex_tool_output_cap.py:69: test_another_harness_rejects_the_field uses pytest.raises(ValidationError) with no match=, so any ValidationError makes it pass. It also stops the same shape in future tests. It does not catch a match= that is present but too weak to tell two error paths apart, which is the A1 bool-validator test-pinning half (see the harness bucket).

Harness improvements (not statically reachable):

  • Add a generic bounds-coverage test for every agent-config field that has bounds. Iterate the model_fields of every registered BaseAgentConfig subclass. For each field whose metadata has Ge/Le (or a _context_window_range-style ClassVar), apply apply_overrides(task, dict([parse_override(f"agent.{name}={below_floor}")])) and assert OverrideError with match=name. Also assert that direct parse_agent_config(...) with True/False/below-floor/above-ceiling raises ValidationError with match=name. A new bounded field is then covered on the -D path and the load path without a hand-written case for each field. Why not static: It must run Pydantic validation and the override parser to show that the bad value comes back as a clean OverrideError rather than a traceback. An AST check can see that a bound exists, but not that the CLI path turns the violation into a user error. Prevents: The A3 low finding at tests/test_codex_tool_output_cap.py:86: the out-of-range -D agent.tool_output_token_limit=10 path has no test, but the parallel context_window suite tests it.
  • Add a persisted-default snapshot test with a legacy-record round-trip. Commit a JSON snapshot of {model: {field: default}} for every config model that a persisted record carries (ResolvedAgentConfig members, and the task.json/run.json agent_config surface), plus one frozen pre-change Codex task.json fixture for each AgentKind. The test fails when a new field arrives with a non-None default, or when a default changes, until the author updates the snapshot. It also asserts that reloading each legacy fixture (EvaluationResult.model_validate → model_dump) does not add keys the fixture lacked, or that each added key is on an explicit 'materialized-on-reload' allowlist that names the doc which admits it. This makes the 'a legacy record reloads with a value it never ran with, and evaluate writes it back to task.json' trade-off a deliberate, reviewed decision. Why not static: It depends on what older records omitted, which is history and not something an AST of the current tree contains. Also, whether a non-None default is acceptable for legacy rows is a judgment call. A snapshot forces the decision into review but cannot make it. Prevents: The A7/A8 medium finding at agent_config.py:383/384: tool_output_token_limit defaults to 10_000, so pre-PR Codex records reload and are re-persisted through _write_back/run_record.py:181 with a cap that was never sent to Codex. This affects the cross-repo contract that eval-runner and the evalboard read.
  • Add a Codex binary config-key contract test beside tests/test_codex_provider_binary.py. Check every key that _build_thread_options() writes into the thread config dict against the bundled binary, so that a key Codex silently ignores fails the test. Preferred: if the app-server can return the effective config or a config JSON schema, assert that each sent key is present and has the sent value. Fallback: have the stub return a tool output larger than a small cap (1024) and assert that the next model request carries truncated output. If neither is possible, record that limit in the module docstring so the gap is a deliberate decision. Why not static: Whether Codex honours a key is decided by serde deserialization inside the external binary. The openai_codex SDK passes config through unchecked, so nothing in this repo's source can show the key is read. Only running the bundled binary can. Prevents: The A3 low finding at tests/test_codex_tool_output_cap.py:31: TestThreadOptions only restates the dict branch at codex_agent.py:1794-1795. If a CLI bump renames or drops tool_output_token_limit, the run records 10000 but uses Codex's per-model default, and no test fails.
  • Add an opt-in make mutation-models target, run nightly and not in make verify. It runs mutmut (or cosmic-ray) over field_validator/model_validator bodies in src/coder_eval/models/ against the tests that cover them, and reports surviving mutants. A validator that can be deleted without any test failing is either redundant with a field constraint or unpinned by its tests. Both are review findings that this target finds mechanically. Why not static: Redundancy between a custom validator and a ge= bound, and whether a test's match= tells the two error paths apart, depend on runtime behaviour. You find them by running the suite against a mutated validator. Reading the AST cannot show them. Prevents: The A1/A2/A7 low finding at agent_config.py:401: _reject_bool_tool_output_token_limit duplicates ge=1_024, because True/False already fail the bound. test_a_cap_out_of_range_or_a_bool_fails_at_load matches only the field name, so the test passes with or without the validator.
  • No mechanical gate is proposed for the field-description finding (agent_config.py:393, where the description of None omits the $CODEX_HOME/config.toml precedence that CODEX.md states). This is a recorded boundary, not an omission. When a docs page and the Pydantic description= both state semantics for one field, the review checklist should require them to agree. Better still, CODEX.md could render the field's description from the model, so there is one source. Why not static: The defect is a semantic gap between two prose statements. CE030-style parity checks that a field is documented, not that two descriptions agree. Checking that agreement needs judgment, or an LLM-judge doc check, and not a grep or AST rule. Prevents: The A7 low finding at agent_config.py:393: a schema reader cannot predict that a host $CODEX_HOME/config.toml value leaks into null runs.

Top 5 Priority Actions

  1. Move the exec-ceiling advisory out of the models/ layer: delete the model_validator warn_tool_output_token_limit_above_exec_ceiling and the module logger (src/coder_eval/models/agent_config.py:27, :410-414), emit it once per start with the task-prefixed self._log.warning in CodexAgent._log_config_enforcement (codex_agent.py:1802) or next to the assignment at codex_agent.py:1794-1795, and change docs/agents/CODEX.md:217 to say the warning fires when the agent starts.
  2. Stop reloaded legacy Codex records from reporting a cap they did not run with: keep the field default None at src/coder_eval/models/agent_config.py:383 and stamp 10000 only on newly resolved configs (for example in the default layer of orchestration/config_merge.py); if you keep the trade-off, at minimum say in CODEX.md that evaluate writes the filled-in 10000 back to task.json (the original is kept as task.execute.json).
  3. Add a binary-contract test in tests/test_codex_tool_output_cap.py (the current tests at :31-38 check only the dict that coder_eval builds), for example a stub tool output larger than a 1024 cap followed by an assertion that the next request is truncated, so that a Codex CLI bump that silently ignores the tool_output_token_limit key gets caught; if the app-server cannot show this, record that limit in the module docstring.
  4. Update the field description at src/coder_eval/models/agent_config.py:393 to say that None uses the host $CODEX_HOME/config.toml value first and then Codex's per-model default, as docs/agents/CODEX.md:219-220 states.
  5. Make the tests show what they claim: add match="tool_output_token_limit" to the bare pytest.raises(ValidationError) at tests/test_codex_tool_output_cap.py:69, add an out-of-range -D agent.tool_output_token_limit=10 OverrideError case next to :86-91, and either delete the redundant bool validator at src/coder_eval/models/agent_config.py:401-407 (ge=1_024 already rejects True and False) or assert its specific message.

Stats: 0 🔴 · 0 🟠 · 2 🟡 · 5 🔵 across 8 axes reviewed.

@bai-uipath bai-uipath left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good for now. The key does what it says: codex 0.156.1 applies tool_output_token_limit in both truncation modes, so gpt-6.1-sol goes from a 10,000-byte cap to 40,000 bytes, the same 10000 tokens codex gives every model in its catalog.

  • Why Sol hit this: the pinned codex 0.156.1 predates gpt-6.1-sol (0.160 and later catalog it), so Sol runs on codex's fallback model metadata, and the byte cap is only one part of it: generic base instructions instead of Sol's own, no freeform apply_patch tool, a different shell tool, no default reasoning effort. A codex bump fixes all of those for Sol.
  • Longer term: the model is chosen in an ADO variable and the catalog is pinned in the lock, and nothing checks that they agree. A preflight in the codex agent that calls model/list (the SDK's models(include_hidden=True)) and fails the task when the configured model would fall back, naming the model and the pinned codex version, would catch the next one on its first run instead of two weeks in.

CarlesUIPath and others added 3 commits November 24, 2026 21:17
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 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@CarlesUIPath
CarlesUIPath merged commit 15410bb into main Nov 24, 2026
17 of 18 checks passed
@CarlesUIPath
CarlesUIPath deleted the fix/codex-tool-output-cap branch November 24, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants