Repository navigation
fix: compaction loses track of the active user request - #178477
dmitryvostryakov wants to merge 4 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f6c8b8b82
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const message = findLatestCompactionUserMessage( | ||
| messages, | ||
| (m) => getCompactionContent(m.content).text, | ||
| ); |
There was a problem hiding this comment.
Preserve internal split-turn sources in fallback
When the cut splits a turn started by inter_session, internal_system, synthetic, or operator input and summary generation fails, this external-user-only selector returns empty for compactWithoutSummary (compaction.ts:636-643). That fallback then commits a boundary after dropping turnPrefixMessages without carrying the turn's source at all, so the retained assistant/tool suffix loses the task it belongs to; use a source-preserving selector, with an origin label, for this fallback instead of the user-request selector.
Useful? React with 👍 / 👎.
| return messages.findLast( | ||
| (message): message is Extract<AgentMessage, { role: "user" }> => | ||
| message.role === "user" && | ||
| isCompactionUserRequest(message) && | ||
| Boolean(getText(message).trim()), |
There was a problem hiding this comment.
Scope user-request lookup to the admitted run
When compaction marks a fresh internal-only run unresolved—for example, a cron or independent sessions_send turn after older human work completed—this unbounded findLast skips the admitted input and selects the old external turn. src/agents/embedded-agent-runner/compaction-session-execution.ts:504-506 can set that state for overflow runs regardless of input origin, and src/agents/sessions/agent-session-compaction.ts:424-430 then tells the summarizer the selected text is current work, so completed tasks can be resurrected; scope selection to the current admission/turn and return no external ask for independent internal runs.
AGENTS.md reference: AGENTS.md:L20-L20
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. What this changesThis PR distinguishes external user requests from internal user-role messages when selecting requests and rendering compaction context. Example: A user asks “Review the patch; do not deploy it,” followed by an inter-session update saying “Worker result: tests passed.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open: it addresses a real compaction attribution bug, but introduces two regressions that must be repaired before merging. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherCompaction projects persisted conversation messages into bounded summarizer input and replayable checkpoints, using both agent-core preparation and the safeguard hook. flowchart TD
A[Persisted conversation] --> B[Compaction preparation]
B --> C[Shared origin classification]
C --> D[Core and safeguard summaries]
B --> E[Deterministic timeout fallback]
D --> F[Checkpoint and retained messages]
E --> F
Technical reviewBest possible solution: Keep shared origin classification, preserve attributed internal split-turn sources during fallback, and bind unresolved-request selection to the admitted run. Do we have a high-confidence way to reproduce the issue? Current-main source selects internal user-role messages as requests; the committed fixtures describe a concrete failing path, but no product execution was performed during this read-only review. Is this the best way to solve the issue? A shared origin classifier is an appropriate focused repair, but external-user selection cannot also own arbitrary split-turn source retention or infer which earlier request belongs to the active run. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8fd697560b5f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +52, Tests +215. Total +267 across 8 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 20, 2026, 10:47 AM ET / 14:47 UTC. |
Resolve the test import conflict after upstream removed redundant tests. Preserve the reviewed production patch and both parent histories. Validation: 127 focused tests, targeted types, core lint, formatting, and line-cap pass. Three unchanged upstream UI max-lines failures remain.
Keep historical source context separate from pending human asks and fund it through the existing compaction retention plan. Preserve it in fallback and SQLite reload paths while keeping completed requests out of pending work. Replace the extracted text helper assertions with actual type narrowing.
|
This pull request has been automatically marked as stale after 7 days without qualifying human activity. |
|
Closing due to inactivity. |
What Problem This Solves
Fixes completed requests being revived, or the current human request being lost, when a conversation is compacted after tool, automated, or split-turn messages.
User Impact
Conversations retain the current human request and bounded source facts across compaction, fallback summaries, and session reload. No configuration change or data migration is required.
Why This Change Was Made
Select the pending human request from its recorded provenance and pass that same request through each compaction path. Preserve useful historical source context in its own bounded section, so completed requests do not become pending work again. Existing compaction and summary-quality owners retain the policy; no parallel cache, schema, or request-selection service is introduced.
Evidence
Change size and ownership
Against the merge base: production +224/−77 lines; tests and support +632/−22 lines across 21 files.
The remaining production growth carries human-request provenance and bounded source context through existing compaction owners. The test growth covers distinct selection, budget, fallback, persistence, and caller boundaries. The two helper moves only consolidate existing pure summary transformations; their bodies are unchanged.