fix(host): fence stale metric completions (round 4)

This commit is contained in:
Hypatia May
2026-07-28 14:29:11 +08:00
parent d0ea5fee47
commit 765b360e26
2 changed files with 141 additions and 4 deletions

View File

@@ -438,7 +438,12 @@ export function createApiProxy(ctx: Context, defaults: ApiProxyDefaults): ApiPro
const metricsProjector = new SessionMetricsProjector(
ctx,
metricsRouteFor,
(agent) => { scheduleMetrics(agent.session) },
(agent) => {
if (metricsDisposed) return
if (ctx.agents.get(agent.id) !== agent) return
if (ctx.sessions.get(agent.id) !== agent.session) return
scheduleMetrics(agent.session)
},
)
/** Queue one full-log metrics publication after synchronous session listeners drain. */