Skip to content

Preserve tool-call atomicity when popping context records and add tests#2

Merged
CompilError-bts merged 2 commits intomasterfrom
codex/implement-fix-from-issue-7225-fwjo6t
Mar 31, 2026
Merged

Preserve tool-call atomicity when popping context records and add tests#2
CompilError-bts merged 2 commits intomasterfrom
codex/implement-fix-from-issue-7225-fwjo6t

Conversation

@CompilError-bts
Copy link
Copy Markdown
Owner

Motivation

  • Ensure that removing old conversation records does not break the pairing between assistant tool_calls and subsequent tool messages.
  • Make pop_record robust for cases with leading orphan tool messages and multi-call assistant messages.

Description

  • Rewrote Provider.pop_record to remove the earliest non-system "unit" (a single message or an assistant+tool(s) group) while preserving assistant tool_calls and their following tool messages as an atomic unit.
  • Added helper functions _has_tool_calls and _next_unit_bounds to detect units and compute removal bounds, and limited total removed items to keep behavior close to the previous strategy.
  • Updated tests in tests/test_openai_source.py by adding async tests for pop_record behavior: test_pop_record_removes_assistant_tool_calls_with_following_tools_atomically, test_pop_record_removes_leading_orphan_tool_messages, test_pop_record_normal_messages_no_regression, test_pop_record_assistant_with_multiple_tool_calls, and test_pop_record_only_system_messages.
  • Hardened existing file-URI related tests to use Path comparisons and constructed a file://localhost URI using urlparse/urlunparse to avoid platform-dependent formatting.

Testing

  • Ran the modified tests/test_openai_source.py with pytest, including the new pop_record unit tests, and the updated file-URI tests; all tests passed.
  • Verified no-regression for normal message popping behavior via test_pop_record_normal_messages_no_regression, which succeeded.
  • Verified edge cases for orphan tool messages and multiple tool calls via their respective tests, which succeeded.

Codex Task

@CompilError-bts CompilError-bts merged commit 592a753 into master Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant