Skip to main content
In Python, with langchain-core only: context_runnable() places the context in the prompt’s messages, NiadraCallbackHandler records the turns and history_tools() hands over the kit as StructuredTools. In JavaScript, @niadra/sdk/langchain brings niadraContext(), withNiadraContext() for LangGraph.js nodes, NiadraCallbackHandler and niadraTools().

Install

The TypeScript integration ships with @niadra/sdk 0.3.0, ready on main and on npm when it is published; until then the npm package is 0.1.1.

The five primitives

Minimal example

The same code is in examples/langchain_chain.py and examples/langgraph.ts. For LangGraph agents in Python, see LangGraph.

Agent memory

In Python, history_tools(conversation, agent_memory=...) adds the agent memory tools, and agent_memory=True (or {"write": True, "max_tokens": 300, "tags": [...]}) on the runnable puts the agent’s own notes right before the customer’s context, in the same system message. See Agent memory.

Limits

  • No BaseChatMessageHistory or BaseStore of its own: Niadra is not the state store of the chain or the graph, and the checkpointer never stores a pack.
  • Nothing here fails the chain: with Niadra slow or down, the messages go to the model as they came.
  • Tested against langchain-core 1.6 and @langchain/core 1.2 with a fake chat model and Niadra on the emulator.

Next steps

LangGraph

the middleware for create_agent in Python.

History navigation

the three tools the agent receives.