#13408: fix(gateway): skip SIGUSR1 restart in config.patch for noop reload rules
gateway
stale
Cluster:
Gateway Hot-Reload Improvements
## Summary
`config.patch` and `config.apply` previously unconditionally scheduled `scheduleGatewaySigusr1Restart()` after writing config, even when changed paths were noop-only (e.g. `agents.*`, `models.*`).
This bypassed the existing reload rule logic already used by the file watcher (`diffConfigPaths()` + `buildGatewayReloadPlan()`).
## What changed
- Updated `src/gateway/server-methods/config.ts`:
- imported `diffConfigPaths` and `buildGatewayReloadPlan` from `../config-reload.js`
- in `config.patch` and `config.apply`, compute changed paths and reload plan after writing config
- schedule `scheduleGatewaySigusr1Restart()` only when `reloadPlan.restartGateway === true`
- when restart is not needed, return:
- `restart: { ok: true, skipped: true, reason: "no-restart-needed", noopPaths, hotReasons }`
- include a `reloadPlan` summary in the response payload
- Updated `src/gateway/server.config-patch.e2e.test.ts` with new cases:
- skips restart when only agents-scoped paths change
- still restarts when gateway-scoped paths change
- skips restart for mixed noop-only changes (`agents` + `models`)
- restarts when mixed changes include restart-required paths (`agents` + `gateway`)
## Test results
Because the default Vitest config excludes `*.e2e.test.ts`, the e2e config was used to run this file:
```bash
npx vitest run --config vitest.e2e.config.ts src/gateway/server.config-patch.e2e.test.ts
```
Result: **11 passed**
## References
Fixes #5533
Refs #1997
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the gateway `config.patch` and `config.apply` RPC handlers to compute config diffs (`diffConfigPaths`) and build a reload plan (`buildGatewayReloadPlan`) when config changes are applied. The handlers now only schedule a SIGUSR1 gateway restart when the reload plan requires it, and they return reload-plan details (including noop/hot/restart reasons) to the caller. The e2e config.patch test suite adds cases asserting restart is skipped for noop-only path changes (`agents.*`, `models.*`) and still occurs for gateway-scoped changes.
Overall, the change brings RPC-driven config updates in line with the existing file-watcher reload rules, reducing unnecessary restarts for noop-only config updates.
<h3>Confidence Score: 3/5</h3>
- Moderately safe to merge once protocol/sentinel behavior is corrected
- Core restart-skipping logic is straightforward and covered by new e2e tests, but the change introduces response payload shape drift (new `reloadPlan` and a new `restart` variant) without corresponding protocol/schema updates, and it appears to still write restart sentinels even when restarts are skipped—both can break consumers or cause false restart signals.
- src/gateway/server-methods/config.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#4108: gateway: hot-reload heartbeat when agents.list changes
by jifanchn · 2026-01-29
83.8%
#11746: fix: treat meta config paths as no-op to prevent unnecessary gatewa...
by QDenka · 2026-02-08
82.9%
#20355: fix(gateway): enforce commands.restart guard for config.apply and c...
by Clawborn · 2026-02-18
82.6%
#11280: fix(gateway): add meta prefix to reload rules to prevent double SIG...
by cheenu1092-oss · 2026-02-07
82.3%
#7128: feat: add gateway.restart RPC for graceful in-process restart
by AkashaBot · 2026-02-02
81.9%
#22720: fix: notify sessions on invalid config during hot-reload
by jayleekr · 2026-02-21
81.7%
#7747: Gateway: add zero-latency hot-reload for agent bindings
by NikolasP98 · 2026-02-03
81.1%
#5823: fix(config): exit cleanly on invalid config instead of high CPU loop
by gavinbmoore · 2026-02-01
80.9%
#12953: fix: defer gateway restart until all replies are sent
by zoskebutler · 2026-02-10
80.4%
#9112: Fix: Prevent double SIGUSR1 restart on model switch
by vishaltandale00 · 2026-02-04
79.7%