You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/gateway/server-reload-handlers.ts and src/gateway/server.impl.ts both use getActiveEmbeddedRunCount() to account for in-flight CLI agent runs when computing gateway capacity and deciding whether config reloads are safe. Both sites currently read 0 (literal or stub no-op), causing two regressions:
Config reload safety: createGatewayReloadHandlers line 154 treats active CLI runs as zero, so config reloads proceed mid-run and pick up new config values into in-flight subprocess executions.
Gateway capacity accounting: server.impl.ts:302 computes getTotalQueueSize() + getTotalPendingReplies() + getActiveEmbeddedRunCount() — the CLI subprocess count is silently omitted from the capacity budget. This was flagged in the prior audit comment on audit: review all Pi engine stub replacements for ChannelBridge compatibility #2089 but split out here for tracking.
Tracked from the ChannelBridge compatibility audit on #2089.
Both silently miscount active CLI subprocesses as zero.
Expected behavior
ChannelBridge registers session runs in src/agents/session-run-registry.ts::ACTIVE_SESSION_RUNS via registerSessionRun at channel-bridge.ts:160 and unregisters at channel-bridge.ts:349. The registry exposes getActiveSessionRunCount() returning the map size — this is the correct replacement for getActiveEmbeddedRunCount().
Proposed fix
server-reload-handlers.ts
import{getActiveSessionRunCount}from"../agents/session-run-registry.js";// Inside createGatewayReloadHandlers(params):constgetActiveCounts=()=>{constqueueSize=getTotalQueueSize();constpendingReplies=getTotalPendingReplies();constactiveRuns=getActiveSessionRunCount();return{ queueSize, pendingReplies, activeRuns };// rename from embeddedRuns};
Rename the field from embeddedRuns to activeRuns across all callers in this file (grep shows it's used in the reload-eligibility check and logging).
Summary
src/gateway/server-reload-handlers.tsandsrc/gateway/server.impl.tsboth usegetActiveEmbeddedRunCount()to account for in-flight CLI agent runs when computing gateway capacity and deciding whether config reloads are safe. Both sites currently read0(literal or stub no-op), causing two regressions:createGatewayReloadHandlersline 154 treats active CLI runs as zero, so config reloads proceed mid-run and pick up new config values into in-flight subprocess executions.server.impl.ts:302computesgetTotalQueueSize() + getTotalPendingReplies() + getActiveEmbeddedRunCount()— the CLI subprocess count is silently omitted from the capacity budget. This was flagged in the prior audit comment on audit: review all Pi engine stub replacements for ChannelBridge compatibility #2089 but split out here for tracking.Tracked from the ChannelBridge compatibility audit on #2089.
Current regressed state
server-reload-handlers.ts:150-158(GUTTED post-#77):server.impl.ts:302(REGRESSED via v2026.3.7 sync — importsgetActiveEmbeddedRunCountfrompi-embedded-runner/runs.js, a separate stub file):Both silently miscount active CLI subprocesses as zero.
Expected behavior
ChannelBridge registers session runs in
src/agents/session-run-registry.ts::ACTIVE_SESSION_RUNSviaregisterSessionRunatchannel-bridge.ts:160and unregisters atchannel-bridge.ts:349. The registry exposesgetActiveSessionRunCount()returning the map size — this is the correct replacement forgetActiveEmbeddedRunCount().Proposed fix
server-reload-handlers.tsRename the field from
embeddedRunstoactiveRunsacross all callers in this file (grep shows it's used in the reload-eligibility check and logging).server.impl.ts:302Replace:
with:
Then delete
src/agents/pi-embedded-runner/runs.ts(the stub file with thereturn 0implementation).Acceptance Criteria
server-reload-handlers.tsusesgetActiveSessionRunCountfromsession-run-registryserver.impl.tsusesgetActiveSessionRunCountfromsession-run-registrysrc/agents/pi-embedded-runner/runs.tsstub file deletedembeddedRuns→activeRunspropagated throughoutserver-reload-handlers.tspnpm checkpassesgetActiveEmbeddedRunCountOut of Scope
model.ts,run/params.ts) — tracked separately as part of the audit: review all Pi engine stub replacements for ChannelBridge compatibility #2089 cascade sweeppi-embedded.tsbarrel — tracked under audit: review all Pi engine stub replacements for ChannelBridge compatibility #2089 cascade sweep/abort, subagent kill/steer — separate sub-issuesRelated
src/agents/session-run-registry.ts— replacement run tracking moduleserver.impl.ts:302as a hidden capacity miscount