{"_id":"@atomicmemory/openai-agents","_rev":"3-18f1210e7b5a15545348c0a03f95fcd6","name":"@atomicmemory/openai-agents","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@atomicmemory/openai-agents","version":"0.1.0","license":"Apache-2.0","_id":"@atomicmemory/openai-agents@0.1.0","maintainers":[{"name":"atomicstrata","email":"services@atomicstrata.ai"}],"homepage":"https://github.com/atomicstrata/atomicmemory-integrations#readme","bugs":{"url":"https://github.com/atomicstrata/atomicmemory-integrations/issues"},"dist":{"shasum":"fbfcea8216167ddaf70e13869584280b1c81e0d0","tarball":"https://registry.npmjs.org/@atomicmemory/openai-agents/-/openai-agents-0.1.0.tgz","fileCount":46,"integrity":"sha512-fT41pXCsVjYiooEGjfBJkUgdIQPSHu5sswKV2uAWkUFkQ7ip2POUd5gTn5VSR5geFZkZuzQ1YR3It4ymLmFZEQ==","signatures":[{"sig":"MEYCIQDoEK1PRWnNq3lX3DspKycI9yD7k0e+O3uzPBKwEGTv2wIhAMJ+hWBQY6Hn+N/x0Tiy8XHVbOxcAga+zDJs96XkMfJ1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49958},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"f5545bd93a195c3053f2cad66d403837e1e4d13e","scripts":{"lint":"tsc -p tsconfig.json --noEmit","test":"node --test --import tsx 'src/**/*.test.ts'","build":"tsc -p tsconfig.json","prepack":"pnpm build","typecheck":"tsc -p tsconfig.json --noEmit","smoke:backend":"pnpm build && node scripts/smoke-backend.mjs","prepublishOnly":"node -e \"const v=require('./package.json').dependencies['@atomicmemory/sdk'];if(v.startsWith('file:')||v.startsWith('link:')){console.error('refusing to publish: @atomicmemory/sdk is '+v+'. Publish the SDK first, then pin to a registry version here.');process.exit(1)}\""},"_npmUser":{"name":"atomicstrata","email":"services@atomicstrata.ai"},"repository":{"url":"git+https://github.com/atomicstrata/atomicmemory-integrations.git","type":"git","directory":"adapters/openai-agents-sdk"},"_npmVersion":"11.14.1","description":"AtomicMemory adapter for the OpenAI Agents SDK — pre-run memory retrieval, post-run ingest, and function tools.","directories":{},"_nodeVersion":"25.9.0","dependencies":{"zod":"^4.3.6","@openai/agents":"^0.8.5","@atomicmemory/sdk":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.0","typescript":"^5.6.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/openai-agents_0.1.0_1778774927370_0.3117380367536158","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@atomicmemory/openai-agents","version":"0.1.1","license":"Apache-2.0","_id":"@atomicmemory/openai-agents@0.1.1","maintainers":[{"name":"atomicstrata","email":"services@atomicstrata.ai"}],"homepage":"https://github.com/atomicstrata/atomicmemory/tree/main/adapters/openai-agents#readme","bugs":{"url":"https://github.com/atomicstrata/atomicmemory/issues"},"dist":{"shasum":"b59b7eca0c6021031d4f7298d181f424d623ccc5","tarball":"https://registry.npmjs.org/@atomicmemory/openai-agents/-/openai-agents-0.1.1.tgz","fileCount":46,"integrity":"sha512-2HoyxMJnZ309uy3iRhnzAfKVzcIzu/W38QnLUVi2ha0K0Gj+xmXblBPR6/ZjHae0sy5tbYrNg5rBEtndH1ntBw==","signatures":[{"sig":"MEUCIQDFrXRGwS2yzGYv2BdjFw+P3aeUkRy83WayrGoZwEj31wIgUCpwxLJbyF4VFDqhm5kn96mOpSDLnkI1n6yxzriujPM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50128},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"201677d74fbb3f3cfd5e0dbb5f6904e889dcbb07","scripts":{"lint":"tsc -p tsconfig.json --noEmit","test":"node --test --import tsx 'src/**/*.test.ts'","build":"tsc -p tsconfig.json","prepack":"pnpm build","typecheck":"tsc -p tsconfig.json --noEmit","smoke:backend":"pnpm build && node scripts/smoke-backend.mjs","prepublishOnly":"node -e \"const v=require('./package.json').dependencies['@atomicmemory/sdk'];if(v.startsWith('file:')||v.startsWith('link:')){console.error('refusing to publish: @atomicmemory/sdk is '+v+'. Publish the SDK first, then pin to a registry version here.');process.exit(1)}\""},"_npmUser":{"name":"atomicstrata","email":"services@atomicstrata.ai"},"repository":{"url":"git+https://github.com/atomicstrata/atomicmemory.git","type":"git","directory":"adapters/openai-agents"},"_npmVersion":"11.14.1","description":"AtomicMemory adapter for the OpenAI Agents SDK — pre-run memory retrieval, post-run ingest, and function tools.","directories":{},"_nodeVersion":"25.9.0","dependencies":{"zod":"^4.3.6","@openai/agents":"^0.8.5","@atomicmemory/sdk":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.0","typescript":"^5.6.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/openai-agents_0.1.1_1779188789787_0.15692977547396092","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@atomicmemory/openai-agents","version":"0.1.2","description":"AtomicMemory adapter for the OpenAI Agents SDK — pre-run memory retrieval, post-run ingest, and function tools.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"repository":{"type":"git","url":"git+https://github.com/atomicstrata/atomicmemory.git","directory":"adapters/openai-agents"},"license":"Apache-2.0","engines":{"node":">=20"},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit","test":"node --test --import tsx 'src/**/*.test.ts'","lint":"tsc -p tsconfig.json --noEmit","smoke:backend":"pnpm build && node scripts/smoke-backend.mjs","prepack":"pnpm build","prepublishOnly":"node -e \"const v=require('./package.json').dependencies['@atomicmemory/sdk'];if(v.startsWith('file:')||v.startsWith('link:')){console.error('refusing to publish: @atomicmemory/sdk is '+v+'. Publish the SDK first, then pin to a registry version here.');process.exit(1)}\""},"dependencies":{"@atomicmemory/sdk":"^1.0.2","@openai/agents":"^0.8.5","zod":"^4.3.6"},"devDependencies":{"@types/node":"^20.0.0","tsx":"^4.19.0","typescript":"^5.6.0"},"bugs":{"url":"https://github.com/atomicstrata/atomicmemory/issues"},"homepage":"https://github.com/atomicstrata/atomicmemory/tree/main/adapters/openai-agents#readme","gitHead":"65c9fe5b18faaa87b4b5768e7d04309672aeed4f","_id":"@atomicmemory/openai-agents@0.1.2","_nodeVersion":"25.9.0","_npmVersion":"11.14.1","dist":{"integrity":"sha512-dZ2DRrfQjr5jCvlh8uEjONe5b4FYgI74oUioD8XlSyaZ5nlGE1TFP1Cze76Es8AxX/k3JjXIXsG8Za/BIFUjgg==","shasum":"e1c9f7a3a03a6a122f3128ca4d874fc2939dd208","tarball":"https://registry.npmjs.org/@atomicmemory/openai-agents/-/openai-agents-0.1.2.tgz","fileCount":46,"unpackedSize":50129,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDVji/6clinRg8f0iVYIUL39ntYyRCIC7A45SzaB4aCLAIgUDY+G2H+lykWZUfUSow28nGQC4FCGcoavkSfhnZG6/I="}]},"_npmUser":{"name":"atomicstrata","email":"services@atomicstrata.ai"},"directories":{},"maintainers":[{"name":"atomicstrata","email":"services@atomicstrata.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/openai-agents_0.1.2_1779342395359_0.00780337161687128"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T16:08:47.308Z","modified":"2026-05-21T05:46:35.622Z","0.1.0":"2026-05-14T16:08:47.518Z","0.1.1":"2026-05-19T11:06:29.914Z","0.1.2":"2026-05-21T05:46:35.512Z"},"bugs":{"url":"https://github.com/atomicstrata/atomicmemory/issues"},"license":"Apache-2.0","homepage":"https://github.com/atomicstrata/atomicmemory/tree/main/adapters/openai-agents#readme","repository":{"type":"git","url":"git+https://github.com/atomicstrata/atomicmemory.git","directory":"adapters/openai-agents"},"description":"AtomicMemory adapter for the OpenAI Agents SDK — pre-run memory retrieval, post-run ingest, and function tools.","maintainers":[{"name":"atomicstrata","email":"services@atomicstrata.ai"}],"readme":"# AtomicMemory for OpenAI Agents SDK\n\nAdapter for the [OpenAI Agents SDK for TypeScript](https://openai.github.io/openai-agents-js/). It wires AtomicMemory into agent runs without replacing the SDK's own `Session` implementations.\n\n## Install\n\nThis package is intended to publish as `@atomicmemory/openai-agents`. Until\n`@atomicmemory/sdk` is published and pinned to a registry version, build it\nfrom the monorepo:\n\n```bash\npnpm --filter @atomicmemory/openai-agents build\n```\n\nIn a local workspace, import from the package once it is linked by `pnpm-workspace.yaml`:\n\n```ts\nimport { MemoryClient } from '@atomicmemory/sdk';\nimport { Agent, run } from '@openai/agents';\nimport { runWithMemory } from '@atomicmemory/openai-agents';\n\nconst memory = new MemoryClient({\n  providers: {\n    atomicmemory: {\n      apiUrl: process.env.ATOMICMEMORY_API_URL!,\n      apiKey: process.env.ATOMICMEMORY_API_KEY,\n    },\n  },\n  defaultProvider: 'atomicmemory',\n});\nawait memory.initialize();\n\nconst agent = new Agent({\n  name: 'Assistant',\n  instructions: 'You are a helpful assistant.',\n});\n\nconst { result, retrieved } = await runWithMemory({\n  client: memory,\n  scope: { user: 'user-123', namespace: 'support' },\n  input: 'What did we decide about billing retries?',\n  run: (input) => run(agent, input),\n});\n\nconsole.log(result.finalOutput, retrieved.length);\n```\n\n## Primitives\n\n### `augmentInputWithMemory(client, options)`\n\nSearches AtomicMemory before an agent run and prepends a `system()` message containing retrieved context when matches exist.\n\n```ts\nconst { input, retrieved } = await augmentInputWithMemory(memory, {\n  scope: { user: 'user-123' },\n  input: 'What should I remember?',\n});\n\nconst result = await run(agent, input);\n```\n\n### `ingestAgentTurn(client, options)`\n\nPersists completed turns after `run()`. System messages are excluded by default; the assistant output is appended as the final assistant message.\n\n```ts\nawait ingestAgentTurn(memory, {\n  scope: { user: 'user-123' },\n  input,\n  result,\n  metadata: { source: 'openai-agents', event: 'run_completed' },\n});\n```\n\nFor streamed results, wait for `completed` and pass explicit output text if needed:\n\n```ts\nconst stream = await run(agent, input, { stream: true });\nawait stream.completed;\n\nawait ingestAgentTurn(memory, {\n  scope,\n  input,\n  output: String(stream.finalOutput ?? ''),\n});\n```\n\n### `createMemoryTools(client, options)`\n\nCreates two OpenAI Agents SDK function tools:\n\n- `memory_search` - search AtomicMemory during a run.\n- `memory_ingest` - store durable preferences, decisions, conventions, or facts.\n\n```ts\nconst agent = new Agent({\n  name: 'Assistant',\n  instructions: 'Use memory tools when prior context or durable learning matters.',\n  tools: createMemoryTools(memory, {\n    scope: { user: 'user-123', namespace: 'support' },\n    metadata: { source: 'openai-agents-tool' },\n  }),\n});\n```\n\n## Verify\n\nRun local adapter checks:\n\n```bash\npnpm --filter @atomicmemory/openai-agents test\npnpm --filter @atomicmemory/openai-agents typecheck\npnpm --filter @atomicmemory/openai-agents build\n```\n\nRun the backend smoke test without making an OpenAI API call:\n\n```bash\nexport ATOMICMEMORY_API_URL=\"http://localhost:17350\"\nexport ATOMICMEMORY_API_KEY=\"...\"\nexport ATOMICMEMORY_PROVIDER=\"atomicmemory\"\nexport ATOMICMEMORY_SCOPE_USER=\"$USER\"\nexport ATOMICMEMORY_SCOPE_NAMESPACE=\"openai-agents-sdk-smoke\"\n\npnpm --filter @atomicmemory/openai-agents smoke:backend\n```\n\nThe smoke test writes a unique marker, verifies `augmentInputWithMemory()` retrieves it, then runs `runWithMemory()` with a fake runner and reports the post-run ingest AUDN-SC outcome.\n\nSet `OPENAI_API_KEY` only when you want to test the real `Agent + run()` path from the install example.\n\n## Notes\n\n- AtomicMemory is long-term semantic memory. The OpenAI Agents SDK `Session` surface is still useful for short-term conversation state.\n- Retrieved memories are injected as reference context only. The adapter's default prompt explicitly tells the model not to follow instructions embedded in retrieved memories.\n- `ingestAgentTurn` requires text output. For structured outputs, it serializes `finalOutput` as JSON unless you pass an explicit `output`.\n\n## License\n\nApache-2.0.\n","readmeFilename":"README.md"}