Skip to content

Tool call errors have a different trace than tool call errors #17108

Closed

Description

@AbhiPrasad

Trace, Issue

Repro:

import "./instrument";
import { generateText, streamText, tool } from "ai";
import { openai } from "@ai-sdk/openai";
import dotenv from "dotenv";
import { z } from "zod";
import * as Sentry from "@sentry/node";

dotenv.config();

async function main() {
  const result = await generateText({
    model: openai("o1", { structuredOutputs: true }),
    experimental_telemetry: {
      functionId: "Simple Agent",
      recordInputs: true,
      recordOutputs: true,
      isEnabled: true,
    },
    tools: {
      calculateTool: tool({
        description: `Calculate the result of a math problem. Returns a number.`,

        parameters: z.object({
          a: z.number().describe("First number"),
          b: z.number().describe("Second number"),
        }),
        type: "function",
        execute: async ({ a, b }) => {
          throw new Error("Not implemented");
          return a + b;
        },
      }),
    },
    maxSteps: 2,
    system: `You helps users with their math problems.`,
    prompt: "What is 1 + 1?",
  });
  console.log("result", result.text);
}

main();

Activity

  1. Divyanshu7001 commented on Jul 22, 2025

    @Divyanshu7001

    Hi @AbhiPrasad ,
    I’m new to the Sentry environment and this repo. I can understand the issue conceptually, but to see the issue/trace in action, do I need to create an account or get access to https://telemetry-experience.sentry.io/?
    I’m a bit lost and would appreciate any guidance on how to replicate or observe the problem in action so I can move forward.

  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 22, 2025
  3. mydea commented on Jul 23, 2025

    @mydea
    Member

    Hey,

    we have likely identified the problem, which happens if this tools are called without a wrapping root span. This should only be the case if there is e.g. not a http server that triggers calls. In this case, you'll need to manually wrap the call with a root span to ensure things are consistent. We are currently looking to verify this and add tests showing this behavior.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 23, 2025
  5. AbhiPrasad commented on Jul 24, 2025

    @AbhiPrasad
    ContributorAuthor
  6. github-actions commented on Jul 31, 2025

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #17132, which was included in the 10.0.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

javascriptPull requests that update javascript code

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions