Skip to content

refactor(agents): share strict text content validation - #163469

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/text-content-6366-20261002
Oct 2, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/text-content-6366-20261002

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Closes #163468

What Problem This Solves

The text collector and tool-image sanitizer duplicate the same strict text-content predicate. This explicitly requested maintenance gives that rule one internal owner without changing either caller's contract.

User Impact

No intended user-visible change. Text blocks still require a string value, including empty strings. Existing sanitizer fallback, evaluation order, image-first handling, and container/block/details identity behavior stay unchanged.

Why This Change Was Made

Define the internal guard in src/agents/content-blocks.ts and reuse it in src/agents/tool-images.ts. Extend the existing sanitizer tests with admission and identity cases. Reduce the corresponding assertion-baseline count from 3 to 2 after removing the duplicated cast.

The estimator, text-budget owner, SDK barrels, and package exports are untouched.

Evidence

  • Identical baseline/candidate preservation fixtures: 28/28 passed on both; the refreshed commit also passes all 28 tests.
  • Formatting, dependency pins, assertion ratchet, compatibility gate, and mapped static checks passed on the refreshed commit.
  • Scoped core typechecks passed: core, core-test-agents-root, and core-test-agents-other. All 21 selected local stages passed; this is not a full-suite claim.
  • Fresh scoped autoreview: no findings. The reviewed code/test patch is byte-identical after the main refresh.
  • SDK strict-smoke build and standalone export check passed, including all 151 public SDK entries. The maintained API producer checked all 151 typed modules, 3,631 exports, and 10,795 reachable declaration sections without exposing isTextContentBlock. The 193 default-only runtime entries are not claimed as typed coverage; this is containment proof, not a paired whole-API byte comparison.
  • Timing follow-up to refactor(agents): share strict text content validation #163469 (comment): an isolated src/agents/tool-images.test.ts --maxWorkers=1 run on the reviewed head passed all 13 tests, with 18.98s Vitest duration and 21.877s measured whole-invocation wall time (including a local compiler-cache miss). Exact-head CI passed the same 13 tests with 1.93s Vitest duration and 3.35s runner wall time, with inner parallelism 1: https://github.com/openclaw/openclaw/actions/runs/37000426302/job/110816988088. These are separate local and CI measurements, not a before/after performance delta. The earlier refreshed three-suite run took 22.569s wall time; that aggregate is not isolated file cost. No exhaustive accessor/proxy coverage is claimed.
  • Exact-head hosted CI passed the required gate: https://github.com/openclaw/openclaw/actions/runs/37000426302/job/110818492653 (11:26:35-11:26:41 UTC on October 2, 2026). Those 6 seconds are the aggregate gate job, not the changed test file's runtime. Skipped jobs are not passing proof.
  • Native exact-head review validated with zero findings and preparation accepted the completed hosted gates without changing the head. Native squash landing completed as baa26a6ad51207047f05b14d5bf4a5caea3757d3; the landed four-file patch exactly matches the reviewed patch. The linked maintenance issue is closed.

@vincentkoc vincentkoc self-assigned this Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 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: S labels Oct 2, 2026
@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 Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 2, 2026, 7:42 AM ET / 11:42 UTC (Revision 3).

ClawSweeper review

What this changes

The PR shares strict text-block validation between agent text collection and tool-image sanitization and adds admission and identity preservation tests.

Merge readiness

⛔ Needs changes before merge - 1 item remains

The consolidation remains useful and introduces no identified correctness defect. The previous timing request is only partially addressed: grouped wall time and aggregate gate duration do not establish the changed test file’s measured cost.

Priority: P3
Reviewed head: 06afee03eb68fbe1270e2160518aef02b3f5e877

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving refactor with useful boundary coverage and no identified code defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal refactor is exempt from external-contributor runtime proof; supplied preservation tests and scoped checks are supplemental validation. No authority or stored-data contract changes require additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal refactor is exempt from external-contributor runtime proof; supplied preservation tests and scoped checks are supplemental validation. No authority or stored-data contract changes require additional proof.
Evidence reviewed 7 items Pinned introduced change: The introduced diff extracts the identical object, text-tag, and string-value predicate. Both callers retain their evaluation order; sanitizer image admission still precedes text admission. The assertion baseline shrinks rather than adding an exception.
Preservation coverage: Five table cases exercise the production sanitizer boundary for empty/nonempty text, missing/nonstring text, and another block tag, checking result, container, block, and details identity plus input preservation. These cases introduce no timers, process boots, or image processing.
Current-main necessity: Fetched main retains inline collector validation; comparison against the merge base shows no changes to either affected production module. No merged replacement is established by the supplied related context.
Findings None None.
Security None None.

How this fits together

Agent content handling extracts text from structured provider and tool results. Tool-image sanitization uses the same admission rule before preparing content for model replay.

flowchart TD
 A[Structured content blocks] --> B[Shared strict text validation]
 B --> C[Text collection]
 A --> D[Image-first sanitizer admission]
 B --> D
 C --> E[Agent text consumers]
 D --> F[Prepared tool results]
Loading

Before merge

  • Complete next step (P2) - Record measured wall time for pnpm test src/agents/tool-images.test.ts --maxWorkers=1 and available CI test timing in the PR body; retain the explicit distinction between test timing and aggregate gate duration.
Agent review details

Security

None.

PR surface

Source -3, Tests +22, Other 0. Total +19 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 12 15 -3
Tests 1 22 0 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 4 35 16 +19

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #163468
Summary: This PR is the explicit implementation candidate for the paired open maintenance request.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep one internal strict text predicate while preserving both callers’ existing contracts and leaving public SDK and estimator behavior unchanged.

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

Not applicable: the paired request describes internal maintenance rather than a user-facing defect; source inspection confirms the duplicated predicate.

Is this the best way to solve the issue?

Yes: extracting the existing predicate into the lightweight content owner removes duplication without changing admission rules or introducing a competing API.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is bounded internal maintenance with no intended 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 MEMBER-authored internal refactor is exempt from external-contributor runtime proof; supplied preservation tests and scoped checks are supplemental validation. No authority or stored-data contract changes require additional proof.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff extracts the identical object, text-tag, and string-value predicate. Both callers retain their evaluation order; sanitizer image admission still precedes text admission. The assertion baseline shrinks rather than adding an exception. (src/agents/content-blocks.ts:1, 06afee03eb68)
  • Preservation coverage: Five table cases exercise the production sanitizer boundary for empty/nonempty text, missing/nonstring text, and another block tag, checking result, container, block, and details identity plus input preservation. These cases introduce no timers, process boots, or image processing. (src/agents/tool-images.test.ts:33, 06afee03eb68)
  • Current-main necessity: Fetched main retains inline collector validation; comparison against the merge base shows no changes to either affected production module. No merged replacement is established by the supplied related context. (src/agents/content-blocks.ts:1, 375fb614023c)
  • Latest release comparison: The supplied latest release commit also retains inline collector validation rather than the proposed shared predicate. (src/agents/content-blocks.ts:1, c074824a27c9)
  • Timing follow-up remains incomplete: The captured body explicitly reports 22.569 seconds for three grouped suites and six seconds for the aggregate CI gate, while stating that isolated tool-images timing and per-file CI seconds were not collected. This partially addresses the prior review, but the applicable test-cost policy requests measured cost for each materially changed test file. Public docs: docs/help/testing/writing-tests.md. (docs/help/testing/writing-tests.md:108, 06afee03eb68)
  • Related maintenance request and trusted author: The supplied context identifies the author as MEMBER and pairs this PR with the same author’s open maintenance request, Maintenance: share the strict text-content predicate #163468. That request explicitly limits scope to consolidation while preserving admission, evaluation order, identity, estimator behavior, and public SDK boundaries.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Complete the prior test-cost disclosure with isolated single-worker tool-images wall time and available CI test timing, distinguishing unavailable per-file attribution.

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 (2 earlier review cycles)
  • reviewed 2026-10-02T11:08:41.253Z sha 06afee0 :: needs changes before merge. :: none
  • reviewed 2026-10-02T11:24:57.082Z sha 06afee0 :: needs changes before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review October 2, 2026 11:20
@vincentkoc
vincentkoc merged commit baa26a6 into main Oct 2, 2026
220 checks passed
@vincentkoc
vincentkoc deleted the refactor/text-content-6366-20261002 branch October 2, 2026 11:52
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

Maintenance: share the strict text-content predicate

1 participant