Skip to main content
In Python, NiadraAgentsMemory gives you run_config() (the filter that injects the context before each model call), hooks (which record the turns) and tools. In JavaScript, @niadra/sdk/openai-agents brings NiadraSession, niadraInstructions(), niadraTools() and niadraRunHooks().

Install

The TypeScript integration is in @niadra/sdk on npm.

The five primitives

Minimal example

The same code is in examples/openai_agents_run.py and examples/openai-agents.ts.

Agent memory

In Python, agent_memory=True (or {"write": True, "max_tokens": 300, "tags": [...]}) puts the agent’s own notes after the instructions and before the customer’s context, and search_agent_memory (and remember, with write) join tools. In JavaScript, agentMemory in the options. See Agent memory.

Turn records

With the turns feature on in the space (it ships on), the Python RunHooks with turns=True and the JavaScript hooks with turns: true record each run as a turn record, with each tool call by the provider’s id and each model call with its tokens; a handoff opens a sub-turn. The OpenAI Agents JS hooks cannot stop a tool, so wrap the tools with Niadra.tool() for a replay to answer them from the record; in Python, the FunctionTools answer from the record. A turn never waits for Niadra and never repeats the conversation’s text.

Limits

  • The Python adapter does not implement the SDK’s Session: a Session stores the agent’s own items, and Niadra keeps derived memory, not a copy of each item. Use any Session next to it. In JavaScript, NiadraSession wraps the session you choose.
  • Nothing here fails a run: Niadra slow or down leaves the instructions yours alone.
  • In Python, the openai-agents extra pins versions incompatible with livekit, crewai and litellm; install one per environment.
  • Tested against openai-agents 0.22.3 and @openai/agents 0.18.0 with the model replaced by a fake and Niadra on the emulator.

Next steps

History navigation

the three tools the agent receives.

OpenAI and Azure OpenAI

the client wrap(), for those not on the Agents SDK.