Skip to content

AI SDK v6 ToolLoopAgent: Message Conversion Error & Missing Agent Handoffs #119

@ldriss

Description

@ldriss

Hi Team,

Environment

  • AI SDK Version: v6.0.0-beta.101
  • Framework: Next.js 15.5.6
  • Error Location: process-ui-message-stream.ts:654:25

Problem

When using ToolLoopAgent with message history, message conversion fails:

const agent = new ToolLoopAgent({ 
  model: userProvider.languageModel('claude-haiku-4'),
  instructions: 'You are a helpful assistant.',
  tools 
});



const uiMessages = [...previousMessages, newMessage];
const modelMessages = convertToModelMessages(uiMessages);

const result = await agent.stream({ messages: modelMessages });

Error:


Cannot read properties of undefined (reading 'type')
at process-ui-message-stream.ts:654:25rAgent,
  messages,  // Should accept UIMessage[] directly
});

Actual Behavior

  • convertToModelMessages() throws undefined errors on message.parts
  • Even with validation, stream fails
  • Messages work fine with streamText but not with agents

Missing Features

Compared to @ai-sdk-tools/agents (for AI SDK v5), v6 ToolLoopAgent is missing:

  1. handoffs: [Agent[]] - Multi-agent orchestration with automatic delegation
  2. matchOn: string[] | RegExp[] - Instant pattern-based routing (0ms, no LLM call)
  3. Automatic agent-status events - Streams {"type":"agent-status"} for UI updates
  4. Memory provider integration - memory: { provider, workingMemory, history }
  5. Stable message handling - Messages that work with streamText fail with agents

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions