Setup guides · TypeScript
OpenAI Agents SDK
One call at startup records model calls, tool calls and handoffs from every Runner. Optional hooks on the Runner make tool-call IDs exact. Tool code locations aren't available, and a cancelled run reads as cancelled only when its signal is given to the scope around it.
Your coding agent can do the attaching. Ask it:
It finds the places to hook in and asks you the few things only you know. The steps below are what it does.
Start nomi
nomi is one program, nomi.
Download it from the releases page, then:
nomi init
nomi configure -mode sdk -source my-agent -receiver-listen 127.0.0.1:4320
nomi start # leave this running
nomi browser -home "$HOME/.nomi" # opens the run view Everything it records lives in ~/.nomi; -home on any command chooses another folder. nomi doctor says whether it's healthy.
Install the TypeScript SDK (runnomi-sdk 1.0.0) into your agent from the release's packed file. It isn't on npm, so keep the whole address. Then tell it where nomi is:
cd /path/to/your/agent
npm install https://github.com/joshbodunrin/nomi/releases/download/v1.0.0/runnomi-sdk-1.0.0.tgz
export MYAGENT_NOMI_ENABLED=1
export MYAGENT_NOMI_ENDPOINT=http://127.0.0.1:4320
export MYAGENT_NOMI_TOKEN_FILE="$HOME/.nomi/write-token" npm records that address in package.json and the lockfile, so another machine or CI installs the same file. This was checked with npm 10.9.2 from a packed file on disk, from ES module and CommonJS applications; pnpm, yarn and bun weren't.
The SDK has no runtime dependencies and works from ES modules and CommonJS. The settings are read by Observer.fromEnv with prefix: "MYAGENT_NOMI"; the SDK reads the token file itself, so the token is never on a command line. Events are held in memory and sent in the background: what can't be delivered is counted and reported as lost. To keep events on disk through an outage or a restart, set MYAGENT_NOMI_SPOOL_DIR and MYAGENT_NOMI_SOURCE.
These are the same-machine settings. Your agent can also run in a container or on another machine of yours and send to the same nomi: where nomi runs has what changes, and the attach skill can set it up.
nomi never changes how your agent runs: if it’s off, down or hanging, your agent carries on with the same output.
Check your versions
import { openaiAgentsSupport } from "runnomi-sdk/integrations/openai-agents";
console.log(openaiAgentsSupport());
The range is @openai/agents 0.20 up to (not including) 0.23, with openai 7.2 up to 8, on Node 22 or later; pre-releases aren’t accepted. The check reads package.json files only.
Outside the range, instrument registers nothing, returns null and logs one nomi: OpenAI Agents adapter off line; your agent runs as usual, and scopes and declarations are still recorded. instrument(observer, agents, { strict: true }) throws instead. Don’t downgrade your app’s packages to fit.
Attach
The default OpenAI exporter and any trace processors your app registered keep running.
-
Once, where the observer is created. Pass your app’s own
@openai/agentsmodule: the adapter never imports the framework.import * as agents from "@openai/agents"; import { Runner } from "@openai/agents"; import { Observer } from "runnomi-sdk"; import { instrument, runHooks } from "runnomi-sdk/integrations/openai-agents"; const observer = Observer.fromEnv("my-agent", { project: "my-repo", agent: "my-agent", prefix: "MYAGENT_NOMI" }); instrument(observer, agents);It calls the framework’s
addTraceProcessor. Call it after anysetTraceProcessors(...)of your own: that call replaces every processor, nomi’s included. -
Where your app creates its
Runner, pass it throughrunHooks. It returns the same runner:const runner = runHooks(observer, new Runner({ workflowName: "Support desk", groupId: conversation.id }));runHooksis optional. With it, each tool call has its exact call ID, and anobserver.tool(...)made inside a function tool nests under that tool’s step. Without it, an ID is matched from the model’s reply where it can be, and the step says which it was. An app that uses the top-levelrun(agent, input)has no Runner: userunHooks(observer, agent)on each agent. It adds two event listeners (agent_tool_start,agent_tool_end); your own listeners are untouched, and it replaces and wraps no method of the Runner or Agent. -
Wrap each unit of work. A
runner.runinside the scope joins its run; outside one, eachrunner.runis its own run with no group. Pass the run’sAbortSignalto the scope too: it is how a cancelled run is told from a failed one.const reply = await observer.observe("support_turn", { workflow: "support", group: conversation.id, step: "reply", signal }, async () => (await runner.run(agent, messages, { signal })).finalOutput, ); -
Before the process ends,
await observer.close().process.exit()skips the close an observer otherwise makes when the event loop empties.
Recorded automatically
- Model calls. On the Responses API: the returned model, response ID,
status, tokens (input, output, total, cached, reasoning) and the output cap as the provider echoed it. On Chat Completions: the requested model and tokens. Prompts and replies with content capture on. An input list over a size bound (a later turn passes the whole conversation back) is kept as its JSON text, start and end, and shown as cut, with the reason; the Python SDK does the same. - Tool calls: name, duration and error status; arguments and result with content capture on; the call ID, exact with
runHooks. - Structure: task, agent, turn, model, tool and handoff spans. An agent used as a tool (
agent.asTool) is a nested agent under that tool call, in the same run. - Runner-managed model retries (
modelSettings.retry): the failed call is a separate errored step in the same turn. - Streamed runs (
run(..., { stream: true })): the same facts, recorded when the stream has been read to its end. - The trace’s
workflowNameandgroupId, as metadata of the run. Inside a scope that declares its ownworkflow, the run lists both names (Support desk, supportfor the Runner and scope above); the group is the scope’s. - From the scope: the run’s outcome, the class and HTTP status of an error the run threw, its code location, and the commit that ran.
Declared by your code
Decisions (results and issues), effects, and logical actions (observer.tool(..., { actionId, attempt }, fn) around a side effect’s own attempts), expected exceptions and waits. No hook provides them. An observer.tool(...) made inside a function tool nests under that tool’s step when runHooks is used.
What it can’t see
- A tool function’s file and line: JavaScript doesn’t expose where a function was defined. The scope around the run has its own.
- A cancelled run, unless the scope around it is given your signal (as in Attach): the framework ends an aborted run with an error, so it is stored as a failed run.
- A failed model call’s error class and HTTP status: the framework’s span has the message only. The scope has both.
- Model, tokens, status and reply when the Runner has
traceIncludeSensitiveData: false. They show as missing, not zero. - On Chat Completions: the returned model, the stop reason, the requested output cap and the provider or its endpoint. On Responses: the cap you requested (only the provider’s echo).
- Retries inside the
openaiclient: one longer model call, which says they aren’t reported. - A tool’s exception message under the default error handler, which replaces it.
- Success: the framework’s steps are errored or unspecified, and unspecified is never read as success.
- Anything under
NODE_ENV=test: the framework turns its own tracing off (vitest sets it), so only your scopes are recorded.
Limits and edge cases
- Cancelling: give your signal to both,
await observer.observe("turn", { signal }, () => runner.run(agent, input, { signal }));. A run aborted through it is cancelled, the model or tool call in flight included, with no error steps. A signal that timed out (AbortSignal.timeout) stays a failure. - A streamed run aborted between model calls throws nothing: its steps are unspecified, and a scope around it ends as a success unless your code throws on the abort.
- A tool with its own
errorFunctionreturns what that function returns, and that is recorded as the result.
When nomi is down
Your agent’s output, exit code and requests to the provider are the same with nomi up, down, never answering, answering 500 or refusing the token. What isn’t delivered is counted and said once on stderr. With durable delivery on (NOMI_SPOOL_DIR), the SDK keeps its events on disk and sends them when nomi is back.
- The framework’s own
No API key provided for OpenAI tracing exporterline is printed with and without nomi. - A process killed mid-run leaves steps with a start and no end: the run is shown as not finished, never as succeeded. What was still queued in the process is lost.
Connect your coding agent
nomi includes a server with read-only tools for your coding agent, and a debug skill that teaches it to keep what was observed, what your code declared and what is unknown apart. Pick yours:
Claude Code
claude mcp add nomi -s user -- nomi mcp
mkdir -p ~/.claude/skills && cp -R skills/debug-agent-with-nomi ~/.claude/skills/ Codex
codex mcp add nomi -- nomi mcp
mkdir -p ~/.codex/skills && cp -R skills/debug-agent-with-nomi ~/.codex/skills/ Cursor, in ~/.cursor/mcp.json (or .cursor/mcp.json for one project)
{"mcpServers": {"nomi": {"type": "stdio", "command": "nomi", "args": ["mcp"]}}} Cursor's debug skill (the skill needs Cursor 2.4 or later)
mkdir -p ~/.cursor/skills && cp -R skills/debug-agent-with-nomi ~/.cursor/skills/ Cursor also reads skills from ~/.claude/skills/, so if the skills are already installed for Claude Code, nothing needs copying.
Then open a session in your agent's repository and ask, for example:
- “What went wrong in my agent's last few runs?”
- “Why did this run fail?”
- “What changed between these two runs?”