Repository navigation
refactor(agents): deslop agents - #164566
Conversation
|
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 9:39 PM ET / October 4, 2026, 01:39 UTC (Revision 4). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -937, Tests +18. Total -919 across 66 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
b24817f to
7b4c90e
Compare
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.
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]>
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.
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
maybeWrapCommandWithShellSnapshotreturns unchanged unlessisSupportedSnapshotShelladmits 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.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.pnpm install --frozen-lockfile, targetednode scripts/run-vitest.mjsselections,pnpm test <changed test file> --maxWorkers=1, andnode scripts/check-changed.mjs. Both cycle scripts ran withnode --import ./scripts/tsx.mjs. AWS leasescbx_0ab3436d1084andcbx_87f23e3b1451are released. Blacksmith Testboxtbx_01m41dx2gg864tk73z5y1h39b1expired before hydration and is confirmed stopped. Remaining focused checks used the authorized serialnice -n 15local fallback after broker/capacity failures.Landing Failure Attribution
The unchanged
src/agents/compaction.tool-result-details.test.tswas run on three clean revisions on Blacksmith Testboxtbx_01m426me67tfjtmr543r9bq0bm(runner), using Node 24.19.0, pnpm 12.5.1, a frozen-lockfile install, andnode scripts/run-vitest.mjs src/agents/compaction.tool-result-details.test.ts:b24817f66be9cf78d258adcaf7b0714bad5a0340affb994cf4193ff967b0f792b4634435d39429484bcd6956b0a431b3d7024f1ad13095947c242bf8CI run 37161724319, job
checks-node-changed-compact-small-14, tested merge26dc332222e3a758b5bd3321057b934da631a12fagainst that failing main revision. The privacy filter had been narrowed to provider replay authority. Upstream producer fixccc0020633ba98fc0e930a98df2c05d13d5b9dd8restores 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
b284ad2971f4ec4354e0d2143980502bb3418daeincludes that fix and the Knip Linux-entry repairbf4fe3ace5702c98c669e298e918b204d60d1b8d. 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 as91e9b93bcebd821474415d3daa8e9de4a566e1c3; 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 allocationcbx_89ee4a0d1958is 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.
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.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.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.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.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.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.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.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.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.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.src/agents/code-mode-execution.ts— READ: Inline execution, parked resumes, approval budget credit, and required-completion settlement have distinct ownership and ordering contracts.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.src/agents/bash-tools.exec-run.ts— READ: Retained host dispatch, foreground/background settlement and approval authority; prior l331 file with cron-facing options.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.src/agents/model-fallback-runner.ts— READ: Fallback, cooldown probe, harness-local failure, replay and deferred suspension policies have distinct terminal conditions; retained.src/agents/github-tool-identity.ts— READ: profile isolation, selected-identity fencing, publication snapshots and atomic credential installation are distinct contracts.src/agents/prepared-model-runtime.ts— READ: Publication queue, auth adoption, degraded startup and standalone admission have distinct lifecycle responsibilities; retained.src/agents/transcript-redact.ts— READ: Retained provider-signed replay validation, copy-on-write identity, source provenance, and structured redaction boundaries.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.src/agents/embedded-agent-block-chunker.ts— READ: Unified ordered paragraph/newline break selection; retained fenced-code, table, surrogate, and source-coordinate recovery.src/agents/embedded-agent-subscribe.stream-rendering.ts— READ: Retained independent hidden/visible code parser state and confirmed source-delivery deduplication.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.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.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.src/agents/model-auth-provider-config.ts— READ: Auth provenance, secret markers, provider bindings and inline cooldown contracts prevent credential substitution; retained.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.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.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.src/agents/agent-tools.before-tool-call.wrapper.ts— READ: Retained: preparation, approvals, steering, live authority recheck, execution, and terminal settlement must remain ordered.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.src/agents/prepared-model-runtime.owner.ts— READ: Owner lookup, normalization and atomic build publication preserve directory/config/generation isolation; retained.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.src/agents/model-fallback-attempt.ts— READ: Terminal abort and deferred suspension classification import the excluded cron lifecycle owner; retained.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.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.src/agents/prepared-model-runtime.full-catalog.ts— READ: Inventory retention and runtime projection preserve auth pairing, provider order and native provenance; retained.src/agents/tool-loop-detection.ts— READ: Retained: l331 file; detector ordering and result-specific no-progress hashes preserve distinct user-visible interventions.src/agents/model-catalog-view.ts— READ: Logical and physical donor projections, revocable native observations and picker/status preparation are distinct live flows.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.src/agents/simple-completion-runtime.ts— READ: Prepared auth, route materialization and transferred lease settlement remain necessary; previous l331 pass already simplified this flow.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.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.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.src/agents/model-auth-provider.ts— READ: Explicit profile, per-entry binding, env-first and synthetic deferral branches preserve credential precedence and error contracts.src/agents/tool-catalog.ts— READ: Retained: pure catalog data drives shipped profiles/UI; overlaps Automations closure.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.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.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.src/agents/isolated-completion.ts— READ: CLI and harness isolation, authority revalidation, exact-profile retries and inference budgets are real execution contracts.src/agents/tool-search-runtime.ts— READ: Retained: schema admission, final-input validation, queued generation checks, and network taint follow separate lifecycle contracts.src/agents/tool-display-exec-shell.ts— READ: Retained: l331 file; lexical states distinguish redirects, quotes, arithmetic, heredocs, and compound syntax.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.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.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.src/agents/agent-tools.policy.ts— READ: Retained: scheduled authority and group/profile policy precedence overlap Automations closure.src/agents/tool-display-exec.ts— READ: Retained: l331 file; command-specific parsers preserve redacted labels and conservative shell fallbacks.src/agents/embedded-agent-subscribe.handlers.tools.completion.ts— READ: Retained terminal side-effect/delivery evidence; heartbeat and Automations integration belongs to concurrent owner.src/agents/provider-attribution.ts— READ: Provider host classification and opt-in attribution metadata are externally observable; no safe metadata or endpoint-policy deletion.src/agents/agent-bundle-lsp-runtime.ts— READ: reserved overlap; no edits.src/agents/embedded-agent-subscribe.handlers.messages.update.ts— READ: Retained provider phase reconciliation and append/snapshot paths required by queued mutable partials.src/agents/apply-patch.ts— READ: Retained: l331 file; ordered queue ownership, exclusive creates, moves, and no-op accounting are behavior-bearing.src/agents/agent-tool-definition-adapter.ts— READ: Simplified: removed one-use sanitization forwarding helper and redundant result-coercion intermediates.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.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.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.src/agents/agent-tools.ts— READ: Retained: runtime tool assembly includes Automations/heartbeat closure and owner-bound execution policy.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.src/agents/prepared-model-catalog.ts— READ: Published/read-only/admitted catalog paths enforce different config and lease contracts; their fallbacks are intentional.src/agents/mcp-ui-resource.ts— READ: bounded view ownership, per-request authority and resource metadata fallbacks are needed by supported external MCP Apps.src/agents/embedded-agent-subscribe.handlers.tools.start.ts— READ: Retained synchronous start ordering, question reservation cancellation, and execution activity accounting.src/agents/prepared-model-runtime.build.ts— READ: Batch sharing, per-directory serialization and timeout observer versus work completion contracts are intentional; retained.src/agents/openclaw-tools.ts— READ: Retained: factory registration includes Automations/heartbeat closure; placement, sender, client, and runtime availability stay separate.src/agents/mcp-oauth.ts— READ: refresh, browser start/callback, cancellation and scope challenge flows retain separate lease/authority boundaries.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.src/agents/bash-tools.exec-request-preparation.ts— READ: Retained l331 environment/workdir prepared-state lifecycle and host-specific environment trust boundaries.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.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.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.src/agents/bash-tools.exec-approval-followup.ts— READ: excluded from edits because denied-followup routing contains cron-specific ownership policy.src/agents/embedded-agent-subscribe.reply-delivery.ts— READ: Retained reentrant synchronous callbacks, deferred settlement, source-media restoration and commentary identities.src/agents/model-catalog.ts— READ: Logical and physical route merges use different keys and donor rules; catalog sorting and provider ordering remain observable.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.src/agents/provider-http-errors.ts— READ: Bounded reads, reflected-secret redaction, error metadata and content-family validation protect distinct external response contracts.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.src/agents/provider-model-route-auth.ts— READ: Auth ownership, declared versus ambient credentials, route preferences and exact-route attempts are contract-bearing decisions.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.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.src/agents/embedded-agent-subscribe.ts— READ: Retained subscription and compaction lifetime owner; public getters are consumed by attempt lifecycle.src/agents/workspace-access.ts— READ: Capability-specific pre/post-await fences, Memory publication semantics, and watch cancellation prevent a generic forwarding replacement.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.src/agents/tool-search-catalog.ts— READ: Retained: executor rebinding, schema identity fingerprints, generation teardown, and client-shadow precedence each protect retained catalogs.src/agents/shell-snapshot.ts— READ: Inlined snapshot capture builders and simplified forceRefresh options; retained the directory helper because its assertion baseline is reserved.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.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.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.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.src/agents/code-mode-controller-source.ts— READ: Guest queue quotas, network provenance, immutable handles, and final-value serialization have concrete runtime contracts.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.src/agents/github-oauth-client.ts— READ: strict external response parsing and credential-cache generations protect different wire and revocation contracts.src/agents/embedded-agent-tool-results.ts— READ: Removed redundant non-error status exclusions and handwritten structured-result collection.src/agents/usage.ts— READ: Provider-specific aliases and context/cache accounting are active wire and persisted-data shapes; adapters intentionally differ.src/agents/tool-schema-hints.ts— READ: Retained: compact/declaration modes have different completeness and traversal bounds; combining them would change model-facing text.src/agents/embedded-agent-utils.ts— READ: Retained full versus incremental thinking extraction, content-phase fallback, and public reasoning rendering.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.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.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.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.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.src/agents/prepared-model-runtime-lease.ts— READ: Admission/rebind, configured reuse, retained parent generations and dynamic owner lifetime have distinct authority rules; retained.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.src/agents/agent-bundle-mcp-harness.ts— READ: static and requester paths intentionally differ in stable catalogs and approval behavior; Codex contract untouched.src/agents/core-coding-tools.ts— READ: Retained: host/sandbox/remote-skill routes intentionally differ in filesystem namespace and read-only exception admission.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.src/agents/prepared-model-runtime-auth-publication.ts— READ: Overlapping auth changes require component atomicity, FIFO handling and independent owner gates; retained.src/agents/sandbox-host.ts— READ: CSP validation and isolated-frame bridges are security/visible shell contracts; no behavior-neutral structural reduction found.src/agents/session-tool-result-guard.payload.ts— READ: Retained byte budget and secret-boundary overlap safety; generic JSON helpers differ in accounting contract.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.src/agents/model-runtime-choice.ts— READ: Model availability, native renewal and commit-time validation share captured owners but retain distinct execution semantics.src/agents/tool-mutation.ts— READ: Retained: replay safety and mutation are distinct; classification includes Automations closure.src/agents/embedded-agent-message-delivery.ts— READ: Retained plugin-envelope compatibility, delivery receipts, partial/broadcast semantics and current-source qualification.src/agents/embedded-agent-messaging-extraction.ts— READ: Collapsed repeated attachment field projection into typed string and numeric key loops; retained route/thread ownership.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.src/agents/models-config.providers.secrets.ts— READ: Profile-first versus env-first discovery and opaque secret materialization have deliberate precedence differences.src/agents/tool-display-common.ts— READ: Retained: l331 file; bounded rendering, metadata access order, and secret redaction are observable contracts.src/agents/bootstrap-files.ts— READ: Hook filtering, pinned source protection, personal overlays, and automatic-memory provenance retain distinct necessary boundaries.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.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.src/agents/code-mode-node.ts— READ: Warm pool custody, lifecycle retirement, watchdog delivery, and continuation disposal enforce native-resource ownership.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.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.src/agents/embedded-agent-subscribe.handlers.lifecycle.ts— READ: Retained sync/async terminal callbacks and once-only lifecycle emission across failure and continuation paths.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.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.src/agents/cli-auth-epoch.ts— READ: retained untouched due exact overlap; reusable-session epochs intentionally differ from strict credential and executable-owner fingerprints.src/agents/mcp-http-transport.ts— READ: SSE and Streamable HTTP adapters handle distinct SDK cleanup/reconnect gaps; streaming bounds must remain incremental.src/agents/tool-images.ts— READ: Simplified: removed unused resize-result flag, unified source diagnostic fields, removed redundant text-block alias and path intermediates.src/agents/spawn-plan.ts— READ: Shared spawn owner already combines ACP/subagent policy; the remaining branches distinguish channel placement and admission contracts.src/agents/model-scan.ts— READ: Catalog field parsing and separate tool/image probes protect provider payload and inference contracts; no safe structural deletion.src/agents/session-transcript-repair.ts— READ: Retained provider replay and orphan pairing contracts; legacy finalized partialJson repair has an explicit persisted contract.src/agents/sandbox-paths.ts— READ: Cross-platform lexical paths, canonical prefixes, symlink guards, and managed-media exceptions cannot safely be collapsed.src/agents/tools-effective-inventory.ts— READ: Retained: static model admission avoids provider discovery; dynamic lease ownership and policy notices are substantive.src/agents/code-mode-json.ts— READ: Cumulative source receipts and bounded output/value/error fitting deliberately separate source retention from delivery.src/agents/model-fallback-candidates.ts— READ: Cache identities preserve plugin generations and authored selections; explicit and image fallback collection retain different source precedence.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.src/agents/auth-health.ts— READ: Provider rollups preserve explicit profile order and expiry evidence; l331 already simplified this area.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.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.src/agents/openclaw-plugin-tools.ts— READ: Retained: authority-bound delivery, registry freshness, requester owner binding, and live credential selection are distinct obligations.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.src/agents/prepared-model-runtime.configured.ts— READ: Configured model and provider selection preserve authored routes, static fallback precedence and exact runtime scoping; retained.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.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.src/agents/model-runtime-policy.ts— READ: Exact model, wildcard, provider and inherited runtime policy each have documented precedence and ambiguity behavior.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.src/agents/session-tool-result-guard-wrapper.ts— READ: Derived installed guard methods from the guard owner instead of redeclaring callback signatures.src/agents/code-mode.ts— READ: Catalog prompt construction and exec/wait tool registration expose distinct user/model-facing contracts; kept prompt text unchanged.src/agents/tool-search.ts— READ: Retained: bounded grouped-search projection and direct-call forwarding preserve control descriptions and network-bound output handling.src/agents/workspace-state-store.ts— READ: Worker admission, commit receipt publication, and CLI deletion ownership cannot be removed without storage-boundary changes.src/agents/tool-display-config.ts— READ: Retained: already compact declarative metadata; action-specific detail fields and display bytes are user contracts.src/agents/compaction.ts— READ: Prior l331 changes; retained recoverable partial summaries, bounded retries and model-visible chronology.src/agents/tool-search-ranking.ts— READ: Retained: BM25 scoring, stem variants, stopwords, expansion weighting and tie order preserve search behavior.src/agents/github-read-identity.ts— READ: absence proof, host selection, token rotation and live read authority are active behavior.src/agents/embedded-agent-subscribe.handlers.messages.lifecycle.ts— READ: Retained terminal reasoning order, source snapshot reconciliation and late-event parser state.src/agents/embedded-agent-subscribe.handlers.types.ts— READ: Prior l331 changes; retained shared mutable owner contract rather than introducing inferred cross-module cycles.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.src/agents/session-activity-notes.ts— READ: Streaming assembly, internal-context quarantine, and distinct event projections are observable; heartbeat imports excluded from changes.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.src/agents/model-fallback-observation.ts— READ: Log coalescing retains suppressed counts and time-based eviction; observation metadata and model-facing output stay unchanged.src/agents/mcp-oauth-store.kernel.ts— READ: persisted-row validation and existing-schema reads retained; storage admission redesign is outside this cleanup.src/agents/model-runtime-aliases.ts— READ: CLI aliases, stored profile authority and explicit runtime policy remain active interoperability contracts.src/agents/workspace-alias-rebind.ts— READ: Confirmed workspace moves require filesystem spellings, directory identity, transaction checks, and receipt ownership.src/agents/models-config.providers.secret-helpers.ts— READ: SecretRef, env-marker and provider-key provenance remain distinct; recent secret migration changes retained.src/agents/models-config.plan.ts— READ: Replaced unnecessary conditional object spreads for already optional discovery fields with direct properties; retained workspace truthiness boundary.src/agents/tool-policy.ts— READ: Retained: policy intersections and shipped name families are public configuration semantics, not obsolete aliases.src/agents/codex-mcp-config.ts— READ: native header/env and per-tool approval projection retained; Codex contract untouched.src/agents/session-placement-admission.ts— READ: Placement owner capture, queue admission, and forced-terminal settlement fence different lifecycle transitions.src/agents/mcp-connection-resolver.ts— READ: reserved overlap; no edits.src/agents/cli-backends.ts— READ: retained untouched due exact overlap; runtime and setup registries have deliberately different availability and provider-alias precedence.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.src/agents/agent-bundle-mcp-combined.ts— READ: facade retains server ownership and catalog replay semantics; generic dispatch would add type machinery.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.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.src/agents/model-catalog-visibility.ts— READ: Prepared membership and revocable readiness require separate phases; wildcard/default/configured visibility and physical donor ordering retained.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.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.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.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.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.src/agents/pty-keys.ts— READ: Retained: l331 file; key tables encode exact PTY bytes and modifier/DECCKM semantics.src/agents/identity-file.ts— READ: Markdown merge, bounded file admission, worker loading, and shipped synchronous SDK reader have separate required contracts.src/agents/compaction-planning-projection.ts— READ: Retained bounded UTF-16/CJK-weighted argument accounting; byte-count helpers have a different contract.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.src/agents/mcp-oauth-provider.ts— READ: removed locally redeclared mutation-authority type; inferred concrete value is checked by the canonical worker operation signature.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.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.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.src/agents/embedded-agent-subscribe.handlers.messages.snapshot.ts— READ: Retained source-coordinate reconciliation with code-boundary ownership and chunk generations.src/agents/requester-tool-policy.ts— READ: Delegation lineage and trusted completion envelopes enforce requester authority; sender/group policies cannot be merged blindly.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.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.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.src/agents/code-mode-runtime.ts— READ: Config precedence, historical option semantics, and headless caps are public contracts; cron-linked limits left unchanged.src/agents/memory-search.ts— READ: Provider discovery, secret availability, multimodal validation, and widened SDK configuration types are purposeful.src/agents/bash-tools.exec-approval-request.ts— READ: excluded from edits because request suppression/client delivery contains cron-specific policy.src/agents/apply-patch-file-ops.ts— READ: Retained: sandbox, host-uncontained, and boundary-owned operations differ in authority and atomic-create semantics.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.src/agents/github-oauth-records.ts— READ: shared and personal schema differences are intentional; canonical records preserve recovery metadata.src/agents/mcp-app-model-context.ts— READ: snapshots carry consumption leases and view-scoped authority; no disposable duplicate owner.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.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.src/agents/openclaw-tools.media-factory-plan.ts— READ: Retained: prepared capabilities, explicit model settings, and current auth signals are separate registration facts.src/agents/agent-bundle-mcp-manager-install.ts— READ: static/reused/requester installations share the canonical installer and preserve transferred slots.src/agents/transcript-policy.ts— READ: Provider-owned hooks and custom-transport fallback preserve replay behavior and shipped reasoning formats; prior l331 file retained.src/agents/agent-bundle-mcp-types.ts— READ: removed uncalled bindSessionKey API; all other optional capabilities retain concrete native/in-process consumers.src/agents/model-selection.ts— READ: Public facade exports and persisted/configured/subagent selection have different documented normalization contracts.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.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.src/agents/agent-tools.params.ts— READ: Simplified: replaced generic single-path Set traversal, removed unused replacement type, and inlined one-use extension normalization.src/agents/prepared-model-runtime.refresh-scope.ts— READ: Scoped reload eligibility, retained launch workspaces and plugin/catalog recovery preserve current registered ownership; retained.src/agents/model-catalog-route.ts— READ: Public projection intentionally excludes private transport metadata and preserves exact donor identity; retained.src/agents/exec-defaults.ts— READ: Retained sync and worker-prepared execution-default paths; both share one policy preparation owner with different IO boundaries.src/agents/mcp-stdio-transport.ts— READ: process cleanup ownership, raw byte decoding and asynchronous EPIPE settlement are supported contracts.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.src/agents/tool-policy-pipeline.ts— READ: Retained: warning provenance, frozen Claw policy semantics, and per-layer callbacks require ordered policy application.src/agents/embedded-agent-subscribe.handlers.messages.replies.ts— READ: Retained attachment alignment, selection precedence and failed-delivery media restoration.src/agents/code-mode-swarm.runtime.ts— READ: Collector replay fingerprints, source authority, launch recovery, and wait ownership prevent a simpler unsafe dispatch path.src/agents/mcp-stdio-client.ts— READ: strict proxy framing/error taxonomy differs from the general MCP client; not a redundant client implementation.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.src/agents/code-mode-result-preview.ts— READ: Bounded traversal, heterogeneous-array sampling, and descriptor fitting provide distinct result-retention contracts.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.src/agents/bash-tools.exec-types.ts— READ: Retained public SDK declaration closure and outcome discrimination; deprecated fields explicitly name SDK compatibility contracts.src/agents/mcp-client-lifecycle.ts— READ: SDK startup, graceful/forced physical cleanup and human-input deadline budgets require distinct ownership.src/agents/tool-result-error.ts— READ: Retained: hostile-getter containment, cancellation identity and status precedence protect untrusted tool failures.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.src/agents/mcp-transport.ts— READ: stdio, OAuth, auth-profile and SSE header paths preserve different external transport contracts.src/agents/exec-tool-target-pinning.ts— READ: excluded from edits because its primary owner mints and validates cron scheduled-tool projections.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.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.src/agents/embedded-agent-subscribe.handlers.compaction.ts— READ: Retained completion versus retry persistence, lazy legacy count reconciliation and hook settlement.src/agents/prepared-model-runtime.resources.ts— READ: Construction claims and resource settlement protect donor registrations and aggregate retained failures; no safe flattening identified.src/agents/session-suspension.ts— READ: Serialized writes and generation-fenced rollback protect shutdown against late persistence; no safe simplification found.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.src/agents/node-plugin-tools.ts— READ: Retained: trusted plugin names, generated collision names, node transport and MCP result provenance need separate gates.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.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.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.src/agents/bootstrap-budget.ts— READ: Already changed by l331; read per-file/total budget accounting and retained its warning and USER cap contracts.src/agents/embedded-agent-subscribe.model-state.ts— READ: Retained provider-billed cost precedence, fragment/turn accounting and detached completed snapshots.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.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.src/agents/tool-search-request.ts— READ: Retained: scalar/batch normalization, flattened argument aliases and ambiguity detection encode observed model-input contracts.src/agents/live-cache-regression-policy.ts— READ: Live proof policy/helper rather than shipped production path; retained assertions, baselines and provider evidence distinctions.src/agents/identity-avatar-file.ts— READ: Local avatar resolution, pinned descriptor reads, revision handling, and public URL classification remain separate requirements.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.src/agents/bash-tools.exec-approval-output.ts— READ: Retained authenticated output spans, line-aware head/tail budgets and exact model-facing prompts.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.src/agents/mcp-transport-config.ts— READ: inlined one-use HTTP resolver and reuse its failure result instead of reparsing invalid config.src/agents/model-catalog-auth-labels.ts— READ: Captured credential labels and time-dependent profile flags intentionally project separately; preserve visible status output.src/agents/mcp-content.ts— READ: guest/result projection retains data ownership and independent model-facing deep-value failure behavior.src/agents/tool-policy-audit.ts— READ: Retained: duplicate-name counting and matched-rule provenance preserve bounded audit diagnostics.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.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.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.src/agents/prepared-model-runtime.plugin-generation.ts— READ: Derived generation lineage and media invocation custody are live; conditional registry/artifact retention remains necessary.src/agents/tool-search-directory.ts— READ: Retained: immutable-array cache, duplicate-name filtering, and bounded row degradation preserve stable prompt bytes.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.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.src/agents/session-model-auto-revert.ts— READ: Captured marker timestamps and validated fallback updates protect concurrent operator changes and one-run rollback.src/agents/mcp-client-elicitation.ts— READ: transport callbacks need captured async caller scope and unambiguous active-request authority.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.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.src/agents/prepared-model-runtime.published-owner.ts— READ: Passive reads and retained acquisitions share projection but differ on drainage and lease retention; retained.src/agents/embedded-agent-error-observation.ts— READ: Reserved by another open PR; read only, no edits.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.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.src/agents/prepared-model-runtime.publication-events.ts— READ: Live pending/failure getters and publication notifications preserve provider/native acquisition status; retained.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.