Skip to content

Extra-fetch stored agents that fell off the newest-200 dispatch catalog - #346

Merged
tylerreckart merged 8 commits into
mainfrom
fix/dispatch-target-agent-catalog
Sep 21, 2026
Merged

tylerreckart merged 8 commits into
mainfrom
fix/dispatch-target-agent-catalog

Conversation

@cursor

@cursor cursor Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

GET /v1/agents/:id resolves a stored agent with get_agent_record. /v1/orchestrate, /v1/agents/:id/chat, A2A message/send and message/stream, and the scheduler installed only list_agent_records(200) (newest updated_at).

Event routing already has list_agent_records_for_routing because a tenant with more than 200 agents can drop older ids off that page. Dispatch never got the same treatment, so a targeted stored agent GET still found returned SSE agent not found / A2A TaskNotFound / scheduler not found in tenant catalog.

Fix

list_agent_records_for_dispatch returns the newest-200 page plus a get_agent_record of the targeted id when it is missing (empty / index skip the extra fetch). Orchestrate, A2A, and the scheduler install that set. Sibling /agent and /parallel still resolve from the newest-200 REST page; GET /v1/agents list paging is unchanged.

Tests

unit_tenant_agents — 201 agents so the 200 page drops one; dispatch of that id returns 201; on-page id is not duplicated; empty/index/missing/cross-tenant ids do not leak. Suite 7/7 locally (+ ASan/UBSan).

Independently mergeable against main (0456350). merge-tree vs #321–#345: code auto-merges. CHANGELOG [Unreleased] sibling-conflicts as usual after the first of those merges.

Open in Web View Automation 

Note

Medium Risk
Touches orchestrator catalog loading on orchestrate, A2A, and scheduler paths; behavior change is narrow (extra row when targeted id fell off the page) but affects agent resolution for large catalogs.

Overview
Fixes a catalog mismatch for tenants with more than 200 stored agents: dispatch paths only installed the newest-200 updated_at page, so GET /v1/agents/:id could succeed while /v1/orchestrate, agent chat, A2A message/send / message/stream, and the scheduler returned agent not found for older ids.

Adds TenantStore::list_agent_records_for_dispatch, which keeps the newest-200 list and extra-fetches the targeted id via get_agent_record when it is missing (skips for empty / index). build_blocking_orchestrator / build_a2a_orchestrator take an optional target_agent_id and install that set; orchestrate, A2A, and scheduler pass the run’s agent id. Sibling /agent and /parallel resolution is unchanged (still newest-200 only). Unit test covers 201-agent tenants, no duplicate on-page ids, and tenant scoping.

Reviewed by Cursor Bugbot for commit 97dd547. Bugbot is set up for automated code reviews on this repo. Configure here.

GET /v1/agents/:id already used get_agent_record. Orchestrate, A2A, and
the scheduler installed only list_agent_records(200), so a stored agent
that fell off that page 404'd as not found. Dispatch now extra-fetches
the targeted id; sibling /agent and /parallel still use the REST page.

Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
@tylerreckart
tylerreckart marked this pull request as ready for review September 21, 2026 12:59
@tylerreckart
tylerreckart enabled auto-merge (squash) September 21, 2026 12:59
@tylerreckart
tylerreckart merged commit 920c43f into main Sep 21, 2026
2 of 6 checks passed
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.

3 participants