Inspect agents written in other languages
Studio reads stock OpenTelemetry spans, not only weft’s. Export your agent’s traces over OTLP/HTTP to Studio’s ingest, POST /v1/traces, and name the spans by the OTel GenAI conventions: an invoke_agent span carrying gen_ai.conversation.id, with chat spans for model calls and execute_tool spans for tool calls under it. Studio derives one run per such span: its steps, tools, usage and cost. It has no events, transcript or requests, and says so with the derived badge.
In Python, with the OpenTelemetry SDK and its OTLP/HTTP exporter (opentelemetry-sdk, opentelemetry-exporter-otlp-proto-http), against a weft studio on its default address:
from opentelemetry import tracefrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporterfrom opentelemetry.sdk.resources import Resourcefrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessor
provider = TracerProvider(resource=Resource.create({"service.name": "py-support"}))provider.add_span_processor( BatchSpanProcessor(OTLPSpanExporter(endpoint="http://127.0.0.1:7331/v1/traces")))trace.set_tracer_provider(provider)tracer = trace.get_tracer("support-agent")
def handle(conversation_id, prompt): with tracer.start_as_current_span("invoke_agent support", attributes={ "gen_ai.operation.name": "invoke_agent", "gen_ai.agent.name": "support", "gen_ai.conversation.id": conversation_id, # without it: a trace, no run }): with tracer.start_as_current_span("chat gpt-5", kind=trace.SpanKind.CLIENT, attributes={ "gen_ai.operation.name": "chat", "gen_ai.provider.name": "openai", "gen_ai.request.model": "gpt-5", }) as chat: reply = call_model(prompt) # your model call chat.set_attribute("gen_ai.usage.input_tokens", reply.input_tokens) chat.set_attribute("gen_ai.usage.output_tokens", reply.output_tokens) with tracer.start_as_current_span("execute_tool lookup_order", attributes={ "gen_ai.operation.name": "execute_tool", "gen_ai.tool.name": "lookup_order", "gen_ai.tool.call.id": reply.call_id, }): run_tool(reply) # your tool call
# at exit: the batch processor exports in the background; flush what is queuedprovider.shutdown()In TypeScript the OTLP/HTTP trace exporter takes the same URL, new OTLPTraceExporter({ url: 'http://127.0.0.1:7331/v1/traces' }) from @opentelemetry/exporter-trace-otlp-proto or @opentelemetry/exporter-trace-otlp-http, and the spans take the same names and attributes. A GenAI instrumentation library that already emits chat spans for your model calls needs only the enclosing invoke_agent span with a conversation id, provided it writes gen_ai.provider.name (semconv 1.37 and later). Studio reads the provider from that key only; a span with the older gen_ai.system gives a run with no provider, which reads unpriced.
Send spans to Studio
Section titled “Send spans to Studio”Studio’s receiver takes OTLP/HTTP at POST /v1/traces and POST /v1/logs: protobuf or JSON, optionally gzip, at most 16 MiB per request after decompression. A write failure answers 503, so the exporter retries; a retried export lands on the same rows. OTLP over gRPC is not served.
| Studio | Ingest URL | Auth |
|---|---|---|
weft studio or weft dev | http://127.0.0.1:7331/v1/traces (or the port it printed) | none: loopback peers only |
embedded under /studio/ | <app>/studio/v1/traces | as the Studio was built |
built with studio.IngestToken(tok) | its address | Authorization: Bearer <tok> |
Without an ingest token, ingest answers only peers on the same machine, and refuses a request a proxy forwarded (Forwarded, X-Forwarded-For, X-Real-IP) and a browser page from an origin nobody allowed. A browser exporter sends an Origin, which loopback ingest refuses unless it is a localhost origin or one the Studio’s AllowOrigins names.
A Studio reachable from other hosts needs an ingest token. weft studio has no option for one, so it takes exports from this machine only; an app on another host exports to an embedded or hosted Studio built with studio.IngestToken(tok) (Run Studio). The ingest token is separate from the Studio’s API token (studio.Token). Your exporter sends it as a header:
- Python:
OTLPSpanExporter(endpoint=…, headers={"Authorization": "Bearer <tok>"}) - TypeScript:
new OTLPTraceExporter({ url: …, headers: { Authorization: 'Bearer <tok>' } }) - Either SDK, from the environment:
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20<tok>
A Python agent instrumented by the OpenTelemetry GenAI contrib packages exports to a local weft studio with:
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:7331 OTEL_METRICS_EXPORTER=none OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true opentelemetry-instrument python app.pyThe endpoint is the bare origin: the exporter adds /v1/traces and /v1/logs itself. Python’s exporter defaults to gRPC, so it needs OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf; the JavaScript one defaults to HTTP. OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true turns content capture on, which the story and the tool calls below read. A stock invoke_agent span makes a run; any other GenAI span is a trace.
Log records your agent exports to /v1/logs are stored as app logs. Those emitted under the run’s spans show on the run’s logs view, as a weft run’s bridged lines do.
Check it with an OTLP/JSON body
Section titled “Check it with an OTLP/JSON body”This body is a two-step run of a Python agent, in otherlang/stock-spans.json:
{ "resourceSpans": [{ "resource": {"attributes": [ {"key": "service.name", "value": {"stringValue": "py-support"}} ]}, "scopeSpans": [{ "scope": {"name": "support-agent"}, "spans": [ { "traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "00f067aa0ba902b7", "name": "invoke_agent support", "kind": 1, "startTimeUnixNano": "1790848800000000000", "endTimeUnixNano": "1790848803200000000", "attributes": [ {"key": "gen_ai.operation.name", "value": {"stringValue": "invoke_agent"}}, {"key": "gen_ai.agent.name", "value": {"stringValue": "support"}}, {"key": "gen_ai.conversation.id", "value": {"stringValue": "conv_7f3a"}} ], "status": {"code": 1} }, { "traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "a1b2c3d4e5f60001", "parentSpanId": "00f067aa0ba902b7", "name": "chat gpt-5", "kind": 3, "startTimeUnixNano": "1790848800050000000", "endTimeUnixNano": "1790848801250000000", "attributes": [ {"key": "gen_ai.operation.name", "value": {"stringValue": "chat"}}, {"key": "gen_ai.provider.name", "value": {"stringValue": "openai"}}, {"key": "gen_ai.request.model", "value": {"stringValue": "gpt-5"}}, {"key": "gen_ai.usage.input_tokens", "value": {"intValue": "812"}}, {"key": "gen_ai.usage.output_tokens", "value": {"intValue": "41"}} ] }, { "traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "a1b2c3d4e5f60002", "parentSpanId": "00f067aa0ba902b7", "name": "execute_tool lookup_order", "kind": 1, "startTimeUnixNano": "1790848801300000000", "endTimeUnixNano": "1790848801420000000", "attributes": [ {"key": "gen_ai.operation.name", "value": {"stringValue": "execute_tool"}}, {"key": "gen_ai.tool.name", "value": {"stringValue": "lookup_order"}}, {"key": "gen_ai.tool.call.id", "value": {"stringValue": "call_abc"}} ] }, { "traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "a1b2c3d4e5f60003", "parentSpanId": "00f067aa0ba902b7", "name": "chat gpt-5", "kind": 3, "startTimeUnixNano": "1790848801500000000", "endTimeUnixNano": "1790848803100000000", "attributes": [ {"key": "gen_ai.operation.name", "value": {"stringValue": "chat"}}, {"key": "gen_ai.provider.name", "value": {"stringValue": "openai"}}, {"key": "gen_ai.request.model", "value": {"stringValue": "gpt-5"}}, {"key": "gen_ai.usage.input_tokens", "value": {"intValue": "905"}}, {"key": "gen_ai.usage.output_tokens", "value": {"intValue": "37"}} ] } ] }] }]}Post it to a running weft studio from docs-site/examples; the run appears in Studio’s runs list as agent support, started 1 Oct 2026 (the list is ordered by start time):
curl -sS -X POST http://127.0.0.1:7331/v1/traces \ -H 'Content-Type: application/json' --data @otherlang/stock-spans.jsonTestStockSpansMakeADerivedRun posts the same file to a Studio and reads the row back. It reads id otel-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7, derived: true, agent support, service py-support, provider openai, model gpt-5. It has session conv_7f3a, status succeeded, 2 steps, 1,717 input and 78 output tokens, and a known cost priced from the shipped table’s gpt-5 row like any run. Its page has one hole, derived, reason derived from spans · no events, and its transcript is empty with that badge.
Derived runs
Section titled “Derived runs”A derived run is listed and searched with your weft runs. What Studio shows for it:


| Surface | A derived run |
|---|---|
| runs list, search, live | a row badged derived, searchable by agent, model and error text |
| sessions | its turns grouped under gen_ai.conversation.id, the conversation as the session; a session every turn of which is derived is marked “derived (stock OTel)” (derived: true) and numbers its turns 1..n by start order |
| run page | the span waterfall; a story of per-step cards, one per chat span, each with its USER, ASSISTANT and tool-call rows read from the span’s gen_ai.input.messages, gen_ai.output.messages and gen_ai.system_instructions when the producer captured content |
a step (/api/runs/{id}/steps/{n}) | the chat span’s times and usage, priced like any step (unknown, never a known $0, when the span has no gen_ai.usage.*). Its execute_tool spans become calls, with args and result from gen_ai.tool.call.arguments and gen_ai.tool.call.result when the producer captured them (else args null and no result), and call_id "" for a span without gen_ai.tool.call.id |
| logs | the app log records under its spans; a GenAI log event (gen_ai.<role>.message, gen_ai.choice) is drawn as that message, and the story lists such messages below the step cards as “messages the app logged” |
| export | json, jsonl and otlp: the row and the spans, every other block badged |
Not derivable, and shown as missing with the derived badge rather than as empty: events (event_count 0, no event stream), the transcript, the request and catalog, the turn, public id, stop reason and pending calls. A derived row’s message_count counts its chat spans that carry message content. The run header says the badge’s reason and fix once, for a Python or TypeScript developer: turn content capture on (OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true), set gen_ai.conversation.id for a session, and “weft’s own records need a weft SDK (Go today)” (the record contract gives events, the transcript and requests). Every block read off the spans then carries the chip “derived · from span attributes” alone.
What a derived run cannot do, because there is no transcript to replay:
- The playground’s run, preview and fixtures routes refuse a derived source run with 400 and the badge, after authentication and before any check of the command’s content, so no command reaches a runtime. Studio and the devtools panel hide replay, save as test, open in app and compare on a derived run, and say why once: “they need weft’s records”.
export?format=wefttestis 400 with the badge.diffagainst a derived side marks every columnunknown; only unequal step counts show.- A panel token never reads a derived run: it has no public id. A read-scoped panel token is served stock spans without their system prompt (
gen_ai.system_instructions, system-role messages,gen_ai.prompt).
A trace that makes no run says why. GET /api/traces and /api/traces/{id} name a trace’s derived runs in run_ids. /api/traces/{id} answers not_run {reason, fix} when the trace makes none: “model or tool calls only: no invoke_agent span opens a run” (a model-call instrumentation under an HTTP handler), or “its agent span has not arrived”. /api/traces?not_run=1 lists the GenAI traces that make no run, and the runs page says how many arrived over the last 7 days, linking that list.
How Studio derives a run
Section titled “How Studio derives a run”The derivation is one function in obsdb, obsdb.DeriveStockRuns, used by both backends (ExampleDeriveStockRuns). Its rules, summarised from [§9 of the record contract], which is the reference(https://github.com/weftgo/weft/blob/v0.20.2/docs/record-contract.md#9-deriving-a-run-from-stock-spans):
- A root is one run. A root is a span whose operation is
invoke_agentand that has noweft.run.id. It must also either carrygen_ai.conversation.id, the run’s session, or have no otherinvoke_agentspan stored above it in its trace: a top-level agent, a run with no session. Aninvoke_agentspan without a conversation id nested under another agent span is not a root; itschatandexecute_toolspans count toward the enclosing root’s run. Whether an agent is top-level is read from the stored spans. When an enclosing agent arrives in a later export, the trace is derived again: the inner run’s row is deleted (its spans stay, now the enclosing run’s) and announced on the live lane as a removed row, so an open list drops it. A trace whose GenAI spans include noinvoke_agentspan makes no run. - The operation comes from the attribute, else the name.
gen_ai.operation.namedecides; an empty value counts as unset. Without it, a name startinginvoke_agentorexecute_tool, orchatalone or followed by a space, decides. Achatbotspan is not a model call. - The subtree stops at nested roots and at weft spans. A root inside another root’s subtree is its own run, a child linked by the
gen_ai.tool.call.idof the nearestexecute_toolabove it. A span withweft.run.idis never derived, so weft’s own runs never get a derived twin; a stock agent called from a weft tool is a top-level run in its own conversation, and deleting the weft run deletes it too. - Runs converge across exports. A span counts only through a complete chain of stored parents, and a trace is derived again from all its spans whenever an export brings a GenAI span. A batch processor that exports children before their root still ends with the whole run.
- Fields come from the root, then the
chatspans. The id isotel-<trace id>-<root span id>, the same on every retry. Agent fromgen_ai.agent.name, provider and model from the root or the firstchatspan, service from the resource’sservice.name. Status isfailedwith the root’s status description when the root’s status isError, elsesucceeded; a failed root with no description reads “the root span’s status is Error (no description)”. - Usage is the run’s own. The root’s
gen_ai.usage.*, when present, taken as given; else the sum over the subtree’schatspans, nested roots excluded. No correction either way: a producer whose root totals include its children’s usage counts them twice. Steps are thechatspans in start order; tools theexecute_toolspans, each on the latest step that started before it.
Attribute values may be integers, doubles or decimal strings: a reader takes "812" as 812. The run’s spans, read back, carry weft.step.index and weft.tool.seq stamped by the reader and gen_ai.operation.name as the derivation resolved it.
Complete example
Section titled “Complete example”The test that checks this page, in otherlang/otherlang_test.go, starts a Studio on a loopback port over a fresh database, posts stock-spans.json to /v1/traces and reads /api/runs, the run document and its transcript back. It also strips the conversation id and finds a derived run with no session, and checks that a Studio built with studio.IngestToken answers 401 to an export without the bearer.
go test ./otherlangBest practices & gotchas
Section titled “Best practices & gotchas”- Set
gen_ai.conversation.idon the agent span to group runs into a session. Without it a top-level agent is still a run, with no session; a nested agent without it folds into its parent. (Source: record contract §9;TestNoConversationIDIsARunWithNoSession) - Capture content to read a derived run’s story. Without
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=truethe steps have no messages and the calls no arguments or results. (Source: CHANGELOG.md:41) - Report usage on the
chatspans. A run whose spans carry nogen_ai.usage.*key reads zero tokens and an unknown cost, never a known $0. (Source: record contract §9, usage) - Give the root its own usage, not a total. A root’s usage is taken as given; totals that include nested agents count them twice in the parent’s cost. (Source: record contract §9, “Usage and cost of derived children”)
- Use an ingest token beyond loopback. Without one, Studio’s ingest answers peers on the same machine only. (Source:
studio.IngestTokengodoc;studio/studio.go:346-379) - Do not start a
weft.RunIDwithotel-. Derived ids use that prefix. This is a convention of the record contract; nothing in the core enforces it. (Source: record contract §9,id;core/run.go:232)
See also
Section titled “See also”- Use your own OpenTelemetry SDK: the GenAI attributes weft writes
- Run Studio: embedded, local binary or hosted
- Read a run in Studio
- The record contract: emit weft’s records from any language for a full run
Symbols used: studio.IngestToken · obsdb.DeriveStockRuns · ExampleDeriveStockRuns