Skip to content

Fix tool history hygiene on current main (integrates #36) - #39

Merged
architectds merged 1 commit into
mainfrom
codex/pr36-tool-history-integration
Sep 13, 2026
Merged

architectds merged 1 commit into
mainfrom
codex/pr36-tool-history-integration

Conversation

@architectds

Copy link
Copy Markdown
Owner

Origin and source drift

This integrates and supersedes the tool-history work proposed by @jt-wang in #36 (original commit 629debd2ea069f2964f2a418e3b13d88242ac006). The source had drifted by the time we reviewed it: current main has newer native relay APIs and a shared history normalization path. The original patch could not simply be merged unchanged.

The integration commit retains the original author's identity, the two proposed helpers and the original regression cases. It adapts the implementation to current main and adds the boundaries discovered during review. Thank you @jt-wang for identifying and addressing the original history-loss problem.

Changes

  • Convert mixed Chat/Responses tool history at the existing shared pairing boundary, before pairing and deduplication. Remove the separate Chat pairing path instead of adding another provider-only repair.
  • Treat reuse after a completed call/result pair as a new invocation. Coalesce duplicate pending copies without consuming the next invocation's result.
  • Allocate collision-safe correlation IDs without rewriting an earlier request prefix when more history arrives.
  • Preserve parallel groups, structured tool outputs, namespace metadata, freeform/custom tool payloads and visible reasoning. Reuse the Chat bridge's existing reasoning reader.
  • Compare object/string JSON argument copies semantically. Reject different pending calls sharing one ID explicitly rather than guessing which result belongs to them.
  • Leave the existing native Responses normalization contract unchanged. No routing/profile selection changes and no release/version bump.

Verification

  • New regressions failed on the pre-integration implementation; the adapted implementation passes them.
  • 200 targeted tests passed, including shared-normalizer and built-bundle wire checks.
  • Full Windows npm test: 1,148 total; 1,141 passed, 7 skipped, 0 failed.
  • Strict built-bundle replay retains the original captured Codex envelope and all 164 tool declarations (with the existing outbound provider tool policy). It combines that envelope with the sanitized 1,659-item captured long-session history, adds eight mixed-dialect/reused-ID/custom-tool rounds, switches Chat to Responses, compacts, resumes and checks the first post-compaction tool pair. Assertions check actual result content/order and correlation IDs, not merely HTTP success.
  • Existing complete-package Command Code/native switch, local Chat/KV-mock, xAI and installed-Codex coupling regressions also pass in the full suite.
  • Real provider probes were attempted using the same redacted long-history envelope on an isolated built gateway. OpenCode Go returned quota exhaustion (401); Command Code returned its weekly usage cap (429). These are blocked probes, not successful live inference validation. No real tool commands were executed.
  • Installed gateway was not restarted or modified; its configuration hash stayed unchanged. No local GPU test or llama lifecycle action was performed.

CI must pass on this PR's exact head before merge. This PR does not include #38, a version bump or a deployment.

Integrate jt-wang's PR #36 (629debd).
The original patch predates current gateway/native relay changes. Preserve
its reused-call identity and Chat-to-Responses conversion work and tests,
adapting them into the current shared pairing boundary.

Flatten mixed dialects before identity, pairing and deduplication. Keep
completed invocations distinct, coalesce identical pending copies, avoid
alias collisions, and retain structured output and visible reasoning.
Reject genuinely ambiguous pending calls instead of guessing their results.

Test all routed normalizers and the Chat bridge from one history fixture.
Replay a sanitized 1,659-item session plus eight mixed tool rounds through
the built bundle, including Chat/Responses switching and compaction.

Full Windows suite: 1141 passed, 7 skipped, 0 failed (1148 total).
Live Go and Command Code probes were blocked by account quota limits;
no successful live-provider inference is claimed.

Original-PR: #36
Original-Commit: 629debd
@architectds
architectds merged commit 2c3f9ff into main Sep 13, 2026
3 checks passed
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.

2 participants