Skip to content

test(agents): prove live compaction from the successful direct read - #180236

Merged
RomneyDa merged 1 commit into
mainfrom
test/openai-compaction-live-read-retry
Oct 22, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
test/openai-compaction-live-read-retry

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: the release-only live test agent-session.openai-compaction.live.test.ts > "automatically compacts tool history and resumes from its SQLite checkpoint" failing its seed check when the model's first read call passes offset: 0, or when the model keeps the file marker out of its context.

User Impact

There is no user-visible change. This removes a flaky failure from the release live lane (Native live agents) without weakening what the lane proves.

Why This Change Was Made

Root cause. The runner leaves tools.codeMode at its default "auto" tier, and that tier engages Code Mode for gpt-5.6-luna. The offline replay below confirms it: the model-visible tools were exec and wait. The seed transcript therefore holds Code Mode exec results, not raw read output. In those results the model decides what the script returns. The two recorded failures follow from that:

  • The first cell called read({ offset: 0 }) and was rejected (offset: must be >= 1; received 0). The retry cell then read the file, saved the marker with the guest store(), and returned only {"markerStored":true}. The session store stays outside model context, so no tool result carried the marker, and expect(suppliedText).toContain(marker) failed. Line 325 on release/2026.10.6.
  • A cell can likewise return a slice instead of the full file text, which breaks the tail-marker and length checks.

This test owns compaction of tool history and SQLite replay, not Code Mode orchestration. Its premise is that the file contents reach the model through tool history and then survive compaction.

Fix.

  • Pin the direct tool surface with codeModeOverride: false, as the other runner live tests already do. The read result is then the file text in tool history.
  • Build the seed precondition only from successful read results (toolName === "read" && !isError), so a rejected first call such as offset 0 does not count and does not break the check.

Every downstream assertion is unchanged: compaction checkpoint summary contains the marker, no tool results after compaction, the compact and replay replies equal the marker, and the replay stays under budget.

read with offset 0: no product change. offset is documented as a 1-based start line. The model already sees offset?: number /* integer, >= 1 */ in the Code Mode quick index and the schema minimum: 1 on the direct tool. The rejection names the field, the received value, and the expected input. In the recorded case the model self-corrected in one turn. Treating 0 as "from start" would add a second spelling for line 1, and it would hide 0-based callers whose offset: 5 silently reads one line early. The owner contract is coherent as it stands.

Evidence

  • Offline replay through the real test body. No OPENAI_API_KEY was available locally. I wrote a scratch harness (not committed) that runs this file's actual test body. It sets OPENCLAW_LIVE_OPENAI_COMPACTION=1 and uses configureAiTransportHost({ buildModelFetch }) to serve scripted OpenAI Responses SSE, covering the seed, compaction summary, compact, and replay requests.
    • Before (origin/main), with the recorded Code Mode sequence (offset 0 rejected, then a store() cell returning {markerStored:true}): the test fails at expect(suppliedText).toContain(marker) with the same error text as the release run.
    • After, with direct read called with offset: 0, then read, then STORED: the whole live test passes. Output: budget=10420 compactions=1 replayTokens=3037 sqliteReplay=passed toolMarker=preserved. The request log shows read exposed directly (no exec).
    • After, negative check with only the rejected offset-0 call and no successful read: the test still fails with expected '' to contain 'TOOL-MEMORY-…', so the contract is not weakened.
  • Live gap. This has not been rerun against the real OpenAI API. The release live lane (Native live agents) is the remaining proof.
  • pnpm test src/agents/sessions/agent-session.openai-compaction.live.test.ts --maxWorkers=1 takes 1.7s wall time and reports "No test files found": default suites exclude live files, so there is no CI cost outside the live lane. The offline replay ran the test body in about 9.3s.
  • tsgo (test/tsconfig/tsconfig.core.test.agents-sessions.json), oxlint, run-format --check, and git diff --check are all clean. Autoreview (Codex, P2 threshold) came back scoped-clean.
  • The commit cherry-picks cleanly onto origin/release/2026.10.6 (git merge-tree exit 0).

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Oct 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR disables Code Mode in the live compaction fixture and checks seed contents only in successful direct read results.

Example: A seed read is rejected with offset 0, then a successful read supplies TOOL-MEMORY-A1B2C3D4.

  • Before: Code Mode can retain the marker outside model-visible tool history, causing the seed assertion to fail.
  • After: The successful direct read supplies the marker in tool history for the unchanged compaction and replay assertions.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent; validation rests on reported scripted replay rather than inspected live-provider evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test repair is outside the contributor proof gate; supplied evidence describes the actual fixture running with scripted Responses SSE, with real-provider execution explicitly unverified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Release validation can fail before exercising compaction because the fixture assumes raw file contents enter tool history.
Reason: The maintainer-authored direction is established, and the focused repair restores the test premise while preserving its independent persistence and recall checks.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it is a focused maintainer-authored test repair that preserves the compaction assertions, with no actionable correctness or security findings.

Priority: P3
Reviewed head: 7e4dbc7789e58b88597e442e295819893ace120a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The author reports scripted red/green replay and a negative control, but the changed fixture has not been rerun against the real OpenAI API.
Agent review details

How this fits together

The live test invokes the embedded agent runner, reads synthetic file contents into conversation history, forces automatic compaction, and reopens SQLite state to verify marker recall.

flowchart LR
  A[Synthetic file] --> B[Direct read tool]
  B --> C[Agent tool history]
  C --> D[Automatic compaction]
  D --> E[SQLite checkpoint]
  E --> F[Reopened session recall]
Loading

Technical review

Best possible solution:

Use the existing direct-tool override and successful-read filter while retaining all compaction and SQLite replay assertions.

Do we have a high-confidence way to reproduce the issue?

Source supports the mismatch between Code Mode output and the fixture's raw-read premise, and the author reports matching scripted reproduction; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch is the smallest complete fixture repair using existing owners: pin direct tools and exclude failed reads without changing the production read contract or weakening downstream assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 461123273058.

Provenance checked

  • Live tool-history compaction and SQLite replay fixture keeps the original intent (86a119a: Verify that a marker supplied only through tool output survives automatic compaction, persisted checkpoint reopening, and subsequent recall.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 86a119a adds src/agents/sessions/agent-session.openai-compaction.live.test.ts:202 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 86a119a3a158; files: src/agents/sessions/agent-session.openai-compaction.live.test.ts)
  • Dallin Romney: Raw commit 492c932 adds src/agents/sessions/agent-session.openai-compaction.live.test.ts:210 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 492c932c0716; files: src/agents/sessions/agent-session.openai-compaction.live.test.ts)

PR surface

Tests +7. Total +7 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 9 2 +7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 9 2 +7

Labels

Label changes:

  • add P3: This is a narrow release-test reliability repair with no production behavior change.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a narrow release-test reliability repair with no production behavior change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the changed fixture passing in the real OpenAI release live lane when that lane runs.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 21, 2026, 11:22 PM ET / October 22, 2026, 03:22 UTC.

@RomneyDa
RomneyDa merged commit d11c239 into main Oct 22, 2026
111 checks passed
@RomneyDa
RomneyDa deleted the test/openai-compaction-live-read-retry branch October 22, 2026 03:29
RomneyDa added a commit that referenced this pull request Oct 22, 2026
tideclaw-bot added a commit that referenced this pull request Nov 4, 2026
Adapt 28 audited units to the release-native ownership model.
Preserve AgentsAPI/cron policy and actor-owned projection recovery.

Source provenance and original contributor credit:
#176852 342fea1 — yinx65588-boop <[email protected]>
#180853 50f795a — Peter Steinberger <[email protected]>
#184041 e356196 — Peter Steinberger <[email protected]>
#184069 7739767 — Peter Steinberger <[email protected]>
#182666 9ff9d88 — Stefan Stüben <[email protected]>
#183884 112667f — Peter Steinberger <[email protected]>
#184021 05010ed — Peter Steinberger <[email protected]>
#183390 15a5706 — Masato Hoshino <[email protected]>
#183282 24d7dd3 — pstarkgit <[email protected]>
#164843 127f3c2 — PollyBot13 <[email protected]>
#172959 30f88d3 — main object unavailable; stable source inspected
#172959 eb2255b — johan-eilertsen <[email protected]>
#120943 1a76be1 — Peter Steinberger <[email protected]>
#178271 b3c8f8a — Wang Rui <[email protected]>
#178271 7bd6895 — RJ <[email protected]>
#177518 679980c — Masato Hoshino <[email protected]>
#182454 a538efe — Peter Steinberger <[email protected]>
#180042 bef193c — sunlit-deng <[email protected]>
#179347 2405bf4 — Peter Steinberger <[email protected]>
#179060 ccedbdc — Peter Steinberger <[email protected]>
#118011 9596527 — Peter Steinberger <[email protected]>
#182219 fade14f — Sukhdeep <[email protected]>
#181871 b1b5f00 — Peter Steinberger <[email protected]>
#178888 5125e3c — RoboClaw <[email protected]>
#180075 c9c2d16 — Wang Rui <[email protected]>
#181081 f223f77 — Jason O'Neal <[email protected]>
#180236 d11c239 — Dallin Romney <[email protected]>
#173921 af50fbd — Peter Steinberger <[email protected]>
#174868 7034ca4 — Peter Steinberger <[email protected]>
#172724 492c932 — Dallin Romney <[email protected]>

Proof: targeted owner/sibling tests, supported fresh two-pass review clean.
Known qualification gaps recorded in the release backport evidence.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant