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.
Manual setup: Agnost AI SDK
act, extract, or observe call that you want to see as one interaction.
Call await agnost.shutdown() once when the application exits, not after each request.
Manual setup: OpenTelemetry
Stagehand v4 can export its own traces with thetelemetry.traces option, but those spans
carry only stagehand.* operation and log attributes: no prompts, no model output, and no
user or session. Agnost AI does not ingest them. Instead, route Stagehand’s model calls
through a bring-your-own-LLM callback
that calls the Vercel AI SDK with telemetry on. Every inference Stagehand makes for act,
extract, and observe then arrives as GenAI spans with the full prompt and answer.
Install
@ai-sdk/openai or another AI SDK provider in place of @ai-sdk/anthropic if you prefer.
Setup
1. Register the exporter once at startupbrowserbase.launch() in
place of localBrowser.launch(). Model Gateway is bypassed: the callback calls your provider
with your own key.
What appears in Agnost AI
- Conversations grouped by
sessionId. - User-level analytics grouped by
userId. - Events named
stagehand(one per model call), withagent_stepandchatchildren. The input is Stagehand’s instruction plus the page snapshot; the output is the JSON the model returned.extractmakes a second call that checks whether the extraction finished.
Verify
Run oneextract call, then open Events in Agnost AI. Confirm a stagehand event with
the instruction as input and the extracted JSON as output, and that the conversation shows
your sessionId and userId.
Troubleshooting
- No events: confirm
registerTelemetry(...)runs beforeStagehand.create()and that the exporter hasX-Agnost-Org-ID. Callawait sdk.shutdown()before a short script exits. modelwith amodelName(for exampleanthropic/claude-sonnet-5) runs the model inside Stagehand’s runtime, where your telemetry cannot reach it. Use thegeneratecallback.- Do not point
telemetry.tracesat Agnost AI. Those spans have no GenAI attributes and are dropped. - Events split across conversations: create the callback with the right
sessionIdfor each user session.
References
Next steps
- Conversations: review the complete Stagehand session.
- Events: inspect each model call Stagehand made.
- Patterns: organize production conversations by what users wanted.