Skip to content

Hydrate POST /v1/events with the routed agent constitution - #333

Merged
tylerreckart merged 5 commits into
mainfrom
fix/event-ingest-hydrate-agent-def
Sep 21, 2026
Merged

tylerreckart merged 5 commits into
mainfrom
fix/event-ingest-hydrate-agent-def

Conversation

@cursor

@cursor cursor Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

POST /v1/events routes file-backed agents first, then the full tenant catalog (list_agent_records_for_routing, up to 10k). It then delegates to handle_orchestrate with only agent_override set. Orchestrate preloads list_agent_records(..., 200) (newest updated_at) and never reads agents_dir.

That mismatch has two failure modes:

  1. A file-backed match, or a tenant agent off the newest-200 page, 404s agent not found after SSE opens.
  2. A file-backed id that collides with a tenant row can run the tenant constitution even though file routing won.

Fix

After routing, attach the winning constitution as inline agent_def on the synthetic orchestrate body (stamped id matches the override). File-backed glob wins even when a tenant row shares the id. Explicit agent / tenant routing prefer the tenant blob, then fall back to agents_dir. index is unchanged.

Tests

unit_route_event — file-backed load by stem / Title Case; file routing prefers the file blob over a colliding tenant blob; tenant/explicit prefer the tenant blob; file fallback when the tenant row is missing; index and unknown ids stay empty.

Independently mergeable against main. Code hunks (event_routing, handle_event_ingest) auto-merge with #321–#332. CHANGELOG [Unreleased] will need a rebase after whichever sibling merges first.

Open in Web View Automation 

Note

Medium Risk
Changes how event ingest hands off to orchestrate and which constitution runs when file and tenant agents share an id; behavior is covered by new unit tests and fails open if JSON parse fails.

Overview
POST /v1/events now passes the routed agent’s constitution into orchestrate as inline agent_def, closing a gap where routing could pick a file-backed agent or a tenant agent outside orchestrate’s newest-200 preload while the run still 404’d agent not found or used the wrong stored definition on id collision.

Event ingest records whether file glob routing won, loads the tenant agent_def when tenant routing wins, and uses new event_ingest_agent_def_json / file_backed_agent_def_json helpers to choose the blob (file wins on clash when file routing won; explicit/tenant paths prefer tenant, then disk) and stamp id to match agent_override. Docs and CHANGELOG describe the behavior; unit_route_event covers load, stem vs display name, and precedence.

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

Orchestrate only preloads the newest-200 tenant catalog and never reads
agents_dir, so a file-backed match or an off-page tenant agent 404'd
(or, on an id clash, ran the tenant blob). Attach the winning
constitution as inline agent_def so dispatch matches routing.

Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
@tylerreckart
tylerreckart enabled auto-merge (squash) September 21, 2026 13:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 426dbde. Configure here.

Comment thread src/event_routing.cpp
Keep both Unreleased changelog entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_dba1911b-2948-4d9d-b30a-e96a91f79364)

Keep both Unreleased changelog entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep both Unreleased changelog entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tylerreckart
tylerreckart merged commit 01ff5fd into main Sep 21, 2026
1 of 5 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