Skip to content

feat: Fan-out primitive for parallel self-invocation (#230) - #233

Merged
vybe merged 1 commit into
mainfrom
feature/230-fan-out-primitive
Mar 31, 2026
Merged

vybe merged 1 commit into
mainfrom
feature/230-fan-out-primitive

Conversation

@vybe

@vybe vybe commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add POST /api/agents/{name}/fan-out endpoint and fan_out MCP tool for dispatching N independent tasks to an agent in parallel
  • Each subtask follows the standard TaskExecutionService path — full dashboard observability (cost, tokens, logs, origin tracking)
  • Subtasks linked by fan_out_id column on execution records for aggregation and debugging
  • Concurrency controlled by asyncio.Semaphore with configurable max_concurrency (1-10, default 3)
  • Input validation: unique task IDs, max 50 tasks, message length limit, timeout 10-3600s, best-effort policy only

Changes

  • src/backend/services/fan_out_service.py — Core coordination service
  • src/backend/routers/fan_out.py — Endpoint with Pydantic validation
  • src/backend/services/task_execution_service.py — Accept fan_out_id param
  • src/backend/database.py, db_models.py, db/schedules.py, db/migrations.py — fan_out_id column + migration
  • src/backend/routers/schedules.py — Expose fan_out_id in execution API responses
  • src/mcp-server/src/tools/chat.ts — fan_out MCP tool definition
  • src/mcp-server/src/client.ts — fanOut() API client method
  • docs/memory/requirements.md — Requirement 17.5 (FANOUT-001)
  • docs/memory/feature-flows/fan-out.md — Feature flow documentation

Test Plan

  • Validation: empty tasks, duplicate IDs, invalid task IDs, concurrency > 10, unsupported policy → 422
  • Cross-agent targeting rejected → 400
  • Fan-out dispatches tasks in parallel and collects results
  • Execution records created with triggered_by=fan_out and fan_out_id linkage
  • fan_out_id visible in executions API response
  • TypeScript compiles clean
  • pytest tests/test_fan_out.py -v (14 test cases)

Closes #230

🤖 Generated with Claude Code

Add POST /api/agents/{name}/fan-out endpoint and fan_out MCP tool that
dispatches N independent tasks to an agent in parallel, collects results
with per-task status, and returns an aggregated response. Each subtask
follows the standard TaskExecutionService path for full dashboard
observability (cost, tokens, logs), linked by a shared fan_out_id.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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: Fan-out primitive for parallel self-invocation

1 participant