- Orchestrator Agent: A primary agent that receives user requests.
- Specialist Agent: An agent with a specific skill (e.g., image analysis) that the Orchestrator Agent can query.
1. The Architectural Pattern
The core idea is that theOrchestrator Agent is also a Nevermined subscriber. It will purchase a payment plan for the Specialist Agent and use its credits to pay for services on behalf of the end-user.
2. Setting Up the Specialist Agent
First, create and register theSpecialist Agent. This process is identical to the Simple AI Agent Guide. The key is that this agent has a service that another agent will consume.
Specialist Agent (specialist-agent/src/index.ts):
AGENT_ID and PLAN_ID.
3. Building the Orchestrator Agent
TheOrchestrator Agent will have its own public-facing endpoint, but internally it will act as a client to the Specialist Agent.
Step 3.1: Orchestrator’s Environment
The orchestrator needs the Specialist Agent’s details in its.env file.
orchestrator-agent/.env
Step 3.2: Purchasing a Plan for the Specialist
The Orchestrator must purchase a plan to access the Specialist. This can be done in an initialization script.orchestrator-agent/src/initialize.ts
Step 3.3: The Orchestrator’s Logic
The orchestrator’s main endpoint receives a request, queries the specialist, combines the results, and returns a final response.orchestrator-agent/src/index.ts
4. Economic Flow and Considerations
- Pricing Strategy: The
Orchestrator Agent’s payment plan must be priced to cover the costs of querying theSpecialist Agent, plus a margin. If the specialist costs 10 credits per query, the orchestrator might charge the end-user 25 credits. - Credit Management: The orchestrator must monitor its own credit balance for the specialist’s plan and re-purchase or upgrade as needed. This logic can be automated.
- Error Handling: What happens if the specialist agent is down or the orchestrator runs out of credits? Your orchestrator should have robust error handling to manage these scenarios, perhaps by falling back to a default (less accurate) model.
- Discovery: In a more advanced system, the orchestrator could dynamically discover specialist agents from the Nevermined registry based on their skills (metadata tags) and choose the most cost-effective one.