Skip to content

[BUG]: ToolLoopAgent in AI SDK 6 is not captured in LLM ObservabilityΒ #7146

@makinjc

Description

@makinjc

Tracer Version(s)

5.81.0

Node.js Version(s)

25.2.15.8

Bug Report

This is the sample code for upcoming V6 SDK (which is to be GA next week): https://v6.ai-sdk.dev/docs/agents/overview

However it is not being captured in LLM Observability. I tried regular stream text, object are captured. This is only a wrapper though and I think it will be a very popular implementation moving forward.

If there is any interim steps I can do here to make them available, I'd be glad to do it as well.

  const weatherAgent = new ToolLoopAgent({
    model: google("gemini-2.5-flash-lite"),
    tools: {
      weather: tool({
        description: 'Get the weather in a location (in Fahrenheit)',
        inputSchema: z.object({
          location: z.string().describe('The location to get the weather for'),
        }),
        execute: async ({ location }) => ({
          location,
          temperature: 72 + Math.floor(Math.random() * 21) - 10,
        }),
      }),
      convertFahrenheitToCelsius: tool({
        description: 'Convert temperature from Fahrenheit to Celsius',
        inputSchema: z.object({
          temperature: z.number().describe('Temperature in Fahrenheit'),
        }),
        execute: async ({ temperature }) => {
          const celsius = Math.round((temperature - 32) * (5 / 9));
          return { celsius };
        },
      }),
    },
    // Agent's default behavior is to stop after a maximum of 20 steps
    // stopWhen: stepCountIs(20),
  });
  
  const result = await weatherAgent.generate({
    prompt: 'What is the weather in San Francisco in celsius?',
  });

Reproduction Code

No response

Error Logs

No response

Tracer Config

No response

Operating System

No response

Bundling

Unsure

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions