Repository navigation
refactor(agents): share strict text content validation - #163469
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: needs changes before merge. Reviewed October 2, 2026, 7:42 AM ET / 11:42 UTC (Revision 3). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherAgent 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3, Tests +22, Other 0. Total +19 across 4 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
Co-authored-by: Vincent Koc <[email protected]>
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.tsand reuse it insrc/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
core,core-test-agents-root, andcore-test-agents-other. All 21 selected local stages passed; this is not a full-suite claim.isTextContentBlock. The 193 default-only runtime entries are not claimed as typed coverage; this is containment proof, not a paired whole-API byte comparison.src/agents/tool-images.test.ts --maxWorkers=1run 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.baa26a6ad51207047f05b14d5bf4a5caea3757d3; the landed four-file patch exactly matches the reviewed patch. The linked maintenance issue is closed.