Manager
What the manager does
The manager is the orchestration layer (backend/src/core/manager.ts):
- Creates a session and opens an SSE channel for live updates.
- Refreshes the agent catalog from Soroban when configured.
- Builds a plan: ordered planner roles (not specific registry IDs).
- For each step, runs the decision engine to pick a concrete worker under budget.
- Calls the worker with
x402FetchJson(402 → sign → settle → JSON). - Records transactions, metrics, and job results (memory + optional Soroban
record_job_result). - Produces a final summary (LLM when configured, otherwise a stitched text summary).
Why this matters: separating “what kinds of skills” (planner) from “which supplier” (engine) keeps the system extensible when the catalog grows.
How planning works
Two modes:
LLM planner (Claude)
When ANTHROPIC_API_KEY is set, createPlan asks for strict JSON: explanation + steps[] with agentName, reason, input.
Prompt constraint (critical): the model must only output allowed planner roles — it does not choose prc_pro vs prc_bas.
Heuristic planner
If no LLM or parse fails, localPlanner uses keyword rules (e.g. “research” → DeepResearch, “sentiment” → SentimentAI) and always tries to end with Summarizer when present.
Steps are then normalized (dedupe roles, cap depth) and prioritized so Summarizer tends to run last; other steps sort by the best available engine score per role.
How decisions are made (concrete worker)
For each plan step:
- Map role → capability (
plannerRoleToCapability). - Load current catalog (chain-merged or static).
- Optionally read Soroban
get_best_agentfor that capability (when RPC returns data) and attachsorobanDeclaredWinnerIdto SSE. - Filter candidates:
price <= remaining budget, not already tried for this step. - Sort by engine score —
reputation × 0.7 − price × 0.3(backend/src/core/scoring.ts). - Hire the top worker; on failure, retry up to 3 attempts per step with the next candidates.
SSE event engine-decision includes:
chosenAgentId,engineScore,candidatesConsideredsorobanDeclaredWinnerId,oracleAlignedWithHirewhen chain data exists
Why this matters: judges can see transparent economics — not a black-box router.
Cost vs reputation tradeoff
- High reputation — better engine score, more likely to win hires, higher Soroban oracle score.
- Low price — also raises score; cheap reliable agents beat expensive mediocre ones.
- Budget in query — text like
under $0.02sets a session budget; steps stop when spend exceeds it.
Why this matters: this is how you show agent markets without hand-waving — numbers are in the API and UI.