Repository navigation
refactor(agents): share workspace context preparation - #158389
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: blocked before merge. Reviewed September 25, 2026, 9:26 PM ET / September 26, 2026, 01:26 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch moves workspace instruction, persona, project-context, and memory preparation into shared harness helpers exposed through the Plugin SDK, then updates the Codex adapter, documentation, and tests to use them. Merge readiness⛔ Blocked before merge - 4 items remain Keep this PR open. Current main still prepares Codex workspace context locally, and the linked Agents API fix depends on this branch. The source review found no actionable correctness defect, but the public SDK refactor needs maintainer sponsorship and after-change native behavior proof. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw reads workspace files, applies session filters and character budgets, then prepares context for an agent harness. The Codex adapter places that context into native thread and turn requests and retains instruction snapshots for resumed sessions. flowchart LR
A[Workspace files] --> B[Session filters and budgets]
B --> C[Shared context preparation]
C --> D[Instruction snapshot]
C --> E[Persona and memory guidance]
D --> F[Codex adapter]
E --> F
F --> G[Native thread and turn requests]
Decision needed
Why: OpenClaw's contribution policy requires explicit maintainer direction for a refactor-only PR, and accepting a public SDK contract is a lasting ownership choice. Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +107, Docs +31, Other +2. Total +152 across 11 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one approved preparation owner for Codex and the Agents API consumer, while preserving Codex's existing prompt and snapshot behavior and exposing only the SDK operations both harnesses need. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a refactor rather than a report of a failing current-main behavior. The old and proposed Codex preparation paths are available for source comparison. Is this the best way to solve the issue? Unclear pending maintainer direction: the extraction is coherent and has a concrete stacked consumer, but the owner must decide whether this public SDK seam should land separately or within that fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against af9a06739009. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review Please reassess the current head |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Maintainer direction for the current head The maintainer has now explicitly directed merging without attaching live Codex proof. Accept the documented source parity comparison and existing native request-boundary regressions for this refactor. No live Codex session is claimed. The PR description records this waiver and the remaining CI issue. Please reassess the owner-decision and live-trace blockers in the latest review using that direction. This requests review only; normal CI gates still apply. No production logic changes are requested or authorized by this comment. |
|
🦞👀 Re-review progress:
|
Share workspace instruction, persona, and memory preparation through the existing agent harness SDK so native harnesses can reuse the same owner. Keep Codex protocol delivery, path projection, restriction gates, and saved snapshot behavior in its adapter. Move generic coverage alongside the shared code. Validation: source parity review, unchanged native request-boundary tests on base and refactor, shared preparation regressions, selected type/lint/SDK checks, and the canonical artifact build passed. ClawSweeper found no actionable correctness or security findings. Maintainer-directed merge accepts the known unrelated chat reset/yield CI failure tracked in openclaw#158524 and waives live Codex trace attachment. Other cancelled CI checks are not claimed as passing.
Why This Change Was Made
OpenClaw workspace instructions, persona, and memory guidance should have one preparation owner that native harnesses can consume. Keeping that policy inside the Codex adapter makes another harness duplicate it or omit it. This MVP extraction provides shared preparation while preserving Codex's native delivery behavior.
This standalone extraction is explicitly maintainer-directed as the prerequisite for #158328. The two new functions in
openclaw/plugin-sdk/agent-harness-runtimeare the intended shared contract; Codex keeps its native delivery and lifecycle decisions. The maintainer has explicitly approved merging without attaching a live Codex trace. The source comparison and native request-boundary tests below are the accepted evidence for this refactor; no live session proof is claimed.What Problem This Solves
Makes bounded Gateway workspace context reusable by native harnesses without copying Codex-specific protocol or filesystem behavior.
User Impact
Preserves Codex instruction bytes, context refresh, memory routing, warning logging, and saved snapshots. Agents API integration remains a separate stacked change.
What Changed
MVP Gaps
The current Agents API client supports creation instructions, reasoning updates, and user messages. It does not implement a per-turn developer instruction carrier, instruction refresh, native fork preparation, or Gateway-to-hosted-workspace path projection. Persona and personal-overlay refresh, other turn-scoped workspace context, and memory prompt guidance remain unimplemented in that adapter. This PR supplies preparation, without claiming those client operations are available or freezing turn-scoped context into session instructions. No filesystem transfer, new API operation, configuration, or persistence migration is added.
Full-context preparation preserves the existing Codex selection timing: projecting the root instruction path away from its source workspace produces an empty root snapshot. The Agents API instructions-only caller does not project paths. Cross-workspace snapshot selection is outside this MVP.
Evidence
Fresh independent source review found no remaining actionable P0-P2 findings, including SDK accounting and strict Codex parity follow-ups. The autoreview CLI was unavailable for the signed-in account; independent source review supplied the review instead.
38ac4ae5dfdaaa161ef8b4a7f1d6968297a4969epassed 206 in 332.69 seconds. Six generic cases moved to core, and all thirteen core preparation/snapshot cases pass. The existing full native attempt file is unchanged and passes on both versions, covering real mocked app-server request payloads, workspace context, routing, lifetimes, recovery, hooks, persistence and delivery.5f22fe850b2a1d75f61c2a83b7e8ffb38c289f9716a645b412127b91db803dc5.ebea171d02e89881ee7a479a6654da7aa145fb80passed the canonicalpnpm build:ci-artifactsbuild, including runtime bundles, SDK declarations, SDK export validation, generated assets and UI. Build command cost: 217 seconds; the separate Control UI build took 16 seconds. Passing build job. The earlier full local build was interrupted and is not claimed as passing.Object.assigninto a newly created temporary object to satisfy lint. It does not mutate bootstrap inputs. Fresh independent review found no observable change. All nine shared-context tests and three native memory-routing tests pass on final head, in 26.17 and 32.83 seconds wall respectively. Formatting and whitespace checks pass. All selected changed-file checks pass: formatting, core/source/test, extension/source/test and script types, SDK exports and surface, plugin ownership/boundaries, dependency/ratchet, deprecation/coercion, dead exports, core/extension/script lint, native schema, legacy-store/media/sidecar/import-cycle and webhook/pairing guards. The lint rule rejected a map-spread allocation; the temporary-object correction described above passed fresh review, affected tests and all remaining lint/guard checks.A native payload test invocation failed before executing tests because it overlapped the build:
Error: Boundary configuration or resolution topology changed during compilation. An owner-guard invocation had the same compile-time topology failure. The build created package outputs while each compiler was sealing its input snapshot. The lanes passed after package emission stopped; no product fix or weakened compiler guard was used for that scheduling failure. The first build was interrupted to apply the two parity corrections and is not success evidence. The passing canonical CI artifact build above supplies final packaging evidence.No local Docker Gateway or live hosted API session is part of this source refactor validation. Live Codex trace attachment is explicitly waived by the maintainer.
Current required CI is blocked by the existing chat reset/yield failure in
src/gateway/server-methods/chat.reset-visible-yield.test.ts(run36197770240, job108278733146). The same failure is recorded outside this refactor, and the lifecycle owner repair is tracked in #158524. This extraction does not modify those lifecycle owners. The maintainer explicitly accepted this unrelated failure and directed merging the refactor. No tests related to this refactor are failing. The failed group has one failing test case with two assertion failures and 400 passing tests; 43 other checks were cancelled, so this is not a claim that all CI passed.Base:
1667391dc4676e731efe1c5c3a49065e1f4bebb0