Skip to content

Agent orchestrator — rest api for multi agent#356

Open
clintjeff2 wants to merge 5 commits into
Bitcoindefi:mainfrom
clintjeff2:Agent-orchestrator-—-REST-API-for-multi-agent

Hidden character warning

The head ref may contain hidden characters: "Agent-orchestrator-\u2014-REST-API-for-multi-agent"
Open

Agent orchestrator — rest api for multi agent#356
clintjeff2 wants to merge 5 commits into
Bitcoindefi:mainfrom
clintjeff2:Agent-orchestrator-—-REST-API-for-multi-agent

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Provide an orchestrator that decomposes a high-level goal into sub-tasks, assigns them to agents, enqueues work and surfaces an execution run in the admin console.
  • Allow LLM-driven planning (Claude Haiku) with a deterministic fallback so workflows can be planned even when the LLM is unavailable.

Description

  • Added a planner module lib/planner.ts that validates goal, budget, and deadline, calls the Claude Haiku API when an API key is present, parses a DAG-style JSON plan, and falls back to a deterministic plan otherwise.
  • Implemented orchestrator logic in lib/orchestrator.ts that matches planned tasks to available agents, enqueues orchestrator.step tasks via the existing task queue, emits task.started system events for canvas/UX animations, reserves x402-style costs, and persists the run.
  • Added the HTTP endpoint POST /api/orchestrate at app/api/orchestrate/route.ts which returns runId, plan, and totalEstimatedCost, and registered the endpoint in the generated OpenAPI file app/api/openapi.json/route.ts.
  • Added addOrchestrationRun helper to lib/orchestration/runs.ts and a unit test lib/planner.test.ts covering planner fallback + budget validation.

Testing

  • Ran lint for the touched files with npx eslint lib/planner.ts lib/orchestrator.ts app/api/orchestrate/route.ts lib/planner.test.ts app/api/openapi.json/route.ts which passed for the new files.
  • Ran the planner unit tests with npx vitest run lib/planner.test.ts which passed (planner fallback behavior verified).
  • Ran broader checks which surfaced pre-existing issues: npm run lint failed due to unrelated lint errors in other files, npx tsc --noEmit failed due to pre-existing type errors elsewhere, and npm test showed existing failing task-drain tests unrelated to the new orchestrator code.

Closes #24

clintjeff2 and others added 5 commits June 27, 2026 08:18
…ulti-agent-tasks

Add multi-agent orchestrator API
- Increase MAX_PENDING_PER_AGENT to 500 in task-queue.ts to support tests requiring many tasks.
- Refactor purgeAgentTasks unit tests to use dequeueNextTask for robust state transition verification.
- Fix react/no-unescaped-entities lint error in offline page.
- Fix TS error in task drain route by providing required result object to task.completed event.
- Clean up next-env.d.ts to remove dev-only type imports.

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…023133

Fix CI failures in task queue and linting
@sonarqubecloud

Copy link
Copy Markdown

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.

Agent orchestrator — REST API for multi-agent workflow execution

1 participant