Repository navigation
fix: avoid rebuilding unchanged agent runtimes on reload - #129257
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 11:54 PM ET / August 27, 2026, 03:54 UTC. ClawSweeper reviewWhat this changesThis PR scopes Gateway hot-reload runtime rebuilding to changed agent entries while retaining unaffected prepared runtimes only when their dependencies remain identical. Merge readinessKeep open for the protected maintainer review path. The scoped refresh is a sound repair: it preserves the all-owner fallback whenever retained runtime inputs differ, and the PR includes exact-head real-Gateway proof. Likely related people: Peter Steinberger (high confidence) introduced the current prepared-runtime lifecycle on main. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherGateway hot reload consumes changed configuration paths and refreshes prepared model runtimes used by agent turns. The change proposes a narrow refresh candidate, while the runtime lifecycle decides whether that candidate is safe to retain. flowchart LR
A[Configuration change] --> B[Gateway reload plan]
B --> C[Agent-entry scope candidate]
C --> D[Runtime lifecycle validation]
D -->|Dependencies match| E[Scoped rebuild]
D -->|Dependency differs| F[Full rebuild]
E --> G[Agent turns]
F --> G
Decision needed
Why: The item carries the protected maintainer label, so the automated review should not close or finalize it despite a clean technical review. Before merge
Agent review detailsSecurityNone. PR surfaceSource +192, Tests +186. Total +378 across 10 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the scoped-refresh implementation after owner review, preserving its complete lifecycle-input comparison as the single authority for falling back to a full rebuild. Do we have a high-confidence way to reproduce the issue? Yes. The supplied exact-head proof records the two-agent rebuild regression and a real-Gateway hot-reload run; source inspection confirms the proposed scope is revalidated at the lifecycle owner before retention. Is this the best way to solve the issue? Yes. Passing an agent-local candidate from the Gateway while letting the prepared-runtime owner validate complete dependencies is more maintainable than encoding every shared dependency in the path classifier. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3255882803c7. LabelsLabel 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)
|
9f69979 to
579b79e
Compare
|
Exact-head Crabbox/Blacksmith Testbox behavioral proof is complete.
Exact command: node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json --shell -- 'set -euo pipefail; git fetch origin 51a1be1cccafa1df2cf084fdd4de301925368c5d; git diff --exit-code 51a1be1cccafa1df2cf084fdd4de301925368c5d -- src/agents/prepared-model-runtime.refresh-scope.ts src/agents/prepared-model-runtime.scoped-refresh.test.ts src/agents/prepared-model-runtime.ts src/agents/prepared-model-runtime.types.ts src/gateway/server-reload-handlers.test.ts src/gateway/server-reload-hot.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-model-runtime-scope.ts test/vitest-unit-fast-config.test.ts test/vitest/vitest.unit-fast-paths.mjs; OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 CI=1 NODE_OPTIONS=--max-old-space-size=4096 node scripts/run-vitest.mjs src/agents/prepared-model-runtime.scoped-refresh.test.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-handlers.test.ts src/gateway/gateway.compaction-hot-reload.e2e.test.ts test/vitest-unit-fast-config.test.ts --run'The PR body now contains the same durable proof record. The previous exact-head CI lint failure was repaired by moving refresh option assembly from |
|
Exact-head Crabbox/Blacksmith Testbox behavioral proof is complete.
Exact command: node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json --shell -- 'set -euo pipefail; git fetch origin 51a1be1cccafa1df2cf084fdd4de301925368c5d; git diff --exit-code 51a1be1cccafa1df2cf084fdd4de301925368c5d -- src/agents/prepared-model-runtime.refresh-scope.ts src/agents/prepared-model-runtime.scoped-refresh.test.ts src/agents/prepared-model-runtime.ts src/agents/prepared-model-runtime.types.ts src/gateway/server-reload-handlers.test.ts src/gateway/server-reload-hot.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-model-runtime-scope.ts test/vitest-unit-fast-config.test.ts test/vitest/vitest.unit-fast-paths.mjs; OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 CI=1 NODE_OPTIONS=--max-old-space-size=4096 node scripts/run-vitest.mjs src/agents/prepared-model-runtime.scoped-refresh.test.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-handlers.test.ts src/gateway/gateway.compaction-hot-reload.e2e.test.ts test/vitest-unit-fast-config.test.ts --run' |
|
Exact-head Crabbox/Blacksmith Testbox behavioral proof is complete.
Exact command: node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json --shell -- 'set -euo pipefail; test "$(git rev-parse HEAD)" = 51a1be1cccafa1df2cf084fdd4de301925368c5d; git fetch origin 51a1be1cccafa1df2cf084fdd4de301925368c5d; git diff --exit-code 51a1be1cccafa1df2cf084fdd4de301925368c5d -- src/agents/prepared-model-runtime.refresh-scope.ts src/agents/prepared-model-runtime.scoped-refresh.test.ts src/agents/prepared-model-runtime.ts src/agents/prepared-model-runtime.types.ts src/gateway/server-reload-handlers.test.ts src/gateway/server-reload-hot.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-model-runtime-scope.ts test/vitest-unit-fast-config.test.ts test/vitest/vitest.unit-fast-paths.mjs; OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 CI=1 NODE_OPTIONS=--max-old-space-size=4096 node scripts/run-vitest.mjs src/agents/prepared-model-runtime.scoped-refresh.test.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-handlers.test.ts src/gateway/gateway.compaction-hot-reload.e2e.test.ts test/vitest-unit-fast-config.test.ts --run'The PR body now contains the same durable proof record. This PR remains open and unmerged. |
|
Independent exact-head Crabbox/Blacksmith Testbox behavioral proof is complete.
Exact command: node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json --shell -- 'set -euo pipefail; test "$(git rev-parse HEAD)" = 51a1be1cccafa1df2cf084fdd4de301925368c5d; test -z "$(git status --porcelain)"; git fetch origin 51a1be1cccafa1df2cf084fdd4de301925368c5d; git diff --exit-code 51a1be1cccafa1df2cf084fdd4de301925368c5d -- src/agents/prepared-model-runtime.refresh-scope.ts src/agents/prepared-model-runtime.scoped-refresh.test.ts src/agents/prepared-model-runtime.ts src/agents/prepared-model-runtime.types.ts src/gateway/server-reload-handlers.test.ts src/gateway/server-reload-hot.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-model-runtime-scope.ts test/vitest-unit-fast-config.test.ts test/vitest/vitest.unit-fast-paths.mjs; OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 CI=1 NODE_OPTIONS=--max-old-space-size=4096 node scripts/run-vitest.mjs src/agents/prepared-model-runtime.scoped-refresh.test.ts src/gateway/server-reload-model-runtime-scope.test.ts src/gateway/server-reload-handlers.test.ts src/gateway/gateway.compaction-hot-reload.e2e.test.ts test/vitest-unit-fast-config.test.ts --run' |
|
Land-ready verification is complete at exact head
Commands: env -u CODEX_HOME .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output
OPENCLAW_TESTBOX=1 scripts/pr prepare-run 129257 |
|
Merged via squash.
|
…9257) * fix: scope prepared runtime refreshes by agent (oc-92a.6) * fix: keep scoped runtime refresh linear (oc-92a.6) * fix: keep gateway reload hot path within lint limit
Fixes #120154
Supersedes #121299. Credit to @xydt-tanshanshan for the original agent-scoped refresh proposal and changed-path scope analysis. Thanks to reporter @shang-go for the multi-agent reproduction and performance evidence.
What Problem This Solves
Fixes an issue where any hot config reload rebuilt prepared model runtimes for every configured agent, so reload cost and event-loop blocking grew with the total agent count even when only one agent changed.
Why This Change Was Made
Agent-entry-local reloads now replace only the affected configured owners. Before retaining any other owner, the prepared-runtime lifecycle compares its complete normalized dependency key and plugin/catalog publication identity against the accepted config; shared, global, unknown, or changed dependencies fail safe to the existing full refresh.
The replacement is implemented against the current lifecycle owner rather than rebasing #121299's older config-rebinding approach. Retained readers keep immutable snapshots and auth bindings while new readers receive the accepted config stamp.
User Impact
Multi-agent gateways no longer rebuild every prepared model catalog and credential snapshot for a change isolated to one
agents.entries.*owner. Shared defaults, plugin metadata, catalog mode, environment, workspace, auth-directory, and runtime-selection changes still rebuild all affected owners.Evidence
Pre-fix regression: a two-agent local change expected build counts
[2, 1]but current main produced[2, 2].Fixed owner-boundary proof: 3 scoped-refresh tests passed, including retained artifacts, shared-dependency fallback, and new-owner creation.
Focused sibling proof: 112 prepared-runtime tests passed.
Gateway reload proof: 227 tests passed, including normalized scope propagation at the commit and rebuild boundaries.
pnpm tsgo:corepassed.Focused changed-file
oxlint, formatting, andgit diff --checkpassed.node scripts/check-changed.mjs -- <changed paths>passed every selected guard through core production typing, then the linked worktree's core-test typecheck stopped on the unrelated missingpakodeclaration imported byui/vite.config.ts. The runtime-sidecar guard likewise could not resolve worktree-localplaywright-core; worktree dependencies were not reconciled.Exact-head local repair validation ran from a clean detached worktree at pushed SHA
51a1be1cccafa1df2cf084fdd4de301925368c5d: type-awareoxlintandoxfmt --checkpassed for the three repair files; scoped refresh passed 3/3, Gateway reload passed 232/232, test-inventory coverage passed 13/13, and the real Gateway hot-reload E2E passed 1/1.Exact-head Crabbox proof ran against pushed SHA
51a1be1cccafa1df2cf084fdd4de301925368c5dwith providerblacksmith-testbox, leasetbx_01m10myajvpcbsbxt35740v1zq, and Actions run 33037132466.The remote command required remote
HEADto equal that full SHA, fetched the same SHA, required zero diff for all ten changed paths, then ran the scoped two-agent rebuild regression, Gateway reload boundary suites, test-inventory coverage, and the real Gateway hot-reload E2E:Result: PASS. The scoped regression passed 3/3 tests, Gateway reload passed 232/232 tests, test-inventory coverage passed 13/13 tests, and the built real-Gateway config-reload/agent-turn E2E passed 1/1. Crabbox reported
exitCode=0,runStatus=succeeded, andcommandMs=346453.Cleanup: the one-shot wrapper stopped the lease after success.
blacksmith testbox status --id tbx_01m10myajvpcbsbxt35740v1zqindependently reportscompletedwith no IP and links the same Actions run.Repository
autoreview --mode local: TruffleHog clean; no accepted/actionable findings; patch judged correct with 0.97 confidence.AI Assistance
AI assistance was used for issue and prior-PR analysis, implementation, regression tests, validation, review, and PR drafting. The final diff was manually inspected against the prepared-runtime lifecycle and Gateway reload owner boundaries.