Skip to content

feat(server): bound the finished tasks InMemoryTaskStore keeps - #441

Merged
muscariello merged 1 commit into
stack/02-pb-integral-numbersfrom
stack/03-inmemory-task-store-limit
Nov 2, 2026
Merged

muscariello merged 1 commit into
stack/02-pb-integral-numbersfrom
stack/03-inmemory-task-store-limit

Conversation

@muscariello

Copy link
Copy Markdown
Member

Fixes #401. Replaces #407. Stacked on #440: review only the last commit.

Cause: InMemoryTaskStore never removes a task and TaskStore has no delete, so a long-running agent keeps every task it has served. #401 measured 192 MiB RSS at 20,000 tasks with one 4 KiB artifact each.

Change: InMemoryTaskStore::new().with_terminal_task_limit(n) is opt-in and keeps at most n tasks in a terminal state. Past that, the task that reached a terminal state earliest is purged. Tasks that are not terminal are never purged, a purged task reads as TaskNotFoundError, and new() keeps everything as before.

Needs a decision: unlike #439 and #440, this is a feature with new public API, so it needs a design review, not only a bug-fix review.

Unproven: the memory figures in #407 and the new tests were not run locally. CI is the check.

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

InMemoryTaskStore never removed a task, and TaskStore has no delete,
so a long-running agent kept every task it ever served: 20,000 tasks
with a 4 KiB artifact each held 192 MiB.

InMemoryTaskStore::with_terminal_task_limit(n) keeps at most n tasks
in a terminal state and purges the one that reached its terminal state
earliest. Tasks that are not terminal are never purged, and a purged
task reads as TaskNotFoundError, which A2A 3.3.2 allows for a task
that was completed and purged. new() keeps every task, as before. With
a limit of 1,000 the same run stays at about 20 MiB.

Fixes: #401

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: gulldan <[email protected]>
@muscariello
muscariello force-pushed the stack/03-inmemory-task-store-limit branch from f9c9296 to 161e4b1 Compare November 2, 2026 12:02
@muscariello
muscariello removed this pull request from stack #442 November 2, 2026 15:00
@muscariello
muscariello added this pull request to stack #456 November 2, 2026 15:01
@muscariello
muscariello added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit f392d21 Nov 2, 2026
25 checks passed
@muscariello
muscariello deleted the stack/03-inmemory-task-store-limit branch November 2, 2026 17:44
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: a2a-server: let InMemoryTaskStore bound how many finished tasks it keeps

3 participants