Repository navigation
fix(harness-pi): stream between-turn compaction on the next turn - #24407
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
gr2m
force-pushed
the
fix/harness-pi-compaction-fork-base
branch
from
November 3, 2026 17:25
8282256 to
6257258
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Pi compaction requested between turns runs successfully but its observation is buffered indefinitely. The next turn never delivers the summary or token count to the application.
Summary
Drain pending compaction observations after the next turn's
stream-start, before the model emits new content. Regression coverage checks one or multiple observations, preserves their order/summary/token count, and verifies they are delivered only once. Updated on current main and signed the rebased contributor commit while retaining its original author. The regression mock now returns the current Pi compaction result type and explicitly declares a new session. Opus found no blockers; added its suggested stream-order assertion.Validation: all 360 Pi harness tests pass.
pnpm type-check:fullandpnpm checkpass. Includes a patch changeset for@ai-sdk/harness-pi.Contributor Credit
@dannote reported #24359 with a real Pi/Codex reproduction and root cause analysis. @pei711 authored the fix and original regression test. @gr2m added delivery-once coverage and the public application verification below.
End-to-End Verification
Ran the same temporary application using the public
HarnessAgent,createPi, and local just-bash sandbox. It executes the actual installed Pi runtime, creates conversation history, callssession.compact(), and consumes two subsequentfullStreams. A loopback HTTP server supplies deterministic OpenAI-compatible model responses, including the compaction summarization request. There are no mocked Pi modules.Before (
5c1f2c6027, whose Pi implementation matches main): seven local model requests complete, including compaction, but neither subsequent stream contains a compaction observation.After: the first subsequent stream includes
tool-call:compactionandtool-result:compactionwith{ trigger: 'manual', summary: 'The cat is called Brioche.', tokensBefore: 40008 }, followed by the normal model response. The following stream has no duplicate compaction.Prerequisites: repository dependencies, supported Node and pnpm. Save the complete script below outside the checkout as
/tmp/ai-pi-compaction/repro.mjs. From each checkout run:Both runs resolve the checkout's built workspace packages. No reproduction-only files are committed.
Verification limit: this is a local application E2E flow through the real Pi runtime and sandbox, with synthetic model responses. No live model or Pi subscription credentials are configured, so the reporter's cloud-model reproduction could not be rerun. This does not validate remote model behavior or semantic memory retention.
Checklist
pnpm changesetin the project root)Future Work
This fixes queued observations on the next turn of a live session. Persisting undelivered observations across stop/detach and ordering compaction that completes concurrently with turn setup are existing limitations outside this change.
Related Issues
Fixes #24359.