Skip to content

ejentum/ejentum-langgraph

Repository files navigation

ejentum-langgraph

LangGraph.js and LangChain.js integration for the Ejentum Reasoning Harness. createEjentumTools() returns an array of eight DynamicStructuredTool instances you pass as the tools argument to createReactAgent, createAgent, ToolNode, or any LangChain graph node that accepts tools.

Use the harness before the agent generates on complex, multi-step, or multi-constraint tasks where the model's default reasoning template would miss a constraint, take a shortcut, or drift across turns. Each call returns a cognitive operation: a structured procedure (numbered steps with a failure pattern to refuse and a falsification test) paired with an executable reasoning topology (a DAG of those steps with decision gates, parallel branches, bounded loops, and meta-cognitive exit nodes). The agent reads both layers before producing its response.

Four dynamic tools (reasoning, code, anti-deception, memory) are available on all tiers including the 30-day free trial. Four adaptive tools (adaptive-reasoning, adaptive-code, adaptive-anti-deception, adaptive-memory) additionally run an adapter LLM that rewrites the matched operation with task-specific identifiers; they require the Go or Super tier.

Install

npm install ejentum-langgraph
# peer deps
npm install @langchain/core zod

Configuration

export EJENTUM_API_KEY="ej_..."

Or pass it explicitly: createEjentumTools({ apiKey: "..." }). Get a key at ejentum.com/pricing.

Usage

With createReactAgent (LangGraph.js)

import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { ChatAnthropic } from "@langchain/anthropic";
import { createEjentumTools } from "ejentum-langgraph";

const agent = createReactAgent({
  llm: new ChatAnthropic({ model: "claude-sonnet-4-6" }),
  tools: createEjentumTools(),
});

const result = await agent.invoke({
  messages: [{ role: "user", content: "Should we keep the GraphQL gateway or pivot to REST?" }],
});

With createAgent (LangChain v1.x)

import { createAgent } from "langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createEjentumTools } from "ejentum-langgraph";

const agent = createAgent({
  model: new ChatOpenAI({ model: "gpt-4o" }),
  tools: createEjentumTools(),
});

Inside a graph node

import { ToolNode } from "@langchain/langgraph/prebuilt";
import { createEjentumTools } from "ejentum-langgraph";

const toolNode = new ToolNode(createEjentumTools());

Pick a subset

import { createReasoningTool, createAntiDeceptionTool } from "ejentum-langgraph";

const tools = [createReasoningTool(), createAntiDeceptionTool()];

Tool inventory

The LLM-facing tool name is the name field on each tool (set by the factory; canonical hyphenated strings).

Factory Tool name (LLM-visible) Mode string Library size
createReasoningTool reasoning reasoning 311
createCodeTool code code 128
createAntiDeceptionTool anti-deception anti-deception 139
createMemoryTool memory memory 101
createAdaptiveReasoningTool adaptive-reasoning adaptive-reasoning (same pool)
createAdaptiveCodeTool adaptive-code adaptive-code (same pool)
createAdaptiveAntiDeceptionTool adaptive-anti-deception adaptive-anti-deception (same pool)
createAdaptiveMemoryTool adaptive-memory adaptive-memory (same pool)

Each tool takes one parameter, query: string, and returns the injection as plain text. Errors return as human-readable strings rather than thrown exceptions.

API reference

import { createEjentumTools, type EjentumConfig, type HarnessMode } from "ejentum-langgraph";

createEjentumTools(config?: EjentumConfig): DynamicStructuredTool[]
EjentumConfig field Default Description
apiKey process.env.EJENTUM_API_KEY API key.
apiUrl https://api.ejentum.com/harness/ Override for self-hosted gateway.
timeoutMs 10000 Per-call HTTP timeout.

Wire contract

createEjentumTools() issues:

POST https://api.ejentum.com/harness/
Headers: Authorization: Bearer <key>, Content-Type: application/json
Body:    { "query": <string>, "mode": <one of 8 mode strings> }
Response (200): [ { "<mode>": "<injection string>" } ]

Full wire contract, field structure, DAG syntax, and a canonical dynamic-vs-adaptive comparison on the same query are documented in the ejentum-mcp README. The format is identical across this package and every Ejentum shim.

ejentum-mcp alternative

LangGraph supports MCP via @langchain/mcp-adapters:

import { MultiServerMCPClient } from "@langchain/mcp-adapters";

const client = new MultiServerMCPClient({
  mcpServers: {
    ejentum: {
      url: "https://api.ejentum.com/mcp",
      headers: { Authorization: `Bearer ${process.env.EJENTUM_API_KEY}` },
      transport: "streamable_http",
    },
  },
});
const tools = await client.getTools();

Compatibility

  • Node.js 18+
  • @langchain/core 0.3+ (peer dep >=0.3.0)
  • Works with @langchain/langgraph 0.x and 1.x, and langchain 1.x
  • zod 3.x (peer dep ^3.23.0)
  • TypeScript 5.x

License

MIT

Measured effects

The Ejentum harness is benchmarked publicly under CC BY 4.0 at github.com/ejentum/benchmarks:

  • ELEPHANT sycophancy: 5.8% composite on GPT-4o (40 real Reddit scenarios)
  • LiveCodeBench Hard: 85.7% to 100% on Claude Opus (28 competitive programming tasks)
  • Memory retention: 50% fewer stale facts served (20-turn implicit state changes)
  • Plus per-harness numbers across BBH/CausalBench/MuSR, ARC-AGI-3, SciCode, and perception tasks

Methodology, scenarios, run scripts, and raw outputs are all in-repo.

About

LangGraph.js / LangChain.js integration for the Ejentum Reasoning Harness. createEjentumTools() returns 8 agent-callable tools (4 harnesses × dynamic + adaptive).

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors