Skip to main content

Choose a setup method

Start with one method for a call path. Combining SDK tracking with framework OpenTelemetry on the same call can create duplicate interactions.
Recommended. Choose this path when you want your coding agent to inspect the project, select a supported transport, make the smallest instrumentation change, send a test event, and verify that it reached Agnost AI.
Install the skill once in your coding-agent environment:
Run the framework-specific prompt below from the application root. Review the resulting diff before deploying it.
BAML runs its LLM calls inside its own Rust runtime. Python and Node.js HTTP instrumentors (OpenInference, OpenLIT, OpenLLMetry) never see those requests, and BAML’s built-in tracing only sends to Boundary Studio. To get BAML calls into Agnost AI, wrap each BAML function call and read the call details from a BAML Collector. This guide covers BAML v0 (baml-py and @boundaryml/baml), the current stable release.

Manual setup: Agnost AI SDK

Pass a fresh Collector to each call with baml_options. After the call, collector.last holds the function name, token usage, and the LLM calls BAML made, including retries and fallbacks. The selected call is the one whose result BAML parsed.
AnswerTicket stands for any function in your baml_src. BAML returns a typed object, so the example records it as JSON. Record a single field instead (for example reply.reply) if that is the text your users see. Call agnost.shutdown() (Python) or await agnost.shutdown() (TypeScript) once when the application exits, not after each request.

What appears in Agnost AI

  • Conversations grouped by conversation_id.
  • User-level analytics grouped by user_id.
  • Events for each BAML function call, with the user message as input, the parsed result as output, and the BAML function, client, provider, and token counts as event metadata.

Manual setup: OpenTelemetry

BAML has no OpenTelemetry exporter, and its provider calls are invisible to OTel instrumentors. If you already run an OpenTelemetry pipeline, record one span per BAML call with GenAI semantic-convention attributes filled from the Collector. Agnost AI accepts these spans as agent events.

Install

Setup

gen_ai.conversation.id groups spans into one conversation and user.id attributes them to a user. If b.AnswerTicket raises, the span ends with an error status and Agnost AI marks the event as failed. The model name is read from the request body BAML sent, which holds it for OpenAI- and Anthropic-style providers. Call provider.shutdown() once when the process exits.

Verify

Run one BAML function call, then open Events in Agnost AI. Confirm the event shows the user message as input, the parsed result as output, and your user ID. Then open Conversations and confirm two calls with the same conversation ID land in one conversation.

Troubleshooting

  • Pass the collector on every call: baml_options={"collector": collector} in Python, { collector } in TypeScript. Without it, collector.last is None.
  • Create one Collector per request. A shared collector keeps every past call, and collector.last can belong to another request.
  • Confirm agnost.init("your-org-id") runs before the first begin().
  • Short scripts must call agnost.shutdown() or agnost.flush() before exit.
  • For the OpenTelemetry path, confirm X-Agnost-Org-ID is set on the exporter and that every span has gen_ai.operation.name. Spans without GenAI attributes are dropped.
  • Setting BOUNDARY_API_KEY sends traces to Boundary Studio. It does not affect Agnost AI, and you can use both.

References

Next steps

  • Conversations: review the complete BAML interaction.
  • Events: inspect each BAML function call and its metadata.
  • Patterns: organize production conversations by what users wanted.