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
@niadra/sdk on npm.
The five primitives
Minimal example
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 theturns 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: aSessionstores the agent’s own items, and Niadra keeps derived memory, not a copy of each item. Use anySessionnext to it. In JavaScript,NiadraSessionwraps the session you choose. - Nothing here fails a run: Niadra slow or down leaves the instructions yours alone.
- In Python, the
openai-agentsextra pins versions incompatible withlivekit,crewaiandlitellm; install one per environment. - Tested against
openai-agents0.22.3 and@openai/agents0.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.
