Blog/

announcements

Beyond Workflows: Introducing Agent Network (vNext)

·

Jul 3, 2025

When building AI applications, sometimes the path to success is unclear. You know your goal. But how do you, e.g., get multiple agents to work together in the best possible way? Such systems contain a level of complexity that often cannot be resolved through deterministic approaches.

That's why we built Agent Network (vNext) – a smart orchestration layer that lets AI decide how to best use your agents, workflows, and tools.

The Problem with Predetermined Paths

Workflows excel at predictable execution but lack flexibility for real-world AI applications.

Some of their challenges can include:

  • Unknown execution paths: Uncertain which primitives to run or in what order
  • Unstructured inputs: Converting natural language to structured tasks
  • Dynamic collaboration: Enabling intelligent teamwork between agents
  • Context-aware routing: Making decisions based on conversation history

Consider: "Tell me about the 3 biggest cities in France and their weather right now. Write a blog post about this."

Traditional workflows require pre-defining every step. With Agent Network, an LLM determines and executes the plan automatically.

How Agent Network Works

Agent Network operates in two modes:

Mode 1: Unstructured Input → Structured Execution

Acts as an intelligent router, converting natural language to the right primitive with proper input format.

Example: When a user says "tell me about Paris," Agent Network:

  • Identifies a city research workflow needing { city: string }
  • Calls that workflow with { "city": "Paris" }
  • Routes based on agent descriptions and schemas

Mode 2: Non-Deterministic Multi-Step Workflows

Creates dynamic execution plans for complex tasks using memory-aware orchestration.

Example: For the France cities blog post, Agent Network might:

  1. Find the 3 biggest French cities via research agent
  2. Execute city workflow for each location
  3. Get real-time weather data
  4. Generate final blog post with writer agent

The AI defines the execution plan, not you.

Memory-Driven Intelligence

Agent Network leverages Mastra's memory system to make smart routing decisions:

  • Conversation awareness: Uses context for primitive selection
  • Task history: Tracks progress to avoid duplication
  • Completion detection: Recognizes when tasks are finished

Memory enables sophisticated orchestration for complex tasks.

Register Any Mastra Primitive

Agent Network accepts any Mastra primitive, creating unprecedented flexibility:

 1const network = new NewAgentNetwork({
 2  id: "research-network",
 3  name: "Research Network",
 4  instructions: "Coordinate research and writing tasks intelligently",
 5  model: openai("gpt-4o"),
 6  agents: {
 7    researchAgent: researchAgent,
 8    writerAgent: writerAgent,
 9  },
10  workflows: {
11    cityResearch: cityWorkflow,
12  },
13  tools: {
14    weatherTool: weatherTool,
15  },
16  memory: memory,
17});

Two Methods for Different Use Cases

.generate() - Single Task Execution

Perfect for chat interfaces and one-off tasks:

 1// Routes to the most appropriate primitive
 2const result = await network.generate("Tell me about Tokyo", {
 3  runtimeContext,
 4});

.loop() - Complex Multi-Step Tasks

For tasks requiring multiple primitives and sophisticated planning:

 1// Orchestrates multiple agents and workflows automatically
 2const result = await network.loop(
 3  "Research the top 3 cities in Japan, get their weather, and write a travel guide",
 4  { runtimeContext },
 5);

Better Routing Through Better Descriptions

Agent Network routing quality depends on clear primitive descriptions:

 1const cityWorkflow = createWorkflow({
 2  id: "city-research",
 3  description:
 4    "Perfect for researching specific cities. Use when you have a city name.",
 5  inputSchema: z.object({
 6    city: z.string().describe("The city to research"),
 7  }),
 8  // ...
 9});

Better descriptions lead to smarter routing decisions.

When to Use Agent Network vs Workflows

Choose Agent Network when:

  • Task execution path is uncertain or complex
  • You need intelligent routing based on context
  • Working with unstructured natural language inputs
  • Multiple agents need to collaborate dynamically

Choose Workflows when:

  • You need deterministic, predictable execution
  • The task sequence is well-defined
  • Performance and token efficiency are critical
  • Debugging requires explicit control flow

Key changes in vNext

The vNext implementation improves on our experimental Agent Network:

  • Workflow-based execution: Uses Mastra workflows under the hood instead of tool calls for better reliability
  • New .generate() method: Perfect for chat-based interfaces where you iterate on solutions
  • Improved routing: Better primitive selection based on descriptions and input schemas

Whether you're building research assistants, content creation pipelines, or multi-step analysis tools, Agent Network provides the intelligence to route, execute, and synthesize results automatically.

You can find complete examples in our repository to start building intelligent AI orchestration today.

Stay up to date