Skip to content

refactor(sdk): retire superseded worker prompt/bootstrap SDK exports - #164768

Merged
steipete merged 3 commits into
mainfrom
codex/node-parity-r3-prompt-a
Oct 4, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/node-parity-r3-prompt-a

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Embedded agent sessions currently use separate internal forwarding functions for session creation and configured prompt construction. These redundant entry points complicate sharing prompt preparation with node-hosted sessions.

User Impact

No user-visible behavior change. Session construction defaults, embedded provider-resource ownership, prompt trimming, tool policy, bootstrap content, and the documented session-extension SDK remain unchanged.

Why This Change Was Made

The configured prompt builder now accepts the actual tool projection directly. Embedded prompt callers use that owner, and session callers use the existing session factory with explicit disposal ownership. The obsolete forwarding functions and their internal parameter adapter are removed.

The virtual session-extension SDK and loader are retained because docs/plugins/sdk-overview/host-hooks.md documents their contract. This PR does not retire public exports, alter resource loading, or include the node prompt-parity behavior change.

Evidence

  • 371 tests passed across 21 whole files and affected siblings on Hetzner cbx_5d2b3a4147aa (Node 24.16.0, pnpm 12.5.1); serial command wall time 345.58 s, peak RSS 5.55 GiB. The final assertion repair passed its whole file again: 21 tests, 33.28 s including worker preparation.
  • Production types and the agents-other/agents-sessions test type graphs passed. Typed lint passed with zero warnings/errors. All three unused-export scans passed with zero findings; the mock-export ratchet passed after its canonical four-entry shrink.
  • Lease pnpm exec oxfmt --check and git diff --check passed. Sparse-worktree commits use --no-verify only after lease formatting proof.
  • Independent Codex P0–P2 review passed on the initial candidate and final rebased branch. Full pnpm build passed in 637.20 s (peak RSS 8.78 GiB); only the existing advisory UI size warnings remained.
  • Repository-wide retired-symbol/call-index audit found no remaining callers. Factory invocation counts and ordering are unchanged; tests retain disposal ownership, prompt trimming, and callback bytes.
  • 20 changed paths: 10 production/counting paths, production +58 / -117, net -59. This includes the existing test harness and four-line baseline shrink under the campaign classifier.
  • Tests used base 4fa690195797; the subsequent rebase incorporates no changes to these agent/session owners or fixtures. Exact-head CI run 37178064171 and openclaw/ci-gate passed. Its 17 selected Node jobs used 2,475 job-seconds including setup. ClawSweeper completed its exact-head review with no findings (review).
Deletion and mechanical migration ledger

Deleted src/agents/embedded-agent-runner/system-prompt.ts, retiring buildEmbeddedSystemPrompt and applySystemPromptToSession. Removed createAgentSessionForEmbeddedRunner, createAgentSessionImpl, and CreateAgentSessionInternalOptions from src/agents/sessions/sdk.ts. Kept construction in createAgentSession; embedded callers explicitly preserve cleanupProviderSessionResourcesOnDispose: false.

Owner changes:

  • src/agents/sessions/sdk.ts
  • src/agents/system-prompt-config.ts

Mechanical production callers/fixtures:

  • src/agents/embedded-agent-runner/compaction-session-execution.ts
  • src/agents/embedded-agent-runner/prepared-compaction-runtime.ts
  • src/agents/embedded-agent-runner/run/attempt-session-prepare.ts
  • src/agents/embedded-agent-runner/run/attempt-system-prompt-prepare.ts
  • src/agents/embedded-agent-runner/run/attempt-system-prompt.ts
  • src/agents/embedded-agent-runner/compact.hooks.harness.ts

The four obsolete factory entries are pruned from config/test-mock-exports-baseline.txt. The remaining ten paths migrate existing tests or shared test helpers to the same owners. The deleted wrapper-only setter test is covered at the session-preparation boundary, including its trimming contract.

Use the configured prompt builder and session factory directly. Preserve prompt
trimming and embedded provider-resource disposal ownership; retain the documented
session-extension SDK.

Validated 371 tests across 21 whole files on Hetzner cbx_5d2b3a4147aa.
Independent Codex review is clean at P0-P2. Production delta: -55 lines.

Committed with --no-verify because this sparse worktree has no dependencies;
pnpm exec oxfmt --check passed for every changed file on the lease.
Preserve the trimming regression without referencing an unbound session method. Lease oxfmt --check passed before committing with --no-verify in the sparse worktree.
The lease mock-export owner pruned exactly four obsolete factories. Lease formatting passed for the changed source files; this sparse checkout commit uses --no-verify because dependencies are installed only in the validation and tooling checkouts.
@clawsweeper

clawsweeper Bot commented Oct 4, 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: M labels Oct 4, 2026
@steipete
steipete marked this pull request as ready for review October 4, 2026 04:48
@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 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 1:26 AM ET / 05:26 UTC (Revision 2).

ClawSweeper review

What this changes

The branch removes internal prompt and session forwarding functions and migrates their callers and tests to the existing configured prompt builder and session factory.

Merge readiness

✅ Ready for maintainer review

This remains useful cleanup: current main retains the redundant forwarding paths. The introduced changes preserve prompt handling and resource ownership, and no blocking defect was found.

Priority: P3
Reviewed head: f0fad5275574dbc082a3e1405676de4d8c45a9ed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-consolidation refactor with preserved lifecycle contracts, relevant validation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts this internal refactor from contributor runtime proof; migrated coverage and exact-head CI supplement source review of prompt construction and disposal ownership. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified repository-admin authorship exempts this internal refactor from contributor runtime proof; migrated coverage and exact-head CI supplement source review of prompt construction and disposal ownership. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduction and merge ownership: Reviewed the merge-base-to-head introduced hunks. The raw test-merge commit records the pinned base followed by the exact PR head; its owner changes match the introduced refactor.
Prompt projection preserved: The configured builder absorbs the deleted wrapper's tool-name projection, message-tool selection, and runtime agent-ID fallback.
Embedded lifecycle preserved: Attempt preparation explicitly disables provider-resource cleanup on temporary session disposal, preserves recovery and before-tool-batch inputs, and installs trimmed prompt bytes after publishing the original callback bytes. Compaction follows the same ownership and trimming pattern.
Findings None None.
Security None None.

How this fits together

Embedded agent runs prepare tools and configuration into system prompts, then construct sessions that send those prompts to providers. Temporary embedded sessions leave durable provider-resource cleanup to their outer lifecycle owner.

flowchart TD
  A[Run configuration and tools] --> B[Configured prompt builder]
  B --> C[Trimmed session prompt]
  D[Prepared model and resources] --> E[Session factory]
  C --> E
  E --> F[Provider execution]
  E --> G[Outer lifecycle cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -55, Tests -22, Other -4. Total -81 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 9 58 113 -55
Tests 10 123 145 -22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 4 -4
Total 20 181 262 -81

Review metrics

None.

Technical review

Best possible solution:

Keep prompt configuration and session construction with their existing owners while retaining the documented extension-safe SDK.

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

Not applicable: this is a behavior-preserving refactor, and source inspection confirms the redundant paths remain on current main.

Is this the best way to solve the issue?

Yes: moving the existing projections and lifecycle inputs directly to their owners removes forwarding layers without changing the documented plugin surface.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is bounded internal cleanup with preserved user-visible behavior and successful exact-head CI.
  • 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: Verified repository-admin authorship exempts this internal refactor from contributor runtime proof; migrated coverage and exact-head CI supplement source review of prompt construction and disposal ownership. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge ownership: Reviewed the merge-base-to-head introduced hunks. The raw test-merge commit records the pinned base followed by the exact PR head; its owner changes match the introduced refactor. (34911eccdc52)
  • Prompt projection preserved: The configured builder absorbs the deleted wrapper's tool-name projection, message-tool selection, and runtime agent-ID fallback. (src/agents/system-prompt-config.ts:32, f0fad5275574)
  • Embedded lifecycle preserved: Attempt preparation explicitly disables provider-resource cleanup on temporary session disposal, preserves recovery and before-tool-batch inputs, and installs trimmed prompt bytes after publishing the original callback bytes. Compaction follows the same ownership and trimming pattern. (src/agents/embedded-agent-runner/run/attempt-session-prepare.ts:212, f0fad5275574)
  • Ordinary disposal default preserved: The session constructor still defaults cleanupProviderSessionResourcesOnDispose to true; embedded callers pass false explicitly. Migrated tests retain durable-resource and prompt-trimming coverage. (src/agents/sessions/agent-session-base.ts:151, f0fad5275574)
  • Documented plugin boundary retained: The extension-safe barrel and virtual agent-sessions mapping remain unchanged and do not expose the removed factory. Host-hooks documentation defines the retained runtime-only session-extension surface. (src/agents/sessions/extension-sdk.ts:1, f0fad5275574)
  • Still necessary on current main: Fetched main still contains buildEmbeddedSystemPrompt and applySystemPromptToSession, so the central cleanup has not already landed. No release-fix claim is made. (src/agents/embedded-agent-runner/system-prompt.ts:29, 39b4bdbb6427)

Likely related people:

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

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-10-04T04:54:07.092Z sha f0fad52 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 6a3f4a2 into main Oct 4, 2026
213 checks passed
@steipete
steipete deleted the codex/node-parity-r3-prompt-a branch October 4, 2026 06:07
@fatfatbigcat

fatfatbigcat commented Oct 4, 2026 via email

Copy link
Copy Markdown

@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…penclaw#164768)

* refactor(sdk): retire superseded worker prompt/bootstrap SDK exports

Use the configured prompt builder and session factory directly. Preserve prompt
trimming and embedded provider-resource disposal ownership; retain the documented
session-extension SDK.

Validated 371 tests across 21 whole files on Hetzner cbx_5d2b3a4147aa.
Independent Codex review is clean at P0-P2. Production delta: -55 lines.

Committed with --no-verify because this sparse worktree has no dependencies;
pnpm exec oxfmt --check passed for every changed file on the lease.

* test(agents): assert installed prompt bytes directly

Preserve the trimming regression without referencing an unbound session method. Lease oxfmt --check passed before committing with --no-verify in the sparse worktree.

* test(agents): prune retired prompt mock baselines

The lease mock-export owner pruned exactly four obsolete factories. Lease formatting passed for the changed source files; this sparse checkout commit uses --no-verify because dependencies are installed only in the validation and tooling checkouts.
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: M 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