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.
This guide covers Motia 1.0 TypeScript steps (motia on npm) running on the iii engine. Motia’s own traces describe step and function execution and carry no model data, so the setup below captures the model calls your steps make.

Manual setup: Agnost AI SDK

Initialize once in a shared module, for example src/lib/agnost.ts:
Then wrap the model call in your step handler:
Use any model client inside the try block. The SDK only needs the input and the output. Call await agnost.shutdown() once when the process exits, not inside a step.

Manual setup: OpenTelemetry

Motia’s runtime (iii-sdk) registers the global OpenTelemetry tracer provider in every step process and sends those spans to the iii engine. The engine exports over OTLP gRPC only, and its spans have no GenAI attributes, so Agnost AI would not ingest them. Instead, give the Vercel AI SDK a tracer from a provider of your own that exports to Agnost AI. Model calls, tool calls, prompts, and answers then arrive as GenAI spans.

Install

Installing @opentelemetry/api@^1.10.0 explicitly avoids an npm peer conflict between the current OTLP exporter and the older OpenTelemetry packages that motia depends on.

Setup

1. Add src/lib/agnost-otel.ts
2. Import it in the step and turn telemetry on
Set AGNOST_ORG_ID in the environment that starts the engine (iii -c iii-config.yaml), so the step process inherits it.

What appears in Agnost AI

  • Conversations grouped by sessionId.
  • User-level analytics grouped by userId.
  • Events: one motia-chat agent event per generateText call, with agent_step and chat children for each model request and a tool event (here getWeather) for each tool call, with its arguments and result.

Verify

Call the endpoint once, for example curl -X POST localhost:3111/chat -H 'content-type: application/json' -d '{"message":"What is the weather in Paris?","userId":"u-42","sessionId":"conv-abc123"}', then open Events in Agnost AI. Confirm a motia-chat event with the message as input and the reply as output, a getWeather tool event, and the session and user on the conversation.

Troubleshooting

  • No events: confirm the step imports ./lib/agnost-otel and that AGNOST_ORG_ID is set in the engine’s environment. Spans are batched and sent within about five seconds.
  • A process has one global tracer provider, and Motia’s runtime registers it. Calling NodeSDK.start() or provider.register() in a step either fails or takes over Motia’s tracing, depending on load order. Pass the tracer to new OpenTelemetry({ tracer }) as shown instead.
  • The iii engine’s own OTLP exporter (OtelModule in iii-config.yaml) uses gRPC and sends function spans without model data. Do not point it at Agnost AI.
  • Python steps: wrap the model call with the Python SDK the same way as the TypeScript SDK example above.

References

Next steps

  • Conversations: review the complete Motia interaction.
  • Events: inspect model and tool calls made by your steps.
  • Patterns: organize production conversations by what users wanted.