Skip to content

fix(codex): enforce turn budgets for reasoning and tool-only responses - #201

Open
ye1457 wants to merge 2 commits into
RLinf:mainfrom
ye1457:fix/codex-model-response-budget
Open

ye1457 wants to merge 2 commits into
RLinf:mainfrom
ye1457:fix/codex-model-response-budget

Conversation

@ye1457

@ye1457 ye1457 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex previously counted nonempty text items, so reasoning/tool-only responses could bypass --max-turns. The planner now counts distinct usage updates, uses that count in CLI and Dashboard, and preserves a completed finish when stopping at the budget.

The English and Chinese guides explain turns with a two-file-read example. They distinguish RPent's response count from Claude's tool-use limit without changing Claude's runtime behavior.

Rebased onto current main eecf2069, preserving the complete original changes.

Validation

  • 595 unit tests passed; 3 skips require optional robot dependencies.
  • The four existing Codex budget regressions and installed Claude SDK options check passed.
  • Full pre-commit and strict English/Chinese documentation builds passed.

@QuanluZhang
QuanluZhang requested a review from jx-qiu September 21, 2026 08:39
Comment thread docs/source-zh/rst_source/usage/configure_planner.rst Outdated
assert any(isinstance(event, UsageEvent) for event in sink.events)


def _model_response_events(index: int, *, text: bool = False, finish: bool = False):

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.

Could we simplify the tests here? The core behavior is fairly small, but the new coverage expands into several overlapping parameterized cases across CLI and Dashboard. I think a few focused cases for response counting, budget interruption, and preserving finish, plus one dashboard smoke test, should be sufficient.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reduced the ten test instances to four in 854d1b8: response counting/deduplication, CLI interruption, preserving finish, and one Dashboard smoke test. The reasoning/tool-only, duplicate-usage and cleanup checks remain. Full suite: 587 passed, 3 optional-dependency skips; pre-commit and both documentation builds also pass.

Comment thread rpent/planner/codex.py
if not text:
return ""
self.final_response = text
self.turns += 1

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.

Is this line an error or an unused assignment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The removal is intentional. agentMessage rendering now only handles text; _set_usage counts completed responses, including reasoning/tool-only responses. Restoring this increment would double-count responses that also emit text. The four existing budget regression tests pass.

Comment thread docs/source-zh/rst_source/usage/configure_planner.rst Outdated
``100``。各后端对一轮的定义和上限的执行方式不同,报告的 ``turns_used``
与执行预算时使用的计数不一定相同:

.. list-table:: 各后端的轮数统计与限制

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.

It's still hard to understand. please use understandable description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Replaced the table with a short explanation and a two-file-read example in 0abaca2. Both guides now explain what counts as a turn and why Claude's reported count can differ from its limit. Runtime behavior is unchanged; the existing tests and both documentation builds pass.

@ye1457
ye1457 force-pushed the fix/codex-model-response-budget branch from dedbb9e to 0abaca2 Compare September 25, 2026 10:09
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.

5 participants