Skip to content

refactor(agents): deslop agents core second pass - #158378

Merged
steipete merged 4 commits into
mainfrom
deslop/l55-agents-root-second-pass
Sep 26, 2026
Merged

steipete merged 4 commits into
mainfrom
deslop/l55-agents-root-second-pass

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested second pass over agents core removes repeated execution, projection, and normalization paths that obscure their existing owners.

Depends on #158619 for the startup-fixture race exposed by CI; land that focused test repair first.

Related: #156311. This pass leaves that PR's touched root files and the excluded runner, tools, sandbox, subagent, session, auth-profile, harness, and failover directories alone.

User Impact

The refactors preserve prompt bytes and ordering, tool contracts, model/provider selection, lifecycle ordering, authority checks, and persistent state. Repeated exec preparation now retains its prepared plugin environment. Live-test completions release both timeout timers after early success or failure.

Why This Change Was Made

  • Execution approvals share preparation, decision parsing, follow-up delivery, and durable-grant matching; same-file patch moves use the ordinary update path.
  • Code Mode resumes share their existing execution and delivery-settlement owner, and tool hooks share final approval handling.
  • Provider attribution resolves one selected policy instead of constructing every vendor policy; TLS and request overrides have one merge flow.
  • Tool and image model probes share timeout/error handling while retaining their distinct request bytes; model discovery reuses canonical transport and indexing helpers.
  • Prepared catalogs use the existing mode-aware preparation owner directly, removing static/live forwarding layers.
  • Embedded tool and terminal events share flush/cancellation and payload construction paths while keeping callbacks and event objects independently owned.
  • Transcript/CLI projection removes unused repair counters, duplicate credential wrappers, redundant image validation, and repeated result/slug handling.
  • Workspace, bootstrap, identity, and prompt assembly reuse existing authority, normalization, and ordering owners.
  • MCP/LSP handling shares tool construction and canonical record coercion and avoids constructing HTTP responses twice.
  • Lifecycle helpers reuse terminal merging, abort construction, truncation, and recovery projection; command/worktree helpers remove redundant metadata restoration and Git setup.

Fixes found along the way

Preparing exec arguments twice previously replaced the prepared environment metadata with an empty record, dropping plugin-provided environment values. The preparation owner now returns the already-prepared arguments unchanged. A regression executes the twice-prepared request and checks both effective and requested environment values.

The live completion timeout helper cleared only its abort timer when a provider settled early. It now also clears its hard timeout, and the cache-test path uses the same cleanup owner. Fake-timer regressions cover early success, early failure, and deadline cancellation.

Evidence

  • 1,762 net production lines removed across 96 production files, plus 84 lines removed from test helpers; 40 removed grandfathered assertions tighten the existing ratchet across 13 paths.
  • Linux Blacksmith Testbox: 156 focused files and 75 importer/cross-shard files passed on original head 3ec6c71d77f9b410612f7b260b8379041fbfe5cf, including 11 routed importer shards. Seven focused/importer suites passed after main reconciliation (52.71s).
  • Exact baseline/candidate comparison passed 8,064 tool-list cases and 288 complete prompts, including cache hits. Both bug regressions failed on the original source for the intended reason, then passed with their fixes.
  • On integrated head e297302c20af475ab096a74043e37b540ca142a9, node scripts/check-changed.mjs passed in 1546.05s, including all 25 test-type shards, lint, dead-export scans, and runtime/storage guards. pnpm build passed in 440.88s; SDK export metadata and surface checks passed in 0.17s and 3.53s. The saved remote result verifies all 42 phases successful plus a clean-source postflight. The local wrapper was killed after the complete remote result; successful checks were not repeated.
  • Independent Codex reviews of the implementation and main reconciliation found no actionable P0–P2 findings. The dependency rebases are patch-identical.

Current head is d0f2cfb6f23390da5dfb273994df2e84b0abbb16, based on Gateway fixture repair 1b96bfdeee4b82d47ab985d03253297aa95ea5ed. Compared with the fully tested e297302c20a tree, only the separate Windows fixture changes; production source, agent tests, and assertion-ratchet bytes are identical. Current-head CI passed: 159 successful jobs, 20 skipped, no failures, including openclaw/ci-gate.

Two existing fixture failures surfaced in hosted CI and have separate repairs. The linked Gateway repair serializes its foreign SQLite mutation and validates the row so integrity rejection cannot mask generation-fence coverage. Its original historical SQLite error was not logged; a real held-writer control reproduced the contention mechanism. The Windows repair is #158693: recovery completed before an overly specific errno assertion rejected EPERM. It now binds errors to completed directory loss and retired watcher generations, and passed real Windows CI. Land the Windows repair, then the Gateway repair, then this PR.

All execution used Blacksmith Testbox. Initial parity/focused proof used tbx_01m3cyfjq9m5c690w27276f2yh (run) and tbx_01m3d3kwtd642mmf4hgg2683xb (run). Final integration used tbx_01m3e22vjgfk1w0c9eyg0tdwj9 (run). These leases and the intervening task leases were confirmed stopped. No local tests, builds, or heavy gates ran.

Changed-test cost

Remote wall time for pnpm test <file> --maxWorkers=1 includes the wrapper. CI seconds sum the reported case durations on final head d0f2cfb6f23; they exclude shared runner startup and are not directly comparable to standalone wall time:

Test file (src/agents/) Wall seconds CI case seconds (sum)
bash-tools.exec.resolve-env-hook.test.ts 19.63 0.530
model-scan.probes.test.ts 2.04 0.005
prepared-model-catalog.test.ts 16.37 0.054
prepared-model-runtime.startup-static.test.ts 18.04 0.844
prepared-model-catalog.scoped-thinking.test.ts 17.08 0.212
live-auth-keys.test.ts 15.20 0.026
live-test-helpers.test.ts 1.68 0.018
Personally inspected Codex source contracts

The exact sibling checkout was inspected at public commit 8f38d5a877da8c5c2c0b5158e72bb5f2290a3157:

@clawsweeper

clawsweeper Bot commented Sep 25, 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: XL labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 3:07 AM ET / 07:07 UTC (Revision 9).

ClawSweeper review

What this changes

The branch consolidates agent execution, provider, prompt, transcript, and workspace paths while preserving plugin environment values on repeated exec preparation and clearing live-test timers after early completion.

Merge readiness

⛔ Blocked before merge - 4 items remain

The earlier agent cleanup is on main, but current main still has two defects addressed here. This branch has distinct, coherent work, so it should remain open.

Priority: P2
Reviewed head: d0f2cfb6f23390da5dfb273994df2e84b0abbb16

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a coherent reduction with focused regression coverage and successful exact-head checks; the stacked base leaves final integration unverified.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The repository-admin PR is exempt from the external-contributor proof gate. Its Blacksmith Testbox record reports prompt and tool parity and original-failing regressions for exec preparation and timer cleanup; the inspected exec regression uses mocked host execution, while exact-head CI passed. No stored-data contract change was identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-admin PR is exempt from the external-contributor proof gate. Its Blacksmith Testbox record reports prompt and tool parity and original-failing regressions for exec preparation and timer cleanup; the inspected exec regression uses mocked host execution, while exact-head CI passed. No stored-data contract change was identified.
Evidence reviewed 10 items Current main retains the exec defect: On a second preparation, the current-main branch calls the preparation marker without its existing state; that marker defaults to an empty state. The PR returns the already prepared arguments instead.
Prepared environment state owner: The preparation marker stores the supplied state and uses an empty object when called without one, establishing why a second call can discard plugin environment metadata.
Current main retains the timeout defect: The current-main helper creates a hard timeout but clears only the abort timer after early settlement. The branch clears both timers.
Findings None None.
Security None None.

How this fits together

The agent runtime turns model requests and tool calls into provider requests, workspace operations, and replies. Shared preparation and policy code determines what those operations may use and how their results are recorded.

flowchart LR
  A[Agent turn] --> B[Model and tool preparation]
  B --> C[Approval and workspace policy]
  C --> D[Provider or tool execution]
  D --> E[Result and transcript projection]
  E --> F[Reply delivery]
Loading

Before merge

  • Resolve merge risk (P1) - The successful test merge and CI run use an unmerged fixture-repair branch as the base. The final integration with current main remains unverified until the stacked repairs land.
  • Complete next step (P2) - Land test(skills): make removed-root watcher checks portable #158693, then test(gateway): stabilize startup orphan generation race #158619, and verify this PR's final main-targeted integration before merge.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/session-transcript-repair.ts, serialized state: src/agents/apply-patch.ts, serialized state: src/agents/workspace-access.ts, unknown-data-model-change: src/agents/apply-patch.ts, unknown-data-model-change: src/agents/session-transcript-repair.ts, unknown-data-model-change: src/agents/workspace-access.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one owner for exec environment preparation and live timeout cleanup, with stable prompt, approval, and transcript behavior in the final main tree.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one owner for exec environment preparation and live timeout cleanup, with stable prompt, approval, and transcript behavior in the final main tree.

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

Yes for the two included defects: current-main source shows the prepared exec state being replaced on a second pass and the hard timeout surviving early completion. This read-only review did not execute either path.

Is this the best way to solve the issue?

Yes. The branch repairs those defects at their existing owners and consolidates repeated paths without an identified public contract change.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is normal-priority agent-runtime cleanup with two bounded fixes and no demonstrated urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository-admin PR is exempt from the external-contributor proof gate. Its Blacksmith Testbox record reports prompt and tool parity and original-failing regressions for exec preparation and timer cleanup; the inspected exec regression uses mocked host execution, while exact-head CI passed. No stored-data contract change was identified.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • onevcat: 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)

Rank-up moves

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

  • Verify the exact main-targeted integration after the two fixture repairs land.

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 (8 earlier review cycles)
  • reviewed 2026-09-25T22:08:56.893Z sha 3ec6c71 :: blocked before merge. :: none
  • reviewed 2026-09-25T22:36:46.542Z sha 3ec6c71 :: blocked before merge. :: none
  • reviewed 2026-09-25T23:21:20.007Z sha 3ec6c71 :: blocked before merge. :: none
  • reviewed 2026-09-26T01:25:26.729Z sha 3ec6c71 :: blocked before merge. :: none
  • reviewed 2026-09-26T04:05:59.268Z sha 3ec6c71 :: blocked before merge. :: none
  • reviewed 2026-09-26T05:17:59.082Z sha e297302 :: blocked before merge. :: none
  • reviewed 2026-09-26T05:28:07.992Z sha e297302 :: blocked before merge. :: none
  • reviewed 2026-09-26T06:15:53.638Z sha e297302 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 25, 2026 22:28
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: d0f2cfb6f23390da5dfb273994df2e84b0abbb16
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/bash-tools.exec-approval-followup.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/bash-tools.exec-approval-request.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/cli-auth-epoch.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/exec-approval-result.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/live-auth-keys.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/models-config.providers.secret-helpers.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/provider-auth-recovery-hint.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/provider-runtime-auth-protection.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/provider-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/transcript-redact-images.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/transcript-redact.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@steipete
steipete marked this pull request as draft September 26, 2026 03:58
@steipete
steipete changed the base branch from main to deslop/l55-startup-orphan-write-admission September 26, 2026 03:58
@steipete
steipete force-pushed the deslop/l55-agents-root-second-pass branch from 3ec6c71 to e297302 Compare September 26, 2026 05:07
@steipete
steipete marked this pull request as ready for review September 26, 2026 05:10
Keep the foreign generation update on a separate SQLite connection while admitting it through the existing per-store writer queue. This prevents maintenance contention from aborting the fixture before it changes the generation.

Mark preparation complete only after the injected change succeeds, so swallowed fixture errors cannot masquerade as an exercised race. Preserve the original assertions, timeouts, and worker policy.
Consolidate repeated execution, provider, catalog, prompt, transcript, lifecycle, and workspace flows under their existing owners while preserving prompt bytes and authority ordering.

Retain prepared plugin environment metadata on repeated exec preparation and clear both live completion timeout timers after early settlement. Cover both defects with original-failing regressions.
@steipete
steipete force-pushed the deslop/l55-startup-orphan-write-admission branch from 237510a to 1b96bfd Compare September 26, 2026 06:27
@steipete
steipete force-pushed the deslop/l55-agents-root-second-pass branch from e297302 to d0f2cfb Compare September 26, 2026 06:28
Base automatically changed from deslop/l55-startup-orphan-write-admission to main September 26, 2026 07:36
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 26, 2026
@steipete
steipete merged commit 67adcce into main Sep 26, 2026
253 checks passed
@steipete
steipete deleted the deslop/l55-agents-root-second-pass branch September 26, 2026 07:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
* test(skills): bind watcher errors to completed root loss

* test(gateway): serialize startup orphan fixture writes

Keep the foreign generation update on a separate SQLite connection while admitting it through the existing per-store writer queue. This prevents maintenance contention from aborting the fixture before it changes the generation.

Mark preparation complete only after the injected change succeeds, so swallowed fixture errors cannot masquerade as an exercised race. Preserve the original assertions, timeouts, and worker policy.

* test(gateway): preserve startup generation fence coverage

* refactor(agents): deslop agents core second pass

Consolidate repeated execution, provider, catalog, prompt, transcript, lifecycle, and workspace flows under their existing owners while preserving prompt bytes and authority ordering.

Retain prepared plugin environment metadata on repeated exec preparation and clear both live completion timeout timers after early settlement. Cover both defects with original-failing regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL 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.

1 participant