Skip to content

Route messages to all mentioned agents so tasks run in parallel - #575

Open
QuanCheng-QC wants to merge 2 commits into
developfrom
bugfix/parallel-mention-routing
Open

Route messages to all mentioned agents so tasks run in parallel#575
QuanCheng-QC wants to merge 2 commits into
developfrom
bugfix/parallel-mention-routing

Conversation

@QuanCheng-QC

Copy link
Copy Markdown
Collaborator

Problem

Assigning different tasks to different agents in one channel showed the
"message queued" status instead of parallel work. Every routing path was
single-target: _fallback_targets kept only the first @mention, and in
dynamic mode explicit @mentions never bypassed the LLM router, which
collapses multi-name answers to one agent. All tasks landed on one agent,
whose per-channel queue then serialized them.

Fix

Routing (workspace_mod.py)

  • _fallback_targets honors ALL explicit @mentions (deduped, agent self-mentions filtered)
  • Human messages with explicit mentions skip the LLM router in dynamic/workflow modes; master mode keeps its star topology
  • The LLM router accepts multi-name answers (next:a,b), validating each name and dropping unknowns/self-loops; _ROUTER_PROMPT teaches the multi-target format; router max_tokens raised 30 → 64
  • Master-mode delegation mentions deduped at the source

Cloud agents (cloud_agent.py)

  • Targeted cloud agents invoked concurrently instead of a sequential await loop
  • Fan-out bounded by a semaphore (new CLOUD_AGENT_MAX_CONCURRENCY config, default 4)
  • DB access split into short-lived sessions released before every provider API call; targets deduped before the gather
  • Image/audio file records and their response message still commit in one transaction

Intentionally unchanged: one agent still processes one task at a time per
channel (session-context ordering).

Tests

  • 7 new routing tests + new test_cloud_agent.py (5 tests: dedupe, sentinel filtering, concurrency cap, depth limit)
  • test_llm_router.py + test_cloud_agent.py pass 38/38; full backend suite 344 passed, failure set diff-identical to the develop baseline's pre-existing environmental failures

🤖 Generated with Claude Code

Assigning tasks to different agents in one channel used to funnel every
message through single-target routing — the fallback kept only the first
@mention, the LLM router truncated multi-name answers to one agent, and
in dynamic mode explicit mentions never bypassed the router at all. All
tasks landed on one agent whose per-channel queue then serialized them,
showing the 'message queued' status in the UI instead of parallel work.

- honor ALL explicit @mentions (deduped, self-mentions filtered) in
  _fallback_targets instead of just the first one
- human messages with explicit mentions now skip the LLM router and
  target the mentioned agents directly in dynamic/workflow modes
  (master mode keeps its star topology)
- the LLM router now accepts multi-name answers ('next; a, b') and
  targets every valid name, dropping only unknowns and self-loops
- cloud agents targeted by one message are invoked concurrently with
  per-task DB sessions instead of a sequential await loop
- bound cloud agent fan-out with a semaphore (new
  CLOUD_AGENT_MAX_CONCURRENCY config, default 4) and split DB access
  into short-lived sessions released before every provider API call,
  so a large mention list can no longer pin pool connections for the
  duration of external model round-trips
- dedupe cloud agent targets before the gather and dedupe master-mode
  delegation mentions at the source, so duplicate mentions can't invoke
  the same agent twice with duplicate billable requests
- teach the router prompt the multi-target output format ('next' with
  comma-separated names) for independent tasks, matching the parser;
  raise the router max_tokens from 30 to 64 so multi-name answers
  don't get truncated
- new tests for fan-out dedupe, sentinel filtering, concurrency cap,
  depth limit, and master-mode delegation dedupe
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openagents-workspace Ready Ready Preview, Comment Jul 29, 2026 2:15pm

Request Review

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.

1 participant