Skip to content

refactor(agents): deslop agents - #164566

Merged
steipete merged 2 commits into
mainfrom
deslop/l346-agents-root2-simplify
Oct 4, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l346-agents-root2-simplify

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent runtime code repeats decisions and metadata projections, and retains private options and forwarding layers that have no production consumers.

User Impact

No user-visible behavior change. Configuration keys, persisted data, wire formats, tool descriptions, execution authority, cleanup ordering, and existing lazy-loading boundaries stay intact.

Why This Change Was Made

This second pass removes 937 net production lines in one batch. It follows #163963 and avoids the files reserved by concurrent work.

  • Put MCP manager store creation inside its lifecycle owner, remove the unused session-key writer, and forward existing lease operations directly.
  • Remove unused MCP pagination item projection and its overloads. Keep its deadline, abort, cursor, and size limits; the tests exercise those boundaries without the unused callback.
  • Merge MCP configuration before filtering, preserving configured-server precedence and disabled-server tombstones. Parse HTTP configuration once and reuse its failure reason.
  • Remove the unused model-discovery provider filter and prepared-workspace catalog-purpose options. Keep normalization opt-out, generation fencing, and actual catalog acquisition with their existing owners.
  • Unify model catalog persistence while preserving write/no-op ordering, permissions, and cache invalidation; simplify repeated provider-merge construction.
  • Separate retained restart-recovery claims from new claims instead of repeating the same condition for each field. Preserve omitted-versus-undefined fields and exact media ownership.
  • Share authentication-store inputs and API-key/token fingerprint construction without changing credential precedence or hash tuples. Simplify live key collection and the model-error classifier.
  • Use one tracked-execution map, the canonical runtime-config selector, one memory-flush tool inventory, and direct stable-churn checks.
  • Remove redundant file-tool path machinery, image-resize flags, schema diagnostic wrappers, and duplicate inventory labels. Keep tool text unchanged.
  • Inline one-caller shell snapshot, CLI parser, Code Mode node, computer-capability, and bundle-settings helpers. Preserve workdir validation, executable identity, and capability admission.
  • Consolidate transcript attachment projection, chunk-break selection, raw append storage, and already-sanitized compaction estimates. Keep replay, redaction, and delivery contracts.
  • Reuse owned callback types, simplify sandbox policy normalization and workspace deduplication, and remove comments that only narrate the implementation.

The final result is below the 1,000-line target because five assertion-related cleanup hunks require updates to a baseline file reserved by other open PRs. Those hunks were removed or narrowed; the shared baseline remains untouched. Full size-sorted coverage appears below.

Evidence

  • Independent Codex autoreview at P1 and above: the original candidate was scoped-clean. Fresh rebased-head review raised one unsupported-shell fallback finding, rejected after inspecting the complete owner: maybeWrapCommandWithShellSnapshot returns unchanged unless isSupportedSnapshotShell admits bash/zsh with -c; the private capture function is reachable only through that guarded chain. The existing fish-shell regression passed in prior remote proof, and both source and test are byte-identical after rebase. No accepted/actionable findings remain.
  • AWS Crabbox, Node 24.19.0, pnpm 12.5.1. The pinned base and every changed file hash were verified before execution.
  • Both required import-cycle checks reported zero cycles.
  • Remote proof: 1,891 tests passed across 117 files (six targeted Vitest shards plus the two changed-test-file runs); nine existing skips were retained.
  • Changed-test cost with pnpm test <file> --maxWorkers=1: MCP pagination, 9 tests, 3.99 seconds wall; startup registry, 7 tests, 33.06 seconds cold wall including worker preparation. No new test cases were added.
  • The first focused run caught sparse-array behavior drift in a proposed catalog lookup rewrite. That rewrite was removed completely, and the existing regression passed afterward.
  • Changed-file checks: all source ratchets, formatting, package/plugin boundaries, production types, 27 test type graphs, and unused-export scans passed. Final lint passed after two variable renames and restoration of the original cleanup aggregation/stringifier. The remaining database, media, sidecar, webhook, and pairing guards passed; final focused delta tests passed. Hosted CI gates the pushed head.
  • Infrastructure: Testbox admission expired; broker and capacity failures required a serial low-priority fallback. A stale local Mermaid 11.17.2 link was refreshed to locked 12.0.0. Fresh AWS proof passed the formerly blocked gateway graph. Both used AWS leases have been released.
  • Remote commands included pnpm install --frozen-lockfile, targeted node scripts/run-vitest.mjs selections, pnpm test <changed test file> --maxWorkers=1, and node scripts/check-changed.mjs. Both cycle scripts ran with node --import ./scripts/tsx.mjs. AWS leases cbx_0ab3436d1084 and cbx_87f23e3b1451 are released. Blacksmith Testbox tbx_01m41dx2gg864tk73z5y1h39b1 expired before hydration and is confirmed stopped. Remaining focused checks used the authorized serial nice -n 15 local fallback after broker/capacity failures.
  • No full build, live provider calls, or visual changes.

Landing Failure Attribution

The unchanged src/agents/compaction.tool-result-details.test.ts was run on three clean revisions on Blacksmith Testbox tbx_01m426me67tfjtmr543r9bq0bm (runner), using Node 24.19.0, pnpm 12.5.1, a frozen-lockfile install, and node scripts/run-vitest.mjs src/agents/compaction.tool-result-details.test.ts:

Revision Result Wrapper wall
Original PR head b24817f66be9cf78d258adcaf7b0714bad5a0340 3 passed 23.99s
Clean main affb994cf4193ff967b0f792b4634435d3942948 3 passed 22.51s
Main used by failed CI 4bcd6956b0a431b3d7024f1ad13095947c242bf8 2 passed, 1 failed with the identical extra runtime-context message 22.60s

CI run 37161724319, job checks-node-changed-compact-small-14, tested merge 26dc332222e3a758b5bd3321057b934da631a12f against that failing main revision. The privacy filter had been narrowed to provider replay authority. Upstream producer fix ccc0020633ba98fc0e930a98df2c05d13d5b9dd8 restores filtering of reserved private runtime entries without granting replay authority or rewriting transcript bytes. This PR does not change the failing test or its assertions.

The conflict-free rebase onto b284ad2971f4ec4354e0d2143980502bb3418dae includes that fix and the Knip Linux-entry repair bf4fe3ace5702c98c669e298e918b204d60d1b8d. Range comparison confirms the production cleanup is patch-identical. Rebased head: 7b4c90e92274344bebde156a6530fe73b8d2f393; production reduction remains 937 lines. The exact rebased tree (710391ea74f7184ef39c065e4622d36cc98b3251) passed both cycle checks (zero cycles), production types, agents-root and agents-other test types, and all 131 focused tests across 10 files. Focused tests took 26 seconds wall. The first test-type invocation used noncanonical graph names and failed before compilation; the corrected canonical selectors passed. Fresh independent review is complete; its sole unsupported-shell finding is rejected with the owner-path evidence above. Exact-head CI run 37168194695 passed. GitHub squash-merged the pinned head as 91e9b93bcebd821474415d3daa8e9de4a566e1c3; ancestry on main and the landed reduction of 937 net production lines are verified. No admin exception was needed. Both resumed Testbox leases are stopped; the cancelled AWS allocation cbx_89ee4a0d1958 is absent from the coordinator on authoritative inspection.

Coverage: every root production file over 200 lines, largest first

l346 agents root coverage

Read-only scope: root-level production files in src/agents, sorted by starting size. Reserved files were read and retained untouched.

  • 1596 lines — src/agents/bash-tools.exec-host-gateway.ts — READ: retained untouched due explicit cron closure; standing-grant validation/consumption, mutable-operand binding and post-approval dispatch each retain their authority owner.
  • 1554 lines — src/agents/model-selection-shared.ts — READ: Alias scope, configured-route precedence, literal versus display identities, and wildcard/manual-selection authorization have separate documented contracts; retained.
  • 1520 lines — src/agents/agent-tools.read.ts — READ: Retained: l331 touched this file; paging, namespace guards, immutable skill delivery, and write provenance each protect distinct contracts.
  • 1517 lines — src/agents/model-auth-availability.ts — READ: Auth source precedence, selected-profile authority, cooldowns, and native runtime evidence are distinct; l331 already consolidated its safe shared paths.
  • 1404 lines — src/agents/btw.ts — READ: | 1404 | src/agents/btw.ts | READ | Shared nonprompting auth-store construction and selection inputs; kept generation binding, admitted authority, and CLI/harness fallback ordering.
  • 1219 lines — src/agents/workspace.ts — READ: Bootstrap seeding, persisted completion reconciliation, disappearance protection, and source-identity filtering have separate live contracts; no sound in-scope reduction found.
  • 1128 lines — src/agents/agent-bundle-mcp-runtime.ts — READ: transport reuse, catalog generations, retirement joining and backoff all enforce active lifecycle contracts; no safe large removal.
  • 1120 lines — src/agents/system-prompt.ts — READ: | 1120 | src/agents/system-prompt.ts | READ | Retained byte-sensitive capability/prompt assembly and stable-prefix boundaries; Automations/cron prompt closure is protected.
  • 974 lines — src/agents/bash-tools.exec-runtime.ts — READ: retained untouched due exact overlap; finalization settles descendants, sandbox cleanup, secret egress revocation and notification before releasing process ownership.
  • 790 lines — src/agents/provider-transport-fetch.ts — READ: SSE adaptation, bounded non-OK bodies, exact-origin SSRF trust and local-service lease cleanup preserve different transport contracts.
  • 759 lines — src/agents/code-mode-execution.ts — READ: Inline execution, parked resumes, approval budget credit, and required-completion settlement have distinct ownership and ordering contracts.
  • 753 lines — src/agents/provider-request-config.ts — READ: Header/auth allowlisting and attribution boundaries are intentional; direct option forwarding could admit previously ignored caller fields, so retained.
  • 749 lines — src/agents/bash-tools.exec-run.ts — READ: Retained host dispatch, foreground/background settlement and approval authority; prior l331 file with cron-facing options.
  • 748 lines — src/agents/prepared-model-catalog-worker.ts — READ: Shared worker rotation, borrower recovery, request fencing and exact-generation fingerprints remain necessary; no sound reduction identified.
  • 746 lines — src/agents/model-fallback-runner.ts — READ: Fallback, cooldown probe, harness-local failure, replay and deferred suspension policies have distinct terminal conditions; retained.
  • 746 lines — src/agents/github-tool-identity.ts — READ: profile isolation, selected-identity fencing, publication snapshots and atomic credential installation are distinct contracts.
  • 744 lines — src/agents/prepared-model-runtime.ts — READ: Publication queue, auth adoption, degraded startup and standalone admission have distinct lifecycle responsibilities; retained.
  • 743 lines — src/agents/transcript-redact.ts — READ: Retained provider-signed replay validation, copy-on-write identity, source provenance, and structured redaction boundaries.
  • 743 lines — src/agents/agent-create.ts — READ: | 743 | src/agents/agent-create.ts | READ | Reserved by an open PR; retained creation/deletion/config-publication recovery ownership.
  • 739 lines — src/agents/embedded-agent-block-chunker.ts — READ: Unified ordered paragraph/newline break selection; retained fenced-code, table, surrogate, and source-coordinate recovery.
  • 736 lines — src/agents/embedded-agent-subscribe.stream-rendering.ts — READ: Retained independent hidden/visible code parser state and confirmed source-delivery deduplication.
  • 727 lines — src/agents/agent-tools.before-tool-call.diagnostics.ts — READ: Retained: skill matching, private capture, diagnostic identity, and loop settlement have distinct consumers and trust boundaries.
  • 727 lines — src/agents/agent-command.ts — READ: | 727 | src/agents/agent-command.ts | READ | Reserved by an open PR; retained ingress admission, session rollover, restart recovery, and settlement ordering.
  • 724 lines — src/agents/failover-error.ts — READ: | 724 | src/agents/failover-error.ts | READ | Retained distinct depth-first CLI error selection and provider classification; breadth-first shared traversal would change precedence.
  • 721 lines — src/agents/model-auth-provider-config.ts — READ: Auth provenance, secret markers, provider bindings and inline cooldown contracts prevent credential substitution; retained.
  • 720 lines — src/agents/cli-output-stream.ts — READ: Inlined one-use message-reset wrapper and removed an already-guarded custom-line error branch; retained transcript/tool-split projection.
  • 720 lines — src/agents/agent-bundle-mcp-materialize.ts — READ: model tool projections, App-only policy projections and requester sign-in projections have different visibility/execution semantics.
  • 715 lines — src/agents/plugin-model-catalog.ts — READ: Doctor sidecar claim/recovery, compare-and-set publication and SQLite ownership are required migration and credential-preservation contracts.
  • 715 lines — src/agents/agent-tools.before-tool-call.wrapper.ts — READ: Retained: preparation, approvals, steering, live authority recheck, execution, and terminal settlement must remain ordered.
  • 712 lines — src/agents/prepared-model-runtime.catalog-access.ts — READ: Read in full by models lead; reserved open-PR file left untouched. Concurrent provider/native publication and auth fencing remain owner contracts.
  • 709 lines — src/agents/prepared-model-runtime.owner.ts — READ: Owner lookup, normalization and atomic build publication preserve directory/config/generation isolation; retained.
  • 703 lines — src/agents/agent-scope.ts — READ: | 703 | src/agents/agent-scope.ts | READ | Retained explicit/default/fallback distinctions, primary-probe state and released session/workspace selection contracts.
  • 702 lines — src/agents/model-fallback-attempt.ts — READ: Terminal abort and deferred suspension classification import the excluded cron lifecycle owner; retained.
  • 700 lines — src/agents/code-mode-state.ts — READ: Live-owner disposal, bridge reply custody, expiry, and settled-frontier ordering are substantive; recent perf(agents): bound per-run retained state and share registry snapshots by revision #164199 changes excluded from edits.
  • 698 lines — src/agents/cli-output-records.ts — READ: Collapsed repeated nested error-field extraction, removed redundant empty/falsy guards and one-use unwrap-policy adapter; derive dialect once per parse.
  • 695 lines — src/agents/prepared-model-runtime.full-catalog.ts — READ: Inventory retention and runtime projection preserve auth pairing, provider order and native provenance; retained.
  • 693 lines — src/agents/tool-loop-detection.ts — READ: Retained: l331 file; detector ordering and result-specific no-progress hashes preserve distinct user-visible interventions.
  • 681 lines — src/agents/model-catalog-view.ts — READ: Logical and physical donor projections, revocable native observations and picker/status preparation are distinct live flows.
  • 681 lines — src/agents/cli-output-events.ts — READ: Retained separate provider adapters, tool de-duplication and per-content-block thinking state; apparent duplication reflects distinct wire semantics.
  • 676 lines — src/agents/simple-completion-runtime.ts — READ: Prepared auth, route materialization and transferred lease settlement remain necessary; previous l331 pass already simplified this flow.
  • 675 lines — src/agents/provider-local-service.ts — READ: Shared startup, per-request cancellation, process-tree shutdown and idle leases require their current fencing; shared abort helper has different error semantics.
  • 675 lines — src/agents/admitted-run-context.ts — READ: | 675 | src/agents/admitted-run-context.ts | READ | Protected audit closure; live source-authority and one-shot recovery gates are not accidental complexity.
  • 674 lines — src/agents/prepared-model-runtime.facts.ts — READ: Removed unused workspace build options; retained original cleanup aggregation to preserve the original cause and cleanup failures.
  • 673 lines — src/agents/model-auth-provider.ts — READ: Explicit profile, per-entry binding, env-first and synthetic deferral branches preserve credential precedence and error contracts.
  • 670 lines — src/agents/tool-catalog.ts — READ: Retained: pure catalog data drives shipped profiles/UI; overlaps Automations closure.
  • 669 lines — src/agents/bash-tools.process.ts — READ: retained untouched due exact overlap; poll acknowledgment, retained-output recovery and writable-stdin authority are distinct process contracts.
  • 668 lines — src/agents/cli-runner.ts — READ: retained untouched due exact overlap and cron generation closure; admission, native continuity, hooks and delivered-effect settlement have separate failure lifetimes.
  • 667 lines — src/agents/models-config.providers.implicit.ts — READ: Reserved by another open PR; read in full but left untouched. Discovery option consumers use values and truthiness, not property-presence gates.
  • 667 lines — src/agents/isolated-completion.ts — READ: CLI and harness isolation, authority revalidation, exact-profile retries and inference budgets are real execution contracts.
  • 665 lines — src/agents/tool-search-runtime.ts — READ: Retained: schema admission, final-input validation, queued generation checks, and network taint follow separate lifecycle contracts.
  • 662 lines — src/agents/tool-display-exec-shell.ts — READ: Retained: l331 file; lexical states distinguish redirects, quotes, arithmetic, heredocs, and compound syntax.
  • 660 lines — src/agents/session-tool-result-guard.ts — READ: Simplified before-write hook projection and clarified pending-call comments; retained sync/async persistence adapters, recorder callbacks and committed receipts.
  • 656 lines — src/agents/bash-tools.exec-host-node-phases.ts — READ: Retained prepared-command vs semantic-command approval analyses; their independent policy checks are necessary authority boundaries.
  • 655 lines — src/agents/bash-tools.exec-host-node.ts — READ: Retained inline vs detached approval settlement and fresh-policy revalidation; direct reorganization would obscure distinct lifetimes.
  • 655 lines — src/agents/agent-tools.policy.ts — READ: Retained: scheduled authority and group/profile policy precedence overlap Automations closure.
  • 648 lines — src/agents/tool-display-exec.ts — READ: Retained: l331 file; command-specific parsers preserve redacted labels and conservative shell fallbacks.
  • 645 lines — src/agents/embedded-agent-subscribe.handlers.tools.completion.ts — READ: Retained terminal side-effect/delivery evidence; heartbeat and Automations integration belongs to concurrent owner.
  • 644 lines — src/agents/provider-attribution.ts — READ: Provider host classification and opt-in attribution metadata are externally observable; no safe metadata or endpoint-policy deletion.
  • 642 lines — src/agents/agent-bundle-lsp-runtime.ts — READ: reserved overlap; no edits.
  • 640 lines — src/agents/embedded-agent-subscribe.handlers.messages.update.ts — READ: Retained provider phase reconciliation and append/snapshot paths required by queued mutable partials.
  • 639 lines — src/agents/apply-patch.ts — READ: Retained: l331 file; ordered queue ownership, exclusive creates, moves, and no-op accounting are behavior-bearing.
  • 636 lines — src/agents/agent-tool-definition-adapter.ts — READ: Simplified: removed one-use sanitization forwarding helper and redundant result-coercion intermediates.
  • 621 lines — src/agents/cli-executable-identity.ts — READ: Unified file realpath/open failure handling and POSIX result assembly; inlined the one-use stable-sort comparator without changing hashing or admission.
  • 620 lines — src/agents/model-catalog-decisions.ts — READ: Personal-account projections, native readiness revocation and selected-account discovery cannot be merged with shared inventory; l331 file retained.
  • 617 lines — src/agents/prepared-model-catalog.worker.ts — READ: Worker reconstruction, auth refresh, provider discovery and resource settlement are live paths; catalog acquisition already uses the direct registry owner.
  • 614 lines — src/agents/agent-tools.ts — READ: Retained: runtime tool assembly includes Automations/heartbeat closure and owner-bound execution policy.
  • 606 lines — src/agents/agent-scope-config.ts — READ: | 606 | src/agents/agent-scope-config.ts | READ | Reserved by an open PR; retained roster ownership and exact batch-cache invalidation behavior.
  • 594 lines — src/agents/prepared-model-catalog.ts — READ: Published/read-only/admitted catalog paths enforce different config and lease contracts; their fallbacks are intentional.
  • 594 lines — src/agents/mcp-ui-resource.ts — READ: bounded view ownership, per-request authority and resource metadata fallbacks are needed by supported external MCP Apps.
  • 592 lines — src/agents/embedded-agent-subscribe.handlers.tools.start.ts — READ: Retained synchronous start ordering, question reservation cancellation, and execution activity accounting.
  • 586 lines — src/agents/prepared-model-runtime.build.ts — READ: Batch sharing, per-directory serialization and timeout observer versus work completion contracts are intentional; retained.
  • 585 lines — src/agents/openclaw-tools.ts — READ: Retained: factory registration includes Automations/heartbeat closure; placement, sender, client, and runtime availability stay separate.
  • 578 lines — src/agents/mcp-oauth.ts — READ: refresh, browser start/callback, cancellation and scope challenge flows retain separate lease/authority boundaries.
  • 574 lines — src/agents/embedded-agent-subscribe.handlers.tools.results.ts — READ: Prior l331 changes; retained approval delivery, media custody, shell reminder evidence and lazy hook loading.
  • 571 lines — src/agents/bash-tools.exec-request-preparation.ts — READ: Retained l331 environment/workdir prepared-state lifecycle and host-specific environment trust boundaries.
  • 568 lines — src/agents/code-mode-namespaces.ts — READ: Inlined the one-caller prompt projection wrapper and removed its redundant empty-server branch while preserving prompt bytes.
  • 565 lines — src/agents/agent-run-terminal-outcome.ts — READ: | 565 | src/agents/agent-run-terminal-outcome.ts | READ | Retained documented terminal precedence and shipped harness-result normalization; phase/abort/failure observations are independently meaningful.
  • 564 lines — src/agents/agent-bundle-mcp-manager-lifecycle.ts — READ: folded the one-caller store factory into its lifecycle owner; per-key serialization, transferred capacity and cleanup receipts retained.
  • 563 lines — src/agents/bash-tools.exec-approval-followup.ts — READ: excluded from edits because denied-followup routing contains cron-specific ownership policy.
  • 560 lines — src/agents/embedded-agent-subscribe.reply-delivery.ts — READ: Retained reentrant synchronous callbacks, deferred settlement, source-media restoration and commentary identities.
  • 553 lines — src/agents/model-catalog.ts — READ: Logical and physical route merges use different keys and donor rules; catalog sorting and provider ordering remain observable.
  • 549 lines — src/agents/prepared-model-runtime.configured-refresh.ts — READ: Remote catalog adoption stages candidates privately and fences captured owners before commit; retry and cleanup paths are required.
  • 549 lines — src/agents/provider-http-errors.ts — READ: Bounded reads, reflected-secret redaction, error metadata and content-family validation protect distinct external response contracts.
  • 549 lines — src/agents/agent-tools.before-tool-call.approval.ts — READ: Simplified: embedded and Gateway approval transports share requester identity projection; inlined one-use timeout helper.
  • 546 lines — src/agents/provider-model-route-auth.ts — READ: Auth ownership, declared versus ambient credentials, route preferences and exact-route attempts are contract-bearing decisions.
  • 537 lines — src/agents/code-mode-node.worker.ts — READ: Host/guest validation, source-stack mapping, output capture, and boundary protocol remain necessary across two execution states.
  • 530 lines — src/agents/exec-auto-reviewer.ts — READ: retained untouched due exact overlap; duplicate-key rejection and late model-preparation/transport custody protect the review result and cleanup boundary.
  • 526 lines — src/agents/embedded-agent-subscribe.ts — READ: Retained subscription and compaction lifetime owner; public getters are consumed by attempt lifecycle.
  • 524 lines — src/agents/workspace-access.ts — READ: Capability-specific pre/post-await fences, Memory publication semantics, and watch cancellation prevent a generic forwarding replacement.
  • 523 lines — src/agents/code-mode-bridge.ts — READ: Removed node list/call forwarding layers and the redundant node-projection return DTO; dispatcher validation and policy calls remain unchanged.
  • 520 lines — src/agents/tool-search-catalog.ts — READ: Retained: executor rebinding, schema identity fingerprints, generation teardown, and client-shadow precedence each protect retained catalogs.
  • 519 lines — src/agents/shell-snapshot.ts — READ: Inlined snapshot capture builders and simplified forceRefresh options; retained the directory helper because its assertion baseline is reserved.
  • 518 lines — src/agents/bash-process-registry.ts — READ: retained untouched due exact overlap; pending poll delivery, hidden live process ownership and finished retention cannot share one lifecycle map.
  • 506 lines — src/agents/cli-credentials.ts — READ: Retained distinct Codex Keychain/file fallback, Gemini identity extraction and MiniMax token parsing; credential freshness and cache invalidation have source-specific contracts.
  • 505 lines — src/agents/workspace-state-store.kernel.ts — READ: Database identity, attestation admission, migration receipts, and deletion contracts need retained validation; no schema/durability edit attempted.
  • 504 lines — src/agents/bash-tools.exec-host-shared.ts — READ: retained untouched due exact overlap and cron policy; timeout fallback cannot mint human approval and followup handoff must retain its owning route.
  • 503 lines — src/agents/code-mode-controller-source.ts — READ: Guest queue quotas, network provenance, immutable handles, and final-value serialization have concrete runtime contracts.
  • 503 lines — src/agents/agent-command-restart-recovery.ts — READ: | 503 | src/agents/agent-command-restart-recovery.ts | READ | Returned preclaimed recovery projection early and removed repeated adoption branches; omitted/undefined fields and sourceRunId truthiness are preserved.
  • 502 lines — src/agents/github-oauth-client.ts — READ: strict external response parsing and credential-cache generations protect different wire and revocation contracts.
  • 495 lines — src/agents/embedded-agent-tool-results.ts — READ: Removed redundant non-error status exclusions and handwritten structured-result collection.
  • 482 lines — src/agents/usage.ts — READ: Provider-specific aliases and context/cache accounting are active wire and persisted-data shapes; adapters intentionally differ.
  • 477 lines — src/agents/tool-schema-hints.ts — READ: Retained: compact/declaration modes have different completeness and traversal bounds; combining them would change model-facing text.
  • 473 lines — src/agents/embedded-agent-utils.ts — READ: Retained full versus incremental thinking extraction, content-phase fallback, and public reasoning rendering.
  • 468 lines — src/agents/cron-creator-authority-context.ts — READ: | 468 | src/agents/cron-creator-authority-context.ts | READ | Protected cron/heartbeat lane and reserved; no edits.
  • 466 lines — src/agents/code-mode-headless.ts — READ: Headless wall-clock/tool budgets and injected namespaces serve the cron owner; left unchanged to avoid heartbeat closure.
  • 461 lines — src/agents/model-auth-model.ts — READ: Auth mode reporting, profile checks and secret-header sentinelization are active; forwarding wrapper retained to preserve its narrower option boundary.
  • 456 lines — src/agents/media-generation-task-status-shared.ts — READ: | 456 | src/agents/media-generation-task-status-shared.ts | READ | Retained real shared media-tool status owner, cache expiry/identity semantics and model-facing prompt bytes; l331 already consolidated it.
  • 455 lines — src/agents/tool-call-id.ts — READ: Consolidated native-ID preservation branches; retained the existing transcript rewrite casting and accounting because its assertion baseline is reserved.
  • 454 lines — src/agents/prepared-model-runtime-lease.ts — READ: Admission/rebind, configured reuse, retained parent generations and dynamic owner lifetime have distinct authority rules; retained.
  • 452 lines — src/agents/agent-tools.before-tool-call.policy.ts — READ: Retained: trust/voice/owner/normal hook ordering and final approval reconciliation prevent rewritten arguments bypassing decisions.
  • 450 lines — src/agents/agent-bundle-mcp-harness.ts — READ: static and requester paths intentionally differ in stable catalogs and approval behavior; Codex contract untouched.
  • 446 lines — src/agents/core-coding-tools.ts — READ: Retained: host/sandbox/remote-skill routes intentionally differ in filesystem namespace and read-only exception admission.
  • 443 lines — src/agents/agent-steering-queue.ts — READ: | 443 | src/agents/agent-steering-queue.ts | READ | Retained lease/current-owner checks and exact result identity projection; acknowledgment and release have different durable effects.
  • 442 lines — src/agents/prepared-model-runtime-auth-publication.ts — READ: Overlapping auth changes require component atomicity, FIFO handling and independent owner gates; retained.
  • 440 lines — src/agents/sandbox-host.ts — READ: CSP validation and isolated-frame bridges are security/visible shell contracts; no behavior-neutral structural reduction found.
  • 439 lines — src/agents/session-tool-result-guard.payload.ts — READ: Retained byte budget and secret-boundary overlap safety; generic JSON helpers differ in accounting contract.
  • 437 lines — src/agents/agent-bundle-mcp-manager.ts — READ: lifecycle now creates its own store; removed uncalled bindSessionKey writer and a trivial active-lease forwarding wrapper.
  • 436 lines — src/agents/model-runtime-choice.ts — READ: Model availability, native renewal and commit-time validation share captured owners but retain distinct execution semantics.
  • 436 lines — src/agents/tool-mutation.ts — READ: Retained: replay safety and mutation are distinct; classification includes Automations closure.
  • 433 lines — src/agents/embedded-agent-message-delivery.ts — READ: Retained plugin-envelope compatibility, delivery receipts, partial/broadcast semantics and current-source qualification.
  • 427 lines — src/agents/embedded-agent-messaging-extraction.ts — READ: Collapsed repeated attachment field projection into typed string and numeric key loops; retained route/thread ownership.
  • 426 lines — src/agents/bash-tools.exec-workdir.ts — READ: Removed three-way normalized-input DTO and repeated host mapping fields; replaced duplicate-root builder with ordered Set normalization.
  • 425 lines — src/agents/models-config.providers.secrets.ts — READ: Profile-first versus env-first discovery and opaque secret materialization have deliberate precedence differences.
  • 422 lines — src/agents/tool-display-common.ts — READ: Retained: l331 file; bounded rendering, metadata access order, and secret redaction are observable contracts.
  • 419 lines — src/agents/bootstrap-files.ts — READ: Hook filtering, pinned source protection, personal overlays, and automatic-memory provenance retain distinct necessary boundaries.
  • 419 lines — src/agents/bash-tools.exec-script-ambiguity.ts — READ: Retained l331 lexical parser and distinct pipeline/segment heuristics; unifying them would change ambiguous-command admission.
  • 419 lines — src/agents/embedded-agent-subscribe.handlers.messages.stream.ts — READ: Used canonical safe JSON record parser for standalone message-tool text; retained provider phase helpers.
  • 412 lines — src/agents/code-mode-node.ts — READ: Warm pool custody, lifecycle retirement, watchdog delivery, and continuation disposal enforce native-resource ownership.
  • 410 lines — src/agents/shell-utils.ts — READ: Retained platform-specific executable lookup and WSL stdin transport; seemingly repeated PATH logic has different precedence/empty-entry contracts.
  • 407 lines — src/agents/internal-runtime-context.ts — READ: | 407 | src/agents/internal-runtime-context.ts | READ | Reserved by an open PR; retained nesting-aware stripping and current/retained carrier ownership.
  • 405 lines — src/agents/embedded-agent-subscribe.handlers.lifecycle.ts — READ: Retained sync/async terminal callbacks and once-only lifecycle emission across failure and continuation paths.
  • 404 lines — src/agents/models-config.ts — READ: Unified plugin catalog writes after root-file handling, removed forwarding wrapper and duplicate source/read result construction; preserved write/noop chmod ordering.
  • 403 lines — src/agents/model-auth-runtime.ts — READ: Synchronous availability and asynchronous preparation share one owner already; synthetic/managed secret authority and runtime snapshots remain distinct.
  • 402 lines — src/agents/cli-auth-epoch.ts — READ: retained untouched due exact overlap; reusable-session epochs intentionally differ from strict credential and executable-owner fingerprints.
  • 402 lines — src/agents/mcp-http-transport.ts — READ: SSE and Streamable HTTP adapters handle distinct SDK cleanup/reconnect gaps; streaming bounds must remain incremental.
  • 397 lines — src/agents/tool-images.ts — READ: Simplified: removed unused resize-result flag, unified source diagnostic fields, removed redundant text-block alias and path intermediates.
  • 395 lines — src/agents/spawn-plan.ts — READ: Shared spawn owner already combines ACP/subagent policy; the remaining branches distinguish channel placement and admission contracts.
  • 395 lines — src/agents/model-scan.ts — READ: Catalog field parsing and separate tool/image probes protect provider payload and inference contracts; no safe structural deletion.
  • 395 lines — src/agents/session-transcript-repair.ts — READ: Retained provider replay and orphan pairing contracts; legacy finalized partialJson repair has an explicit persisted contract.
  • 392 lines — src/agents/sandbox-paths.ts — READ: Cross-platform lexical paths, canonical prefixes, symlink guards, and managed-media exceptions cannot safely be collapsed.
  • 388 lines — src/agents/tools-effective-inventory.ts — READ: Retained: static model admission avoids provider discovery; dynamic lease ownership and policy notices are substantive.
  • 384 lines — src/agents/code-mode-json.ts — READ: Cumulative source receipts and bounded output/value/error fitting deliberately separate source retention from delivery.
  • 382 lines — src/agents/model-fallback-candidates.ts — READ: Cache identities preserve plugin generations and authored selections; explicit and image fallback collection retain different source precedence.
  • 382 lines — src/agents/agent-lifecycle-registry.ts — READ: | 382 | src/agents/agent-lifecycle-registry.ts | READ | Reserved by an open PR and cron closure; retained journal/lease authority and commit-versus-cleanup boundaries.
  • 380 lines — src/agents/auth-health.ts — READ: Provider rollups preserve explicit profile order and expiry evidence; l331 already simplified this area.
  • 378 lines — src/agents/models-config.merge.ts — READ: Replaced a plain-object factory with its concrete value and removed single-use provider API forwarding helper; route/cost/secret merge semantics retained.
  • 378 lines — src/agents/runtime-plugins.ts — READ: | 378 | src/agents/runtime-plugins.ts | READ | Retained distinct inspection versus loaded-registry lifetimes, borrowed invocation custody and generation-bound donors.
  • 377 lines — src/agents/openclaw-plugin-tools.ts — READ: Retained: authority-bound delivery, registry freshness, requester owner binding, and live credential selection are distinct obligations.
  • 377 lines — src/agents/code-mode-mcp-api.ts — READ: Schema documentation preserves enum/null/union and index-signature semantics; no safe shared implementation with different native-tool schema renderer.
  • 374 lines — src/agents/prepared-model-runtime.configured.ts — READ: Configured model and provider selection preserve authored routes, static fallback precedence and exact runtime scoping; retained.
  • 374 lines — src/agents/internal-events.ts — READ: | 374 | src/agents/internal-events.ts | READ | Retained plain/protected/data projections and per-media trust aggregation; visible and model-facing byte contracts differ deliberately.
  • 371 lines — src/agents/prepared-model-runtime.plugin-lifetime.ts — READ: Physical registry custody, finite plugin work, publication retirement and shutdown error observation are separate live contracts; retained.
  • 370 lines — src/agents/model-runtime-policy.ts — READ: Exact model, wildcard, provider and inherited runtime policy each have documented precedence and ambiguity behavior.
  • 370 lines — src/agents/compaction-planning.ts — READ: Reused already-sanitized messages for summary token estimates and removed narrating comments; retained atomic tool grouping, pruning order and safety margins.
  • 368 lines — src/agents/session-tool-result-guard-wrapper.ts — READ: Derived installed guard methods from the guard owner instead of redeclaring callback signatures.
  • 368 lines — src/agents/code-mode.ts — READ: Catalog prompt construction and exec/wait tool registration expose distinct user/model-facing contracts; kept prompt text unchanged.
  • 365 lines — src/agents/tool-search.ts — READ: Retained: bounded grouped-search projection and direct-call forwarding preserve control descriptions and network-bound output handling.
  • 364 lines — src/agents/workspace-state-store.ts — READ: Worker admission, commit receipt publication, and CLI deletion ownership cannot be removed without storage-boundary changes.
  • 356 lines — src/agents/tool-display-config.ts — READ: Retained: already compact declarative metadata; action-specific detail fields and display bytes are user contracts.
  • 356 lines — src/agents/compaction.ts — READ: Prior l331 changes; retained recoverable partial summaries, bounded retries and model-visible chronology.
  • 352 lines — src/agents/tool-search-ranking.ts — READ: Retained: BM25 scoring, stem variants, stopwords, expansion weighting and tie order preserve search behavior.
  • 351 lines — src/agents/github-read-identity.ts — READ: absence proof, host selection, token rotation and live read authority are active behavior.
  • 349 lines — src/agents/embedded-agent-subscribe.handlers.messages.lifecycle.ts — READ: Retained terminal reasoning order, source snapshot reconciliation and late-event parser state.
  • 343 lines — src/agents/embedded-agent-subscribe.handlers.types.ts — READ: Prior l331 changes; retained shared mutable owner contract rather than introducing inferred cross-module cycles.
  • 343 lines — src/agents/run-wait.ts — READ: | 343 | src/agents/run-wait.ts | READ | Reserved by an open PR; preserved terminal receipt versus display-history evidence and retry-grace semantics.
  • 342 lines — src/agents/session-activity-notes.ts — READ: Streaming assembly, internal-context quarantine, and distinct event projections are observable; heartbeat imports excluded from changes.
  • 342 lines — src/agents/apply-patch-update.ts — READ: Simplified: inlined the single-use default read adapter; retained mixed line endings, exact/tolerant tiers, and ambiguous-match diagnostics.
  • 340 lines — src/agents/model-fallback-observation.ts — READ: Log coalescing retains suppressed counts and time-based eviction; observation metadata and model-facing output stay unchanged.
  • 338 lines — src/agents/mcp-oauth-store.kernel.ts — READ: persisted-row validation and existing-schema reads retained; storage admission redesign is outside this cleanup.
  • 337 lines — src/agents/model-runtime-aliases.ts — READ: CLI aliases, stored profile authority and explicit runtime policy remain active interoperability contracts.
  • 336 lines — src/agents/workspace-alias-rebind.ts — READ: Confirmed workspace moves require filesystem spellings, directory identity, transaction checks, and receipt ownership.
  • 334 lines — src/agents/models-config.providers.secret-helpers.ts — READ: SecretRef, env-marker and provider-key provenance remain distinct; recent secret migration changes retained.
  • 333 lines — src/agents/models-config.plan.ts — READ: Replaced unnecessary conditional object spreads for already optional discovery fields with direct properties; retained workspace truthiness boundary.
  • 333 lines — src/agents/tool-policy.ts — READ: Retained: policy intersections and shipped name families are public configuration semantics, not obsolete aliases.
  • 331 lines — src/agents/codex-mcp-config.ts — READ: native header/env and per-tool approval projection retained; Codex contract untouched.
  • 330 lines — src/agents/session-placement-admission.ts — READ: Placement owner capture, queue admission, and forced-terminal settlement fence different lifecycle transitions.
  • 329 lines — src/agents/mcp-connection-resolver.ts — READ: reserved overlap; no edits.
  • 326 lines — src/agents/cli-backends.ts — READ: retained untouched due exact overlap; runtime and setup registries have deliberately different availability and provider-alias precedence.
  • 324 lines — src/agents/live-model-switch.ts — READ: Pending switch compare-and-clear and post-run consolidation have different authority checks; preserved synchronous storage and Codex compatibility owner.
  • 323 lines — src/agents/agent-bundle-mcp-combined.ts — READ: facade retains server ownership and catalog replay semantics; generic dispatch would add type machinery.
  • 320 lines — src/agents/cli-session.ts — READ: skipped edits because git log --since=24.hours identifies recently landed fix: retain CLI conversations when child completions arrive #164378 touching its continuity contract.
  • 320 lines — src/agents/execution-auth-binding.ts — READ: | 320 | src/agents/execution-auth-binding.ts | READ | Unified API-key/token hash tuple construction while preserving exact tuple order and API-key-only metadata.
  • 319 lines — src/agents/model-catalog-visibility.ts — READ: Prepared membership and revocable readiness require separate phases; wildcard/default/configured visibility and physical donor ordering retained.
  • 319 lines — src/agents/context-resolution.ts — READ: | 319 | src/agents/context-resolution.ts | READ | Consolidated identical fixed-1M constants and branches while retaining provider eligibility and old-model CLI opt-in.
  • 311 lines — src/agents/workspace-legacy-state.ts — READ: Legacy inputs retain current Doctor migration/reset contracts; complete retirement requires changes outside this assigned root-only scope.
  • 301 lines — src/agents/bash-tools.exec-script-preflight.ts — READ: Retained Python lexical stack, literal-tilde fs-safe path and bounded nonblocking reads; each protects an observed entry-point distinction.
  • 299 lines — src/agents/tool-loop-admission.ts — READ: Retained: batch projection, prepared-call markers, validation-failure recording, and FIFO commit order cannot merge into single-call admission.
  • 299 lines — src/agents/embedded-agent-tool-media.ts — READ: Retained unchanged: trust-helper consolidation needs a shrink in the assertion baseline reserved by other open lanes.
  • 297 lines — src/agents/pty-keys.ts — READ: Retained: l331 file; key tables encode exact PTY bytes and modifier/DECCKM semantics.
  • 294 lines — src/agents/identity-file.ts — READ: Markdown merge, bounded file admission, worker loading, and shipped synchronous SDK reader have separate required contracts.
  • 293 lines — src/agents/compaction-planning-projection.ts — READ: Retained bounded UTF-16/CJK-weighted argument accounting; byte-count helpers have a different contract.
  • 292 lines — src/agents/prepared-model-runtime.catalog-auth.ts — READ: Account observations are bounded and credential-paired; refresh failures retain observed service tiers and provider-scoped auth metadata.
  • 292 lines — src/agents/mcp-oauth-provider.ts — READ: removed locally redeclared mutation-authority type; inferred concrete value is checked by the canonical worker operation signature.
  • 291 lines — src/agents/project-memory-bootstrap.ts — READ: | 291 | src/agents/project-memory-bootstrap.ts | READ | Retained provider audience lifetime and optional cleanup semantics; local truncation rejects isolated high surrogates unlike the shared helper.
  • 287 lines — src/agents/installed-skill-catalog.ts — READ: | 287 | src/agents/installed-skill-catalog.ts | READ | Retained bounded whole/read-search budgets, joined parallel I/O, and permission/currentness checks; cache owners have real cancellation contracts.
  • 286 lines — src/agents/cli-session-store.ts — READ: Retained fork and result publication paths because live commit guards, aborted cleanup, and exact local lifecycle comparison differ.
  • 286 lines — src/agents/embedded-agent-subscribe.handlers.messages.snapshot.ts — READ: Retained source-coordinate reconciliation with code-boundary ownership and chunk generations.
  • 284 lines — src/agents/requester-tool-policy.ts — READ: Delegation lineage and trusted completion envelopes enforce requester authority; sender/group policies cannot be merged blindly.
  • 283 lines — src/agents/prepared-model-runtime.types.ts — READ: Types describe active lifecycle, catalog, auth and lease contracts; no unused knob identified beyond the private workspace-build options removed in facts.
  • 280 lines — src/agents/context.ts — READ: | 280 | src/agents/context.ts | READ | Retained published-generation/cache replacement and backoff; distinct on-demand and post-ready owners must not merge discoveries.
  • 275 lines — src/agents/models-config.providers.catalog-context.ts — READ: Provider OAuth preparation, failure outcomes and locked-account discovery preserve account scope and live request authority.
  • 275 lines — src/agents/code-mode-runtime.ts — READ: Config precedence, historical option semantics, and headless caps are public contracts; cron-linked limits left unchanged.
  • 274 lines — src/agents/memory-search.ts — READ: Provider discovery, secret availability, multimodal validation, and widened SDK configuration types are purposeful.
  • 274 lines — src/agents/bash-tools.exec-approval-request.ts — READ: excluded from edits because request suppression/client delivery contains cron-specific policy.
  • 274 lines — src/agents/apply-patch-file-ops.ts — READ: Retained: sandbox, host-uncontained, and boundary-owned operations differ in authority and atomic-create semantics.
  • 273 lines — src/agents/run-session-target.ts — READ: | 273 | src/agents/run-session-target.ts | READ | Retained typed target versus July+ SQLite compatibility-marker resolution and collision/alternate-store ownership checks.
  • 272 lines — src/agents/github-oauth-records.ts — READ: shared and personal schema differences are intentional; canonical records preserve recovery metadata.
  • 272 lines — src/agents/mcp-app-model-context.ts — READ: snapshots carry consumption leases and view-scoped authority; no disposable duplicate owner.
  • 272 lines — src/agents/agent-command-recovery-owner.ts — READ: | 272 | src/agents/agent-command-recovery-owner.ts | READ | Retained transferred-owner identity checks, waitable live-recovery handoff and finally release ordering.
  • 269 lines — src/agents/exec-auto-review-transcript.ts — READ: Retained bounded redaction, first/last user anchors and tool-call/result pairing; these are independently observable evidence contracts.
  • 268 lines — src/agents/openclaw-tools.media-factory-plan.ts — READ: Retained: prepared capabilities, explicit model settings, and current auth signals are separate registration facts.
  • 268 lines — src/agents/agent-bundle-mcp-manager-install.ts — READ: static/reused/requester installations share the canonical installer and preserve transferred slots.
  • 266 lines — src/agents/transcript-policy.ts — READ: Provider-owned hooks and custom-transport fallback preserve replay behavior and shipped reasoning formats; prior l331 file retained.
  • 266 lines — src/agents/agent-bundle-mcp-types.ts — READ: removed uncalled bindSessionKey API; all other optional capabilities retain concrete native/in-process consumers.
  • 265 lines — src/agents/model-selection.ts — READ: Public facade exports and persisted/configured/subagent selection have different documented normalization contracts.
  • 265 lines — src/agents/date-time.ts — READ: | 265 | src/agents/date-time.ts | READ | Retained distinct timestamp heuristics and system-preference detection; available numeric helpers have different rounding/epoch semantics.
  • 263 lines — src/agents/prepared-model-runtime.inbound-registry.ts — READ: Removed obsolete model-catalog selection mode; production catalog worker already acquires directly. Kept borrowing and inspection ownership unchanged.
  • 263 lines — src/agents/agent-tools.params.ts — READ: Simplified: replaced generic single-path Set traversal, removed unused replacement type, and inlined one-use extension normalization.
  • 262 lines — src/agents/prepared-model-runtime.refresh-scope.ts — READ: Scoped reload eligibility, retained launch workspaces and plugin/catalog recovery preserve current registered ownership; retained.
  • 262 lines — src/agents/model-catalog-route.ts — READ: Public projection intentionally excludes private transport metadata and preserves exact donor identity; retained.
  • 260 lines — src/agents/exec-defaults.ts — READ: Retained sync and worker-prepared execution-default paths; both share one policy preparation owner with different IO boundaries.
  • 258 lines — src/agents/mcp-stdio-transport.ts — READ: process cleanup ownership, raw byte decoding and asynchronous EPIPE settlement are supported contracts.
  • 257 lines — src/agents/agent-command-execution-identity.ts — READ: | 257 | src/agents/agent-command-execution-identity.ts | READ | Protected audit closure; retained runtime registration/terminal-write settlement and public ingress sanitization.
  • 255 lines — src/agents/tool-policy-pipeline.ts — READ: Retained: warning provenance, frozen Claw policy semantics, and per-layer callbacks require ordered policy application.
  • 255 lines — src/agents/embedded-agent-subscribe.handlers.messages.replies.ts — READ: Retained attachment alignment, selection precedence and failed-delivery media restoration.
  • 253 lines — src/agents/code-mode-swarm.runtime.ts — READ: Collector replay fingerprints, source authority, launch recovery, and wait ownership prevent a simpler unsafe dispatch path.
  • 249 lines — src/agents/mcp-stdio-client.ts — READ: strict proxy framing/error taxonomy differs from the general MCP client; not a redundant client implementation.
  • 249 lines — src/agents/conversation-capability-profile.ts — READ: | 249 | src/agents/conversation-capability-profile.ts | READ | Retained profile/group/sender/sandbox/scheduled policy provenance and separate inheritance versus current-turn allowlists.
  • 246 lines — src/agents/code-mode-result-preview.ts — READ: Bounded traversal, heterogeneous-array sampling, and descriptor fitting provide distinct result-retention contracts.
  • 245 lines — src/agents/isolated-completion-route.ts — READ: Lightweight status routing shares dispatch selection without loading execution runtime; auth ownership and explicit CLI rules remain necessary.
  • 245 lines — src/agents/bash-tools.exec-types.ts — READ: Retained public SDK declaration closure and outcome discrimination; deprecated fields explicitly name SDK compatibility contracts.
  • 244 lines — src/agents/mcp-client-lifecycle.ts — READ: SDK startup, graceful/forced physical cleanup and human-input deadline budgets require distinct ownership.
  • 242 lines — src/agents/tool-result-error.ts — READ: Retained: hostile-getter containment, cancellation identity and status precedence protect untrusted tool failures.
  • 240 lines — src/agents/bash-tools.exec-script-target.ts — READ: Retained Node preload parser despite Node source-preflight early return: ambiguity analysis consumes its script hints.
  • 240 lines — src/agents/mcp-transport.ts — READ: stdio, OAuth, auth-profile and SSE header paths preserve different external transport contracts.
  • 239 lines — src/agents/exec-tool-target-pinning.ts — READ: excluded from edits because its primary owner mints and validates cron scheduled-tool projections.
  • 239 lines — src/agents/agent-harness-completion-recovery.ts — READ: | 239 | src/agents/agent-harness-completion-recovery.ts | READ | Retained admitted versus durable completion claim authority and exact source-input/terminal-receipt validation; prior l331 file.
  • 238 lines — src/agents/agent-delete-databases.ts — READ: | 238 | src/agents/agent-delete-databases.ts | READ | Retained real database/registered-owner deletion safeguards and async authority rechecks; deletion lifecycle is substantive.
  • 237 lines — src/agents/embedded-agent-subscribe.handlers.compaction.ts — READ: Retained completion versus retry persistence, lazy legacy count reconciliation and hook settlement.
  • 236 lines — src/agents/prepared-model-runtime.resources.ts — READ: Construction claims and resource settlement protect donor registrations and aggregate retained failures; no safe flattening identified.
  • 235 lines — src/agents/session-suspension.ts — READ: Serialized writes and generation-fenced rollback protect shutdown against late persistence; no safe simplification found.
  • 235 lines — src/agents/bash-tools.exec-approval-followup-state.ts — READ: Retained one-shot claim/finalize/release capabilities and restrictive copying; these prevent leaking private claim/expiry fields.
  • 235 lines — src/agents/node-plugin-tools.ts — READ: Retained: trusted plugin names, generated collision names, node transport and MCP result provenance need separate gates.
  • 234 lines — src/agents/transcript-code-mode-source.ts — READ: | 234 | src/agents/transcript-code-mode-source.ts | READ | Retained opaque response/append ownership and exact copied-call identity checks across hook replacement.
  • 234 lines — src/agents/context-cache-projection.ts — READ: | 234 | src/agents/context-cache-projection.ts | READ | Retained configured versus discovered precedence, normalized aliases and batch yielding; prior l331 consolidated iteration.
  • 233 lines — src/agents/watched-sessions-prompt.ts — READ: | 233 | src/agents/watched-sessions-prompt.ts | READ | Retained shipped synchronous SDK entrypoint and async durable reader with post-I/O watch/disclosure revalidation.
  • 232 lines — src/agents/bootstrap-budget.ts — READ: Already changed by l331; read per-file/total budget accounting and retained its warning and USER cap contracts.
  • 232 lines — src/agents/embedded-agent-subscribe.model-state.ts — READ: Retained provider-billed cost precedence, fragment/turn accounting and detached completed snapshots.
  • 231 lines — src/agents/model-catalog-lookup.ts — READ: Retained the original .some traversal: its sparse-array hole behavior is covered by an existing regression that rejected the proposed for-of rewrite.
  • 230 lines — src/agents/mcp-oauth-store.ts — READ: worker message envelopes have different typed results and missing-database defaults; generic abstraction would require extra type plumbing.
  • 229 lines — src/agents/tool-search-request.ts — READ: Retained: scalar/batch normalization, flattened argument aliases and ambiguity detection encode observed model-input contracts.
  • 228 lines — src/agents/live-cache-regression-policy.ts — READ: Live proof policy/helper rather than shipped production path; retained assertions, baselines and provider evidence distinctions.
  • 227 lines — src/agents/identity-avatar-file.ts — READ: Local avatar resolution, pinned descriptor reads, revision handling, and public URL classification remain separate requirements.
  • 224 lines — src/agents/code-mode-control-tools.ts — READ: Reused the tool-kind metadata owner for marked exec metadata; removed a redundant literal alias and narrating comments.
  • 223 lines — src/agents/bash-tools.exec-approval-output.ts — READ: Retained authenticated output spans, line-aware head/tail budgets and exact model-facing prompts.
  • 223 lines — src/agents/agent-harness-completion-custody.ts — READ: | 223 | src/agents/agent-harness-completion-custody.ts | READ | Retained separate execution custody versus completion-delivery lifetime and physical requester lifecycle binding.
  • 218 lines — src/agents/mcp-transport-config.ts — READ: inlined one-use HTTP resolver and reuse its failure result instead of reparsing invalid config.
  • 217 lines — src/agents/model-catalog-auth-labels.ts — READ: Captured credential labels and time-dependent profile flags intentionally project separately; preserve visible status output.
  • 217 lines — src/agents/mcp-content.ts — READ: guest/result projection retains data ownership and independent model-facing deep-value failure behavior.
  • 216 lines — src/agents/tool-policy-audit.ts — READ: Retained: duplicate-name counting and matched-rule provenance preserve bounded audit diagnostics.
  • 216 lines — src/agents/codex-native-web-search-core.ts — READ: | 216 | src/agents/codex-native-web-search-core.ts | READ | Read but left unchanged; Codex-backed changes require the separate exact sibling-source audit and SDK compatibility proof.
  • 215 lines — src/agents/models-config.providers.discovery-auth.runtime.ts — READ: Deferred secret failures and OAuth preparation track exact selected profiles and preserve request-local failure provenance.
  • 215 lines — src/agents/provider-model-auth-source-plan.ts — READ: Required and automatic auth plans encode declared-credential count, cooldown and profile priority contracts; no sound simplification.
  • 212 lines — src/agents/prepared-model-runtime.plugin-generation.ts — READ: Derived generation lineage and media invocation custody are live; conditional registry/artifact retention remains necessary.
  • 212 lines — src/agents/tool-search-directory.ts — READ: Retained: immutable-array cache, duplicate-name filtering, and bounded row degradation preserve stable prompt bytes.
  • 212 lines — src/agents/minimax-vlm.ts — READ: | 212 | src/agents/minimax-vlm.ts | READ | Reserved by an open PR; retained origin trust, request release and provider-error redaction boundary.
  • 210 lines — src/agents/run-termination.ts — READ: | 210 | src/agents/run-termination.ts | READ | Retained direct versus nested abort classification and hostile-getter handling for observable terminal outcomes.
  • 208 lines — src/agents/session-model-auto-revert.ts — READ: Captured marker timestamps and validated fallback updates protect concurrent operator changes and one-run rollback.
  • 208 lines — src/agents/mcp-client-elicitation.ts — READ: transport callbacks need captured async caller scope and unambiguous active-request authority.
  • 206 lines — src/agents/openai-routing.ts — READ: | 206 | src/agents/openai-routing.ts | READ | Read but left unchanged; provider/Codex routing requires exact sibling-source audit and public SDK compatibility before cleanup.
  • 205 lines — src/agents/plugin-text-transforms.ts — READ: | 205 | src/agents/plugin-text-transforms.ts | READ | Retained different content/tool-argument traversal rules and native stream iteration/result wrapping contract.
  • 204 lines — src/agents/prepared-model-runtime.published-owner.ts — READ: Passive reads and retained acquisitions share projection but differ on drainage and lease retention; retained.
  • 204 lines — src/agents/embedded-agent-error-observation.ts — READ: Reserved by another open PR; read only, no edits.
  • 202 lines — src/agents/prepared-model-runtime-auth.ts — READ: Private WeakMap bindings keep secrets outside public snapshots and compare OAuth account identities without rotating-token churn; retained.
  • 202 lines — src/agents/media-generation-activity.ts — READ: | 202 | src/agents/media-generation-activity.ts | READ | Retained live admission identity, generation fencing, active/completed distinction and recent blocked outcome retention.
  • 201 lines — src/agents/prepared-model-runtime.publication-events.ts — READ: Live pending/failure getters and publication notifications preserve provider/native acquisition status; retained.
  • 201 lines — src/agents/realtime-bootstrap-context.ts — READ: | 201 | src/agents/realtime-bootstrap-context.ts | READ | Retained requested file order, guarded profile reads and exact rendered budget; prior l331 file.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 7b4c90e92274344bebde156a6530fe73b8d2f393
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/execution-auth-binding.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • 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/mcp-oauth-provider.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/sandbox-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.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docker Docker and sandbox tooling agents Agent runtime and tooling size: XL labels Oct 3, 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 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 9:39 PM ET / October 4, 2026, 01:39 UTC (Revision 4).

ClawSweeper review

What this changes

The branch simplifies agent runtime helpers, removes unused internal options, and adjusts existing tests while preserving configuration, authentication, tool execution, and transcript behavior.

Merge readiness

✅ Ready for maintainer review

This remains useful, distinct cleanup work. No concrete introduced correctness or security defect was found, and the merged predecessor does not supersede it.

Priority: P3
Reviewed head: 7b4c90e92274344bebde156a6530fe73b8d2f393

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful owner-local simplification with substantial reported validation and no actionable introduced defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored internal refactor is exempt from ordinary contributor runtime proof. The inspected changes preserve authority rather than materially extending it; persistence restructuring retains existing formats and does not introduce a data-model migration. Reported remote tests remain supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored internal refactor is exempt from ordinary contributor runtime proof. The inspected changes preserve authority rather than materially extending it; persistence restructuring retains existing formats and does not introduce a data-model migration. Reported remote tests remain supplemental validation.
Evidence reviewed 10 items Pinned introduced change: Reviewed the merge-base-to-head hunks. The changes remove private forwarding layers and repeated projections; endpoint drift was not attributed to this PR.
Verified merge ownership: The test merge records the pinned base first and exact PR head second. Its comparison against that base contains the agent cleanup, rather than the unrelated channel and workflow changes listed in endpoint drift.
Still necessary on current main: Fetched main retains the model-catalog forwarding helper removed here. The supplied GitHub metadata identifies #163963 as merged earlier cleanup, not a replacement for this batch.
Findings None None.
Security None None.

How this fits together

The agent runtime combines model configuration, credentials, plugin tools, and conversation state to execute model turns. Its results feed tool dispatch, replies, and persisted transcripts.

flowchart TD
  A[Conversation and configuration] --> B[Agent runtime]
  C[Models and credentials] --> B
  D[Plugin and MCP tools] --> B
  B --> E[Execution checks]
  E --> F[Tool execution]
  F --> G[Replies and transcripts]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -937, Tests +18. Total -919 across 66 files.

View PR surface stats
Area Files Added Removed Net
Source 63 666 1603 -937
Tests 3 40 22 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 66 706 1625 -919

Review metrics

None.

Technical review

Best possible solution:

Keep the simplifications within existing runtime owners while preserving current configuration, authority, persistence, and transcript contracts.

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

Not applicable: this PR proposes behavior-preserving cleanup, and source review found no concrete introduced failure to reproduce.

Is this the best way to solve the issue?

Yes: removing unused private options and consolidating projections within their existing owners is a maintainable approach; the inspected refactors preserve the relevant contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4525e1d28e2a.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal simplification with no intended user-visible behavior change or demonstrated urgent regression.
  • 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: The member-authored internal refactor is exempt from ordinary contributor runtime proof. The inspected changes preserve authority rather than materially extending it; persistence restructuring retains existing formats and does not introduce a data-model migration. Reported remote tests remain supplemental validation.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head hunks. The changes remove private forwarding layers and repeated projections; endpoint drift was not attributed to this PR. (src/agents, 7b4c90e92274)
  • Verified merge ownership: The test merge records the pinned base first and exact PR head second. Its comparison against that base contains the agent cleanup, rather than the unrelated channel and workflow changes listed in endpoint drift. (7623cebb9a19)
  • Still necessary on current main: Fetched main retains the model-catalog forwarding helper removed here. The supplied GitHub metadata identifies refactor(agents): deslop agents #163963 as merged earlier cleanup, not a replacement for this batch. (src/agents/models-config.ts, 4525e1d28e2a)
  • Shell fallback disposition: The complete shell snapshot owner returns the original command before capture unless the shell is bash or zsh and its arguments include -c. This supports rejecting the unsupported-shell fallback concern described in the PR body. (src/agents/shell-snapshot.ts:81, 7b4c90e92274)
  • Authority and persistence preservation: Auth fingerprint consolidation preserves the original tuple fields and ordering. OAuth changes remove only a local type alias; mutation authority remains unchanged. Model persistence retains write/no-op ordering, permissions, cache invalidation, and the existing serialized formats. (src/agents/models-config.ts:281, 7b4c90e92274)
  • Final execution boundary: The unchanged tool wrapper rechecks abort, current plugin runtime, and source execution guards immediately before implementation starts. Consolidating tracked-call state preserves pending, started, and settled distinctions without changing execution admission. (src/agents/agent-tools.before-tool-call.wrapper.ts:500, 7b4c90e92274)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason O'Neal: 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 (3 earlier review cycles)
  • reviewed 2026-10-03T22:04:51.443Z sha 6454c22 :: blocked before merge. :: none
  • reviewed 2026-10-03T23:15:17.847Z sha 6454c22 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T23:33:59.877Z sha b24817f :: needs maintainer review before merge. :: none

@steipete
steipete enabled auto-merge (squash) October 3, 2026 22:19
@steipete
steipete disabled auto-merge October 3, 2026 23:08
@steipete
steipete enabled auto-merge (squash) October 3, 2026 23:26
@steipete
steipete disabled auto-merge October 4, 2026 00:25
@steipete
steipete force-pushed the deslop/l346-agents-root2-simplify branch from b24817f to 7b4c90e Compare October 4, 2026 01:29
@steipete
steipete enabled auto-merge (squash) October 4, 2026 01:31
@steipete
steipete merged commit 91e9b93 into main Oct 4, 2026
166 checks passed
@steipete
steipete deleted the deslop/l346-agents-root2-simplify branch October 4, 2026 01:40
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
Simplify agent runtime internals without changing configuration, persisted state, tool descriptions, or wire shapes. Remove unused private options and forwarding layers, consolidate metadata projections and execution tracking, and retain authority and cleanup contracts.

Removes 937 net production lines. The PR records validation and complete size-sorted coverage of the root agents subsystem.
fransqaas added a commit to fransqaas/openclaw that referenced this pull request Oct 6, 2026
openclaw#164566 inlined the gateway timeout helper this branch used to bound the
pending-approval wait. Compute the same bound inline: the approval timeout
plus the existing 10 s gateway grace.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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