Skip to content

Bug: agent-job agentRunCache grows unbounded under sustained run fan-out #77976

Description

@fede-kamel

Problem

src/gateway/server-methods/agent-job.ts keeps an in-process agentRunCache: Map<runId, AgentRunSnapshot> populated by every terminal lifecycle event. There is a 10-minute TTL pruned on every set via pruneAgentRunCache, but no max-size cap.

Under sustained subagent fan-out (lots of agent.run lifecycle traffic), the snapshot map grows in lockstep with run rate up to "all runs in the last 10 minutes" before TTL prune can bound it. Same shape as the Discord REST entity cache leak (#77975).

Sibling Maps in this file (agentRunStarts, agentRunWaiterCounts, pendingAgentRunErrors, pendingAgentRunTimeouts) are already lifecycle-bound; only the terminal-snapshot cache lacks a hard cap.

Tracking PR

Fix in #77973.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions