Migrer d'AgentNetwork vers .network()
Depuis la version v0.20.0 de @mastra/core, les changements suivants s'appliquent.
Passer d'AI SDK v4 à v5Lien direct vers Passer d'AI SDK v4 à v5
- Faites passer tous vos packages de fournisseurs de modèles à la version majeure suivante.
remarque
Vous aurez ainsi la garantie qu'ils utilisent tous désormais des modèles v5.
La mémoire est obligatoireLien direct vers La mémoire est obligatoire
- La mémoire est désormais nécessaire au bon fonctionnement du réseau d'agents.
remarque
Vous devez configurer la mémoire de l'Agent.
Procédures de migrationLien direct vers Procédures de migration
Si vous utilisiez la primitive AgentNetwork, vous pouvez remplacer AgentNetwork par Agent.
Avant :
import { AgentNetwork } from '@mastra/core/network'
const agent = new AgentNetwork({
name: 'agent-network',
agents: [agent1, agent2],
tools: { tool1, tool2 },
model: 'openai/gpt-5.6-sol',
instructions: 'You are a network agent that can help users with a variety of tasks.',
})
await agent.stream('Find me the weather in Tokyo.')
Après :
import { Agent } from '@mastra/core/agent'
import { Memory } from '@mastra/memory'
const memory = new Memory()
const agent = new Agent({
id: 'agent-network',
name: 'agent-network',
agents: { agent1, agent2 },
tools: { tool1, tool2 },
model: 'openai/gpt-5.6-sol',
instructions: 'You are a network agent that can help users with a variety of tasks.',
memory,
})
await agent.network('Find me the weather in Tokyo.')
Si vous utilisiez la primitive NewAgentNetwork, vous pouvez remplacer NewAgentNetwork par Agent.
Avant :
import { NewAgentNetwork } from '@mastra/core/network/vnext'
const agent = new NewAgentNetwork({
id: 'agent-network',
name: 'agent-network',
agents: { agent1, agent2 },
workflows: { workflow1 },
tools: { tool1, tool2 },
model: 'openai/gpt-5.6-sol',
instructions: 'You are a network agent that can help users with a variety of tasks.',
})
await agent.loop('Find me the weather in Tokyo.')
Après :
import { Agent } from '@mastra/core/agent'
import { Memory } from '@mastra/memory'
const memory = new Memory()
const agent = new Agent({
id: 'agent-network',
name: 'agent-network',
agents: { agent1, agent2 },
workflows: { workflow1 },
tools: { tool1, tool2 },
model: 'openai/gpt-5.6-sol',
instructions: 'You are a network agent that can help users with a variety of tasks.',
memory,
})
await agent.network('Find me the weather in Tokyo.')