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: Agnost AI skill
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.
Collector. This guide covers BAML v0 (baml-py and @boundaryml/baml), the
current stable release.
Manual setup: Agnost AI SDK
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 theCollector.
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.lastisNone. - Create one
Collectorper request. A shared collector keeps every past call, andcollector.lastcan belong to another request. - Confirm
agnost.init("your-org-id")runs before the firstbegin(). - Short scripts must call
agnost.shutdown()oragnost.flush()before exit. - For the OpenTelemetry path, confirm
X-Agnost-Org-IDis set on the exporter and that every span hasgen_ai.operation.name. Spans without GenAI attributes are dropped. - Setting
BOUNDARY_API_KEYsends 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.