Repository navigation
refactor(agents): deslop tool and auth orchestration - #164019
Conversation
Remove single-use schema builders, forwarding projections, redundant auth normalization, and compaction's mutable production test-dependency registry. Keep tool schemas, auth semantics, and lifecycle authority unchanged. Capture compaction routing before awaited preparation. Isolate inherited provider keys in the video fixture and preload the session mutation handler outside the integration fixture's RPC deadline.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. Reviewed October 3, 2026, 12:05 AM ET / 04:05 UTC. ClawSweeper reviewWhat this changesThe PR simplifies agent tool assembly, session operations, compaction, and credential handling by removing forwarding layers and moving test controls out of production code. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this is useful maintainer-requested cleanup that current main still lacks. The introduced changes preserve the inspected contracts, and no concrete blocking regression was found. Priority: P3 Review scores
Verification
How this fits togetherAgent orchestration turns model tool requests and session state into Gateway operations, compaction, and provider requests. Auth-profile owners supply credentials while session and dispatch owners enforce access and lifecycle checks. flowchart TD
A[Model tool requests] --> B[Tool schemas and validation]
B --> C[Session and dispatch owners]
D[Session state] --> C
E[Auth profile owners] --> F[Provider and compaction execution]
C --> F
C --> G[Gateway operations and tool results]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource -644, Tests +78, Other 0. Total -566 across 43 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Retain the simpler orchestration with canonical owners preserving schema bytes, credential filtering, compaction routing, and lifecycle checks. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving cleanup rather than a reported product bug; the added cases protect preparation-time routing. Is this the best way to solve the issue? Yes: consolidating orchestration at existing owners and removing production-only test controls is a maintainable approach; no concrete introduced defect was identified in the inspected changes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 60bdc8fa5780. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Simplify agent tool, auth-profile, and command-compaction orchestration through their existing owners. Remove single-use schema builders and forwarding layers, redundant projections and normalization, and compaction's mutable production test-dependency registry. Preserve model-facing schemas and descriptions, auth selection and persistence, response shapes, and authority/lifecycle fencing. Capture compaction routing before asynchronous preparation. Repair video fixture provider-environment isolation and session mutation fixture cold-import timing without weakening assertions or deadlines. Net production reduction: 644 lines. Complete subtree coverage and validation evidence are recorded in the PR. Exact-head CI 37095112294 completed with one inherited failure in the unchanged MCP node-matching fixture. Main schedule 37094503398 at the exact PR base reports the identical assertion; source and function-level attribution are recorded in the PR. Other selected CI and security checks passed. Landed through the maintainer-authorized inherited-main exception.
What Problem This Solves
Agent tool, command-compaction, and auth-profile flows retain forwarding layers, duplicate projections, and test-only production indirection after their underlying owners have already been consolidated.
User Impact
No user-visible change. Tool descriptions, parameter schemas, auth selection, persisted credentials, wire responses, and authority/lifecycle checks retain their existing contracts. No migration or operator action is required.
Why This Change Was Made
This maintainer-requested batch removes 644 net production lines. Full coverage was exhausted below the 1,000-line campaign target; the complete size-sorted coverage log is attached below. The remaining large modules implement active authority, persistence, cancellation, transport, and compatibility contracts.
Fixes Found Along the Way
The session-model integration fixture started its 10-second RPC deadline before lazily loading the real mutation handler. A diagnostic reproduced a timeout and measured 17.2 seconds in handler preparation. Preload that concrete handler during collection; the actual Gateway path, deadline, and assertions remain unchanged.
The video-generation no-provider fixture cleared two manually maintained lists that omitted a supported provider key. An inherited key made the unchanged availability owner register the tool. Resolve the canonical provider auth variable names once and clear that same list in both fixture hooks, preserving ADC/rotation cleanup and every assertion.
Two added compaction cases caught a routing change in the intermediate refactor when harness metadata changed during engine preparation. Capture the initial native/context choice once, matching the original behavior; both cases failed before that correction.
Evidence
pnpm test src/agents/command/cli-compaction.test.ts --maxWorkers=1run (37 cases) took 2,210.15 seconds wall time on the loaded host; the final expanded suite passed within the 39-file run (2,829.73 seconds), then all 39 cases passed again on the final source in a standalone wrapper run (400.90 seconds).ZAI_API_KEY=synthetic-video-test-key;node scripts/run-vitest.mjs src/agents/tools/video-generate-tool.test.tstook 706.11 seconds wall time with one worker/project. The original fixture failed the no-provider assertion with an inherited provider key.__proto__behavior.nice -n 15on this dedicated worktree under the explicitly authorized local fallback. No Linux repeated-run stability claim is made.5e6794cf5913e0c646b924753440cfaf2d80cf17without conflicts; both commits are patch-identical bygit range-diff. Prior focused proof is retained for those unchanged inputs. Hosted exact-head CI run 37095112294 completed in 531 seconds wall time: 68 successful jobs, 22 skipped jobs, and the single inherited failing test job plus the aggregate gate described below. Security checks passed. No CI reruns or additional source pushes were used.Inherited-main CI qualification
At exact PR head
ac11cdb39d619bf369413c298b70f823af554b16, checks-node-changed-compact-small-18 fails onlysrc/gateway/mcp-http.runtime.test.ts:323:53:McpLoopbackToolCache > refreshes cached bound tools when node matching preferences change, withexpected [] to deeply equal [ 'exec' ]. The aggregate CI gate follows that failure; all other selected CI jobs passed or were skipped.Independent pre-existence is established by main's scheduled run 37094503398, head
5e6794cf5913e0c646b924753440cfaf2d80cf17(this PR's exact base): checks-node-compact-large-21 reports the same full test name, assertion, and line at 03:52:40 UTC, before this PR's CI run. Main commitdd90d99aac4052787d3e7811d88b114ff7e118baremoved the legacy client-ID tie-breaker while this fixture still expects it.The failed test, MCP runtime, node-exec availability owner, and shared node matching/parsing modules are byte-identical to the main base. There is a shared-module overlap: this PR changes later
resolveAgentNodeId/resolveAgentNodeexports innodes-utils.ts, but the imports and actuallistNodes/resolveNodeIdFromListfunctions invoked by this case are byte-identical; the changed exports are not called on the failing path. Tool construction is mocked in this test. This is function-level causal attribution, not a claim that every transitively imported file is unchanged.The maintainer-authorized inherited-failure route is pinned to the exact reviewed head above. The main fixture repair remains with the main-CI coordinator; this PR does not restore the retired migration behavior, weaken the assertion, or add retries.
Review disposition: unchanged persisted data
ClawSweeper's path-based data-model warning is not a schema change. In
auth-profiles/sqlite.ts, the diff only factors the existing store/state inspection and read branches into private helpers with the same target literals, database routing, JSON reader, and unreadable-row result. No write path, table/schema definition, migration, schema version, or serializer is changed;sqlite-json.ts, the auth types/constants, andsrc/state/**are unchanged. The removedsession-status-visibility.tswas an in-process forwarding helper, andconfig/assertion-safety-baseline.txtis a static-analysis allowance file. Existing passing SQLite-store tests cover reading existing databases, shared-state ownership, external schema changes, and SecretRef plaintext exclusion. No data migration is introduced or needed.Coverage: every production file over 200 lines, sorted by baseline size
l330 agent tools, command and auth coverage
Baseline:
6ef6fc44055eed417c96bcc2f0010ad4cab4c604. All 314 production TypeScript files in the three assigned subtrees were read, largest first, with scoped instructions, relevant history and main callers. Every production file over 200 baseline lines is listed below, globally sorted by size. Three files owned by concurrent l314 were read and excluded from edits.src/agents/auth-profiles/store.tssrc/agents/auth-profiles/oauth-manager.tssrc/agents/auth-profiles/usage.tssrc/agents/tools/web-fetch.tssrc/agents/command/attempt-execution.tssrc/agents/auth-profiles/persisted.tssrc/agents/command/delivery.tssrc/agents/tools/session-status-tool.tssrc/agents/auth-profiles/runtime-snapshots.tssrc/agents/tools/sessions-send-tool.tssrc/agents/tools/gateway.tssrc/agents/tools/message-tool-execution.tssrc/agents/command/cli-compaction.tssrc/agents/tools/sessions-tool.tssrc/agents/tools/cron-tool.tssrc/agents/command/post-run.tssrc/agents/auth-profiles/profiles.tssrc/agents/tools/ask-user-tool.tssrc/agents/tools/computer-tool-node.tssrc/agents/tools/sessions-list-tool.tssrc/agents/tools/sessions-spawn-visible.tssrc/agents/auth-profiles/session-override.tssrc/agents/auth-profiles/runtime-read.tssrc/agents/command/session.tssrc/agents/tools/gateway-caller-context.tssrc/agents/command/model-selection.tssrc/agents/tools/pdf-tool.tssrc/agents/tools/sessions-spawn-tool.tssrc/agents/tools/web-fetch-visibility.tssrc/agents/command/run-embedded-attempt.tssrc/agents/tools/image-tool.tssrc/agents/tools/media-tool-shared.tssrc/agents/tools/system-agent-tool.tssrc/agents/tools/media-generate-background-shared.tssrc/agents/tools/sessions-search-tool.tssrc/agents/command/attempt-execution.helpers.tssrc/agents/tools/video-generate-tool.tssrc/agents/auth-profiles/oauth.tssrc/agents/tools/skill-workshop-tool.tssrc/agents/auth-profiles/store-read.tssrc/agents/tools/sessions-history-tool.tssrc/agents/tools/mobile-ui-tool.tssrc/agents/auth-profiles/oauth-refresh-failure.tssrc/agents/tools/message-tool-schema.tssrc/agents/tools/image-generate-tool.tssrc/agents/tools/sessions-resolution.tssrc/agents/tools/in-process-gateway.tssrc/agents/auth-profiles/sqlite.tssrc/agents/tools/cron-tool-canonicalize.tssrc/agents/tools/common.tssrc/agents/tools/model-config.helpers.tssrc/agents/command/prepare.tssrc/agents/auth-profiles/oauth-refresh-peers.tssrc/agents/tools/cron-tool-creator-cap.tssrc/agents/tools/computer-tool-request.tssrc/agents/tools/cron-tool-schema.tssrc/agents/tools/subagents-tool.tssrc/agents/command/acp-lifecycle.tssrc/agents/auth-profiles/upsert-with-lock.tssrc/agents/tools/nodes-tool-media.tssrc/agents/tools/sessions-send-tool.delivery.tssrc/agents/tools/transcripts-tool.tssrc/agents/tools/message-tool-discovery.tssrc/agents/auth-profiles/runtime-snapshot-owner.tssrc/agents/tools/web-search-provider-common.tssrc/agents/tools/secrets-tool.tssrc/agents/auth-profiles/oauth-refresh-fence.tssrc/agents/auth-profiles/order.tssrc/agents/tools/web-fetch-utils.tssrc/agents/tools/dashboard-tool.tssrc/agents/auth-profiles/usage-state.tssrc/agents/auth-profiles/legacy-source-diagnostic.tssrc/agents/tools/media-generate-background.tssrc/agents/auth-profiles/external-cli-sync.tssrc/agents/command/acp-execution.tssrc/agents/tools/sessions-access.tssrc/agents/tools/web-search-output.tssrc/agents/tools/agents-wait-tool.tssrc/agents/tools/image-tool.model-execution.tssrc/agents/tools/video-generate-tool.execution.tssrc/agents/tools/computer-tool.tssrc/agents/tools/pdf-tool.model-config.tssrc/agents/command/transcript-persistence.tssrc/agents/command/session-store.tssrc/agents/tools/nodes-tool.tssrc/agents/tools/sessions-send-followup.tssrc/agents/tools/music-generate-tool.tssrc/agents/tools/embedded-gateway-stub.tssrc/agents/auth-profiles/external-auth.tssrc/agents/command/types.tssrc/agents/command/session-preparation.tssrc/agents/tools/message-tool-visible-content.tssrc/agents/tools/media-generate-background-completion.tssrc/agents/tools/terminal-tool.tssrc/agents/tools/web-shared.tssrc/agents/auth-profiles/sqlite-json.tssrc/agents/tools/computer-tool-result.tssrc/agents/tools/image-tool.helpers.tssrc/agents/tools/computer-tool-bindings.tssrc/agents/auth-profiles/inline-usage.tssrc/agents/tools/pdf-native-providers.tssrc/agents/auth-profiles/shared-store-bootstrap.tssrc/agents/auth-profiles/mutation-lineage.tssrc/agents/auth-profiles/sqlite-read.tssrc/agents/tools/sessions-send-tool.a2a.tssrc/agents/tools/plugins-tool.tssrc/agents/tools/nodes-tool-commands.tssrc/agents/tools/sessions-tool-schema.tssrc/agents/tools/manifest-capability-availability.tssrc/agents/tools/gateway-tool.tssrc/agents/tools/music-generate-tool.execution.tssrc/agents/command/shared-types.tssrc/agents/tools/image-generate-tool.execution.tssrc/agents/tools/message-tool-source-policy.tssrc/agents/tools/sessions-send-followup-custody.tssrc/agents/tools/computer-tool-schema.tssrc/agents/tools/session-status-model.tssrc/agents/auth-profiles/runtime-external-profile-references.tssrc/agents/tools/media-generate-tool-actions-shared.tssrc/agents/tools/message-tool-schema-scoping.tssrc/agents/auth-profiles/types.tssrc/agents/command/lifecycle.tssrc/agents/tools/cron-tool-write.tssrc/agents/auth-profiles/path-resolve.tssrc/agents/tools/sessions-tool-patch.tssrc/agents/tools/cron-tool-output-schema.tssrc/agents/command/maintenance.tssrc/agents/command/delivery-result.ts