{"_id":"@edgeone/openinference-instrumentation-openai-agents","_rev":"4-f0159fd79bded106dd01ad70deac725d","name":"@edgeone/openinference-instrumentation-openai-agents","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@edgeone/openinference-instrumentation-openai-agents","version":"0.1.0","keywords":["ai","agents","instrumentation","llm","openai","openinference","opentelemetry","tracing"],"author":{"name":"oss-devs@arize.com"},"license":"Apache-2.0","_id":"@edgeone/openinference-instrumentation-openai-agents@0.1.0","maintainers":[{"name":"xiaban","email":"980892894@qq.com"},{"name":"tomcomtang","email":"364786053@qq.com"},{"name":"corbinlin","email":"corbinlin@tencent.com"},{"name":"shirlyyang","email":"shirlyyang@tencent.com"},{"name":"sagacheng","email":"sagacheng@tencent.com"},{"name":"venzil","email":"q153877011@gmail.com"},{"name":"shiyangchen","email":"shiyangchen@tencent.com"},{"name":"tencent-player","email":"vincentlli@tencent.com"},{"name":"zhaodanzhao","email":"zhaodanzhao@tencent.com"},{"name":"xindeli","email":"xindeli@tencent.com"},{"name":"simxin","email":"simxin@tencent.com"}],"homepage":"https://github.com/Arize-ai/openinference#readme","bugs":{"url":"https://github.com/Arize-ai/openinference/issues"},"dist":{"shasum":"c088aab7fd3844d2faee245585b2aaef2552d34a","tarball":"https://registry.npmjs.org/@edgeone/openinference-instrumentation-openai-agents/-/openinference-instrumentation-openai-agents-0.1.0.tgz","fileCount":41,"integrity":"sha512-5cBgl/l7Uu7VcFVfKLgvdG54xw3OvbV9WOTarXN/BtEt5jDp0IB6WoBU/c82BRubzY0Hp8uSdvBjTeXn5fd/tA==","signatures":[{"sig":"MEUCIFa++dyQ8oPist01wOi7FdcgREQuRgHHOnVu8srC6AU+AiEA7Z+Yp3Cp2tumwMkb0RopzU3o+S0kXfVnGvPbgRe+UkA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":479914},"main":"dist/src/index.js","types":"dist/src/index.d.ts","module":"dist/esm/index.js","exports":{".":{"import":"./dist/esm/index.js","require":"./dist/src/index.js"}},"gitHead":"c591577ca2deaa270c0705c325db4a3dca3cdcd0","private":false,"scripts":{"test":"vitest run","build":"tsc --build tsconfig.json tsconfig.esm.json && tsc-alias -p tsconfig.esm.json","prebuild":"rimraf dist && pnpm run version:update","postbuild":"echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test","type:check":"tsc --noEmit","version:update":"../../scripts/version-update.js"},"_npmUser":{"name":"xindeli","email":"xindeli@tencent.com"},"repository":{"url":"git+https://github.com/Arize-ai/openinference.git","type":"git"},"_npmVersion":"11.6.2","description":"OpenInference instrumentation for OpenAI Agents SDK","directories":{},"_nodeVersion":"24.12.0","dependencies":{"@opentelemetry/api":"^1.9.0","@arizeai/openinference-core":"workspace:*","@opentelemetry/instrumentation":"^0.46.0","@arizeai/openinference-semantic-conventions":"workspace:*"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.0.0","openai":"^4.0.0","vitest":"^4.0.3","typescript":"^5.8.3","@openai/agents":"^0.11.4","@opentelemetry/sdk-trace-base":"^1.25.1","@opentelemetry/sdk-trace-node":"^1.25.1"},"peerDependencies":{"@openai/agents":">=0.0.3"},"_npmOperationalInternal":{"tmp":"tmp/openinference-instrumentation-openai-agents_0.1.0_1779419043640_0.16298746917306772","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@edgeone/openinference-instrumentation-openai-agents","version":"0.1.1","keywords":["ai","agents","instrumentation","llm","openai","openinference","opentelemetry","tracing"],"author":{"name":"oss-devs@arize.com"},"license":"Apache-2.0","_id":"@edgeone/openinference-instrumentation-openai-agents@0.1.1","maintainers":[{"name":"xiaban","email":"980892894@qq.com"},{"name":"tomcomtang","email":"364786053@qq.com"},{"name":"corbinlin","email":"corbinlin@tencent.com"},{"name":"shirlyyang","email":"shirlyyang@tencent.com"},{"name":"sagacheng","email":"sagacheng@tencent.com"},{"name":"venzil","email":"q153877011@gmail.com"},{"name":"shiyangchen","email":"shiyangchen@tencent.com"},{"name":"tencent-player","email":"vincentlli@tencent.com"},{"name":"zhaodanzhao","email":"zhaodanzhao@tencent.com"},{"name":"xindeli","email":"xindeli@tencent.com"},{"name":"simxin","email":"simxin@tencent.com"}],"homepage":"https://github.com/Arize-ai/openinference#readme","bugs":{"url":"https://github.com/Arize-ai/openinference/issues"},"dist":{"shasum":"d704d8df533559094765d57bfa7e0733e3653afe","tarball":"https://registry.npmjs.org/@edgeone/openinference-instrumentation-openai-agents/-/openinference-instrumentation-openai-agents-0.1.1.tgz","fileCount":41,"integrity":"sha512-spmrQuL7bJeGq4eD5hY0Mf5f9pttieJhdHzEUGm+6J6nKjD/mFoBztPEAWyOtmk1INCNoJyphHuGsoK8oiQzlQ==","signatures":[{"sig":"MEUCIErZJofD9JR/O0DczkY6hGHk8XZsLYbjMzTNVrU4T70VAiEA5zrjt+ibccddD9zy2eoUEo0eSu0RRVzchxGPntPmzdg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":479905},"main":"dist/src/index.js","types":"dist/src/index.d.ts","module":"dist/esm/index.js","exports":{".":{"import":"./dist/esm/index.js","require":"./dist/src/index.js"}},"gitHead":"c591577ca2deaa270c0705c325db4a3dca3cdcd0","private":false,"scripts":{"test":"vitest run","build":"tsc --build tsconfig.json tsconfig.esm.json && tsc-alias -p tsconfig.esm.json","prebuild":"rimraf dist && pnpm run version:update","postbuild":"echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test","type:check":"tsc --noEmit","version:update":"../../scripts/version-update.js"},"_npmUser":{"name":"xindeli","email":"xindeli@tencent.com"},"repository":{"url":"git+https://github.com/Arize-ai/openinference.git","type":"git"},"_npmVersion":"11.6.2","description":"OpenInference instrumentation for OpenAI Agents SDK","directories":{},"_nodeVersion":"24.12.0","dependencies":{"@opentelemetry/api":"^1.9.0","@arizeai/openinference-core":"^2.1.0","@opentelemetry/instrumentation":"^0.46.0","@arizeai/openinference-semantic-conventions":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.0.0","openai":"^4.0.0","vitest":"^4.0.3","typescript":"^5.8.3","@openai/agents":"^0.11.4","@opentelemetry/sdk-trace-base":"^1.25.1","@opentelemetry/sdk-trace-node":"^1.25.1"},"peerDependencies":{"@openai/agents":">=0.0.3"},"_npmOperationalInternal":{"tmp":"tmp/openinference-instrumentation-openai-agents_0.1.1_1779435658442_0.5002746454408431","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-05-22T03:04:03.521Z","modified":"2026-09-15T06:26:57.921Z","0.1.0":"2026-05-22T03:04:03.774Z","0.1.1":"2026-05-22T07:40:58.577Z"},"bugs":{"url":"https://github.com/Arize-ai/openinference/issues"},"author":{"name":"oss-devs@arize.com"},"license":"Apache-2.0","homepage":"https://github.com/Arize-ai/openinference#readme","keywords":["ai","agents","instrumentation","llm","openai","openinference","opentelemetry","tracing"],"repository":{"url":"git+https://github.com/Arize-ai/openinference.git","type":"git"},"description":"OpenInference instrumentation for OpenAI Agents SDK","maintainers":[{"email":"980892894@qq.com","name":"xiaban"},{"email":"364786053@qq.com","name":"tomcomtang"},{"email":"corbinlin@tencent.com","name":"corbinlin"},{"email":"shirlyyang@tencent.com","name":"shirlyyang"},{"email":"sagacheng@tencent.com","name":"sagacheng"},{"email":"q153877011@gmail.com","name":"venzil"},{"email":"shiyangchen@tencent.com","name":"shiyangchen"},{"email":"vincentlli@tencent.com","name":"tencent-player"},{"email":"zhaodanzhao@tencent.com","name":"zhaodanzhao"},{"email":"xindeli@tencent.com","name":"xindeli"},{"email":"drogbaqb@gmail.com","name":"drogbaqu"},{"email":"946834832@qq.com","name":"xingchenhe"},{"email":"simxin@tencent.com","name":"simxin"}],"readme":"# OpenInference Instrumentation for OpenAI Agents SDK (Node.js)\n\nOpenTelemetry-based instrumentation for the [OpenAI Agents SDK](https://www.npmjs.com/package/@openai/agents) (`@openai/agents`). Bridges the SDK's native tracing events to OpenTelemetry spans following the [OpenInference semantic conventions](https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md), so agent runs can be observed in any OpenTelemetry-compatible backend such as [Arize Phoenix](https://github.com/Arize-ai/phoenix), Arize, Jaeger, or your collector of choice.\n\nThis is the JavaScript / TypeScript counterpart to the Python [`openinference-instrumentation-openai-agents`](../../python/instrumentation/openinference-instrumentation-openai-agents) package.\n\n## Installation\n\n```bash\nnpm install @arizeai/openinference-instrumentation-openai-agents @arizeai/openinference-semantic-conventions @openai/agents\n```\n\n## Quickstart\n\n```typescript\nimport { Agent, run } from \"@openai/agents\";\nimport { OTLPTraceExporter } from \"@opentelemetry/exporter-trace-otlp-proto\";\nimport { resourceFromAttributes } from \"@opentelemetry/resources\";\nimport { BatchSpanProcessor } from \"@opentelemetry/sdk-trace-base\";\nimport { NodeTracerProvider } from \"@opentelemetry/sdk-trace-node\";\nimport { ATTR_SERVICE_NAME } from \"@opentelemetry/semantic-conventions\";\n\nimport { OpenAIAgentsInstrumentation } from \"@arizeai/openinference-instrumentation-openai-agents\";\n\n// 1. Configure OpenTelemetry.\nconst provider = new NodeTracerProvider({\n  resource: resourceFromAttributes({\n    [ATTR_SERVICE_NAME]: \"my-agent-app\",\n  }),\n  spanProcessors: [\n    new BatchSpanProcessor(\n      new OTLPTraceExporter({ url: \"http://localhost:6006/v1/traces\" }),\n    ),\n  ],\n});\nprovider.register();\n\n// 2. Register the OpenInference processor with the agents SDK.\nconst instrumentation = new OpenAIAgentsInstrumentation({ tracerProvider: provider });\ninstrumentation.instrument();\n\n// 3. Use the agents SDK as usual.\nconst agent = new Agent({\n  name: \"Assistant\",\n  instructions: \"You are a helpful assistant.\",\n});\n\nconst result = await run(agent, \"What is the capital of France?\");\nconsole.log(result.finalOutput);\n```\n\n## How it works\n\nUnlike most OpenInference instrumentations, this package does **not** monkey-patch the SDK. The agents SDK exposes a first-class `TracingProcessor` interface; this package implements it and registers via the SDK's `setTraceProcessors` / `addTraceProcessor` APIs.\n\n| Mode | Call | Behaviour |\n| --- | --- | --- |\n| Exclusive (default) | `instrument()` | Replaces every existing trace processor with the OpenInference one. Use when OpenTelemetry is your sole tracing destination. |\n| Additive | `instrument({ exclusiveProcessor: false })` | Adds the OpenInference processor alongside any existing processors (e.g. the SDK's default OpenAI tracing exporter). Use when you want OpenInference *and* OpenAI native tracing. |\n\nTo stop tracing, call `instrumentation.uninstrument()`.\n\n## Configuration\n\n```typescript\nnew OpenAIAgentsInstrumentation({\n  // Optional: an OTel TracerProvider. Defaults to the global provider.\n  tracerProvider,\n\n  // Optional: OpenInference trace configuration for masking/redacting\n  // sensitive data on emitted spans.\n  // See https://github.com/Arize-ai/openinference/blob/main/js/packages/openinference-core\n  traceConfig: {\n    hideInputs: true,\n    hideOutputs: true,\n  },\n});\n```\n\n## Span coverage\n\nEach agents SDK span type is mapped to an OpenInference span kind:\n\n| SDK span | `openinference.span.kind` | Captured attributes |\n| --- | --- | --- |\n| `agent` | `AGENT` | `graph.node.id`, `graph.node.parent_id` (on handoff destination) |\n| `generation` | `LLM` | `llm.model_name`, `llm.invocation_parameters`, `llm.input_messages.*`, `llm.output_messages.*`, `llm.token_count.{prompt,completion,total}`, `llm.token_count.prompt_details.cache_read`, `llm.token_count.completion_details.reasoning` |\n| `response` | `LLM` | All of the above plus `llm.tools.*`, system instructions as input message 0 |\n| `function` | `TOOL` | `tool.name`, `input.value`, `output.value` |\n| `handoff` | `TOOL` | Span name `handoff to <to_agent>`; the destination agent receives `graph.node.parent_id` linking back to the source |\n| `mcp_tools` | `TOOL` | `output.value` (JSON list of tool names) |\n| `guardrail` | `GUARDRAIL` | `tool.name`, `guardrail.triggered` |\n| `custom` | `CHAIN` | `output.value` (JSON-serialised user data) |\n\nBoth the **chat_completions** and **responses** transports are supported. In chat_completions mode the SDK stores raw response objects in `output[]`; this instrumentation extracts messages from `choices[].message` and accumulates token usage across all responses.\n\n## Examples\n\n```bash\ncd js/packages/openinference-instrumentation-openai-agents\npnpm install\npnpm -r build\n\nOPENAI_API_KEY=sk-... npx tsx examples/chat.ts     # single agent + tool call\nOPENAI_API_KEY=sk-... npx tsx examples/handoff.ts  # multi-agent handoff\n```\n\nThe shared OTel setup lives in `examples/instrumentation.ts` — modify it to swap in an OTLP exporter or any other span processor.\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md"}