Skip to content

[FEAT] Support for Distributed Subagents with Routing #280

@myrrakh

Description

@myrrakh

Is your feature request related to a problem? Please describe.

This is the ability to add external voltagent instances as subagents

I'm exploring the possibility of running multiple Voltagent instances across different services/projects, acting as subagents that can route requests between each other using HTTP or Pub/Sub.

The idea is to create a flexible, modular agent architecture. Here's an example of how an external agent might be registered:

registerExternalAgent({ name: "agent2", description: "Use this agent for weather-related queries", instructions: "", http: "http://localhost:3412/" });

I’ve implemented a basic prototype that uses a classification prompt to determine which agent/tool to invoke. It works, but: It’s verbose also passing context (like chat history or user state) is clunky and not scalable.

export const classifierAgent = new Agent({ memory: memory, id: "classifier-agent", name: "Classifier Agent", description: "Classifies the user's intent", llm: new VercelAIProvider(), model: openai("gpt-4o-mini"), hooks, tools, instructions:
You are a classification bot. You must classifier user intent into one of the following options:

  • General topics -> bot-agent
  • Weather -> weather-agent
    ...

You must route the user input to the corresponding agent with the structured format {
"input": "test",
"agent": "bot-agent"
}`
)}

export const tools = [
createTool({
name: "Classifier",
description: "Classifies the user's intent",
parameters: z.object({
input: z.string().describe("The user message to classify"),
agent: z.string().describe("The agent to route the message to")
}),
execute: async (parameters) => {
const { input, agent } = parameters;

        console.log({ input, agent });

        await callAgent({ input, agent });

        return {
            "success": true,
            "message": `Routed to ${agent}`
        }
    },
}),

];

export const callAgent = async ({ input, agent }: { input: string, agent: string }) => {
try {
let response: Response | null = null;

    if (agent.includes("bot-agent")) {
        response = await fetch("http://localhost:6002/agents/bot-agent/text", {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                input,
                options: {
                    "userId": "unique-user-id",
                    "conversationId": "unique-conversation-id",
                    "contextLimit": 10,
                    "temperature": 0.7,
                    "maxTokens": 100
                }
            }),
        });
    }
} catch (error) {
    console.error(error);
    return null;
}

};
`

❓ Open Questions
Should each agent manage its own database and history, or should we share user context (e.g., via Redis or a shared memory layer)?

What’s the best approach for passing relevant user context between agents?

How should agent routing be handled: via HTTP calls, Pub/Sub, or something else?

✅ Goals
Support external/sub-agents that can be routed to via HTTP or Pub/Sub.
Clean way to share or pass user context across agents.
Maintain simplicity and modularity.

Observation: We should not carry all the prompt from the subagent as it happens now, but allow it to be flexibe passing just the needed context, since this increases response latency with not needed tokens as behaviour from subagents

Describe alternatives you've considered

No response

Additional context

No response

Describe the thing to improve

I'm proposing support for registering and routing to external Voltagent instances as subagents across different services or projects. The goal is to enable a modular and distributed agent architecture, where agents can delegate work to specialized subagents over HTTP or Pub/Sub.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions