gateway: hot-reload heartbeat when agents.list changes#4108
gateway: hot-reload heartbeat when agents.list changes#4108jifanchn wants to merge 3 commits intoopenclaw:mainfrom
Conversation
dadf336 to
e7f4c69
Compare
|
The The format issues are in |
When agents.list configuration changes, the heartbeat scheduler should restart to pick up new agent configurations. This enables dynamic agent registration workflows where new agents are added to the config file and their heartbeat tasks are automatically scheduled without requiring a full gateway restart.
e7f4c69 to
fe311a4
Compare
Additional Comments (2)
Also appears in tests: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/gateway/config-reload.ts
Line: 56:58
Comment:
[P1] `agents.list` reload prefix likely won’t match actual diff path (`agents.list.<id>`)
`diffConfigPaths` will produce a path like `agents.list.<agentId>` when an element is added/removed (because it treats objects recursively), not `agents.list`. Your new rule `{ prefix: "agents.list", ... }` will match `agents.list.<id>` (good), but only if the config structure is an object keyed by agentId. If `agents.list` is actually an *array* (as the name suggests), `diffConfigPaths` will emit just `agents.list` on any change (array diff returns `[prefix]`), which is also covered. The ambiguous naming makes this easy to mis-assume; a targeted test for add/remove that uses the real shape of `agents.list` would prevent regressions.
Also appears in tests: `src/gateway/config-reload.test.ts:88-92` (test only asserts the literal path, not a realistic diff).
How can I resolve this? If you propose a fix, please make it concise.
This test calls Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: src/gateway/config-reload.test.ts
Line: 88:92
Comment:
[P2] Test doesn’t validate actual config diff behavior for agent add/remove
This test calls `buildGatewayReloadPlan(["agents.list"])` directly, but the real trigger is `diffConfigPaths(prev, next)`. Depending on whether `agents.list` is an array or an object, the diff path might be `agents.list` or `agents.list.<id>` (or deeper). Consider constructing `prev/next` configs and asserting `diffConfigPaths` output drives the restart heartbeat behavior, so the test covers the end-to-end contract rather than a hard-coded string.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
Address code review feedback from greptile-apps: - Add test that verifies diffConfigPaths produces 'agents.list' for array changes - Add test for agent removal scenario - Tests now cover the end-to-end contract from config diff to reload plan
|
Thanks for the review feedback! I've addressed both concerns: P1 - agents.list prefix matching:
P2 - End-to-end test coverage:
The key insight is that |
bfc1ccb to
f92900f
Compare
Summary
When agents are added or removed via config changes, the heartbeat scheduler now restarts automatically. This ensures newly added agents get their heartbeat tasks scheduled without requiring a full gateway restart.
Use case: In multi-tenant deployments where agents are dynamically registered (e.g., via extension plugins), new agents need their heartbeat tasks to start without restarting the entire gateway.
Changes
agents.listtoBASE_RELOAD_RULESwithrestart-heartbeatactionTest plan
pnpm exec vitest run src/gateway/config-reload.test.tspasses (9 tests)Greptile Overview
Greptile Summary
This PR extends the gateway config hot-reload rules so that changes under
agents.listtrigger a heartbeat scheduler restart, ensuring newly added/removed agents get their heartbeat tasks (re)scheduled without a full gateway restart. It also adds a unit test asserting that a change toagents.listsetsrestartHeartbeatin the reload plan.The change fits into the existing
buildGatewayReloadPlanmechanism insrc/gateway/config-reload.ts, where config path prefixes map to either no-op, hot actions (like restarting cron/heartbeat), or full gateway restart.Confidence Score: 4/5
diffConfigPathsoutput foragents.listshape changes.(2/5) Greptile learns from your feedback when you react with thumbs up/down!