Skip to content

refactor(agents): reuse thinking block predicate - #130001

Merged
steipete merged 2 commits into
mainfrom
codex/wave1-agents-cleanup
Aug 26, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/wave1-agents-cleanup

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Removes a stale private copy of the shared thinking-block classifier from replay sanitization. The duplicate could drift from the canonical definition already used by transcript repair, tool-call ID handling, and embedded turn validation.

Why This Change Was Made

Replay sanitization now calls the existing private isThinkingLikeBlock owner directly. The recognized block types and both replay decision points are unchanged; the assertion-safety ratchet shrinks by one to reflect the deleted assertion.

Alternatives considered: keeping the replay-local alias preserves duplicate policy, while creating another helper would add a third owner. Reusing the existing zero-dependency canonical predicate is the smallest coherent change.

User Impact

No user-visible or agent-behavior change. This reduces private production code and keeps one canonical definition for thinking and redacted_thinking blocks.

Production LOC: +3/-10 (net -7)
Tests: +0/-0
Tooling metadata: +1/-1

Base: 3a759c85c5862b4d95c6d873b3e33c544ee14827
Reviewed head: 4bd426493554af6faa24d39f9b5b6e0611bd4083

Evidence

  • Focused baseline: replay-sanitization Vitest, 14/14 passed.
  • Focused final: replay-sanitization Vitest, 14/14 passed.
  • pnpm check:changed: passed, including formatting, assertion ratchet, dead-export scan, core/core-test typechecks, lint, and import-cycle checks.
  • git diff --check: passed.
  • Test audit: no test edit and no test-only seam; existing owner-boundary coverage remains unchanged.
  • Deslop: clean; no additional changes.
  • Structured autoreview: clean, no accepted/actionable findings.
  • Separate read-only exact-head Codex review: CLEAN, no blocking findings.
  • ClawSweeper exact-head review: no correctness or security findings; its live proof passed 14/14 tests.
  • Hosted exact-head CI: all 14 workflow runs succeeded. Main CI run 32949901184 completed with 127 successful and 20 skipped jobs; PR rollup recorded 151 successful, 45 skipped, and 1 neutral check.
  • Exact-head CI includes the unrelated Control UI budget repair landed separately in fix(ci): restore Control UI startup budget gate #130015; no project blocker is folded into this patch.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 08:17
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 4:56 AM ET / 08:56 UTC.

ClawSweeper review

What this changes

The PR replaces replay sanitization’s local thinking-block classifier with the shared predicate and updates the assertion-safety baseline.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness or security finding: the patch removes a byte-equivalent duplicate and keeps the shared classifier as the sole owner. This maintainer-labeled PR remains open for normal exact-head CI completion.

Priority: P3
Reviewed head: 4bd426493554af6faa24d39f9b5b6e0611bd4083

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch is semantically equivalent and well-covered by existing boundary tests; exact-head CI is still incomplete.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor is outside the external-contributor proof gate; the PR body reports focused replay-sanitization validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor is outside the external-contributor proof gate; the PR body reports focused replay-sanitization validation.
Evidence reviewed 4 items Semantic equivalence: The deleted local predicate and the shared predicate both reject non-objects and accept only thinking and redacted_thinking; the two substitutions preserve the prior decision conditions.
Canonical owner and siblings: The shared predicate is already used by transcript repair, tool-call ID handling, and embedded-turn validation, supporting one canonical owner rather than replay-local policy.
Owner-boundary coverage: Existing wrapper integration tests cover signed-thinking rejection, preservation, and Anthropic embedded tool-result behavior.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.test.ts
[test] starting test/vitest/vitest.agents-embedded-agent-run.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130001-jpSonv/target

 ✓  agents-embedded-agent-run  src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.test.ts (14 tests) 42ms

 Test Files  1 passed (1)
      Tests  14 passed (14)
   Start at  08:57:42
   Duration  11.07s (transform 8.70s, setup 1.03s, import 9.64s, tests 42ms, environment 0ms)

[test] passed 1 Vitest shard in 17.24s
$ node --import tsx scripts/test-projects.mts src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.test.ts
[test] starting test/vitest/vitest.agents-embedded-agent-run.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130001-jpSonv/target

 ✓  agents-embedded-agent-run  src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.test.ts (14 tests) 33ms

 Test Files  1 passed (1)
      Tests  14 passed (14)
   Start at  08:58:00
   Duration  5.06s (transform 2.87s, setup 459ms, import 4.34s, tests 33ms, environment 0ms)

[test] passed 1 Vitest shard in 11.17s

Assertions:

  • PASS expect_output: passed

How this fits together

Replay sanitization prepares stored assistant tool-call turns before provider submission. It uses thinking-block classification to preserve safe signed-thinking turns or remove invalid replay content.

flowchart LR
A[Stored assistant messages] --> B[Replay sanitization]
B --> C[Shared thinking classifier]
C --> D{Safe signed replay?}
D --> E[Preserve provider-owned turn]
D --> F[Repair or remove invalid content]
E --> G[Provider stream]
F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Required exact-head checks are still queued or in progress, so merge readiness is not yet confirmed.
  • Complete next step (P2) - No mechanical repair is needed; this protected maintainer PR only awaits its normal exact-head CI gate.
Agent review details

Security

None.

PR surface

Source -7, Other 0. Total -7 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 10 -7
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 2 4 11 -7

Review metrics

Metric Value Why it matters
Production versus tests production +3/-10 (net -7); tests +0/-0; baseline +1/-1 The change removes duplicate production policy without adding test-only seams; the baseline reduction records the deleted assertion.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared predicate as the single classifier and merge only after the exact-head required checks complete green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the shared predicate as the single classifier and merge only after the exact-head required checks complete green.

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

Not applicable: this PR is an internal behavior-preserving refactor, not a report of a user-facing failure.

Is this the best way to solve the issue?

Yes: reusing the existing shared classifier is the narrowest maintainable solution and avoids duplicate policy drift.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ff73ba5f566f.

Labels

Label justifications:

  • P3: This is a low-risk internal cleanup with no claimed user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor is outside the external-contributor proof gate; the PR body reports focused replay-sanitization validation.

Evidence

What I checked:

Likely related people:

  • Amp: The checked-out PR head is an Amp-authored merge; shallow history prevents reliable attribution to the original feature owner. (role: recent current-head integrator; confidence: low; commits: 4bd426493554; files: src/agents/thinking-block.ts, src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.ts)

Rank-up moves

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

  • Wait for the exact-head required checks to finish green.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-26T08:23:53.976Z sha 202f2a2 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft August 26, 2026 08:49
@steipete
steipete marked this pull request as ready for review August 26, 2026 08:49
@steipete
steipete merged commit 7da8c19 into main Aug 26, 2026
203 checks passed
@steipete
steipete deleted the codex/wave1-agents-cleanup branch August 26, 2026 09:27

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

2 participants