Metadata-Version: 2.4
Name: llama-index-tools-ejentum
Version: 0.2.0
Summary: LlamaIndex tool spec for the Ejentum Reasoning Harness. Wraps the hosted Ejentum MCP server and exposes eight cognitive harness tools as LlamaIndex FunctionTool objects: four dynamic (reasoning, code, anti-deception, memory) plus four adaptive variants (adaptive-reasoning, adaptive-code, adaptive-anti-deception, adaptive-memory) that pre-fit the cognitive operation to the caller's task via an adapter LLM.
Project-URL: Homepage, https://ejentum.com
Project-URL: Documentation, https://ejentum.com/docs/api_reference
Project-URL: Repository, https://github.com/ejentum/llama-index-tools-ejentum
Project-URL: Issues, https://github.com/ejentum/llama-index-tools-ejentum/issues
Project-URL: Changelog, https://github.com/ejentum/llama-index-tools-ejentum/blob/main/CHANGELOG.md
Project-URL: Pricing, https://ejentum.com/pricing
Author-email: Ejentum <info@ejentum.com>
License-Expression: MIT
License-File: LICENSE
Keywords: agentic-ai,ai,anti-deception,cognitive-scaffold,ejentum,llama-index,llama-index-tools,llamaindex,llm,mcp,model-context-protocol,reasoning-harness
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: <3.14,>=3.10
Requires-Dist: llama-index-core<0.15,>=0.13.0
Requires-Dist: llama-index-tools-mcp<0.5,>=0.4.1
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Description-Content-Type: text/markdown

# llama-index-tools-ejentum

[LlamaIndex](https://www.llamaindex.ai) tool spec that subclasses `McpToolSpec` and points at the hosted Ejentum MCP server. Exposes the eight cognitive-harness tools as LlamaIndex `FunctionTool` objects ready for any LlamaIndex agent or query engine.

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.

Tool names exposed to the LLM are whatever the upstream MCP server advertises (canonical hyphenated strings: `reasoning`, `code`, `anti-deception`, `memory`, `adaptive-reasoning`, `adaptive-code`, `adaptive-anti-deception`, `adaptive-memory`). This shim does not rename them.

## Install

```bash
pip install llama-index-tools-ejentum
```

## Configuration

```bash
export EJENTUM_API_KEY="ej_..."
```

Or pass `api_key=` to `EjentumToolSpec(...)`. Get a key at [ejentum.com/pricing](https://ejentum.com/pricing).

## Usage

### Minimal

```python
from llama_index.tools.ejentum import EjentumToolSpec

spec = EjentumToolSpec()
tools = spec.to_tool_list()
```

### Subset of modes

```python
spec = EjentumToolSpec(modes=["reasoning", "code", "adaptive-reasoning", "adaptive-code"])
tools = spec.to_tool_list()
```

Valid mode names (use canonical hyphenated form): `reasoning`, `code`, `anti-deception`, `memory`, `adaptive-reasoning`, `adaptive-code`, `adaptive-anti-deception`, `adaptive-memory`.

### With a ReActAgent

```python
from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI
from llama_index.tools.ejentum import EjentumToolSpec

tools = EjentumToolSpec().to_tool_list()
agent = ReActAgent.from_tools(tools, llm=OpenAI(model="gpt-4o-mini"))

response = await agent.achat(
    "Why might our microservice return 503s only under specific load patterns?"
)
```

## Tool inventory

### Dynamic (all tiers)

| Tool | Library size |
|---|---:|
| `reasoning` | 311 |
| `code` | 128 |
| `anti-deception` | 139 |
| `memory` | 101 |

### Adaptive (Go or Super tier)

| Tool |
|---|
| `adaptive-reasoning` |
| `adaptive-code` |
| `adaptive-anti-deception` |
| `adaptive-memory` |

Each tool takes a single `query: str` argument. Returns the injection as a string.

## API reference

```python
EjentumToolSpec(
    api_key: str | None = None,
    modes: list[str] | None = None,
    api_url: str = "https://api.ejentum.com/mcp",
    timeout: int = 30,
)
```

| Field | Default | Description |
|---|---|---|
| `api_key` | `None` | If unset, read from `EJENTUM_API_KEY`. Raises `ValueError` at construction if neither is set. |
| `modes` | `None` | Optional subset of harness modes to expose. Defaults to all eight. |
| `api_url` | `https://api.ejentum.com/mcp` | Override for self-hosted MCP gateway. |
| `timeout` | `30` | HTTP timeout in seconds for the underlying MCP client. |

The class is a thin subclass of `llama_index.tools.mcp.McpToolSpec`, pre-configured with the hosted Ejentum endpoint and Bearer authentication.

## Wire contract

This shim talks to the **MCP** endpoint (`/mcp`), not the direct-REST endpoint (`/harness/`). For the direct-REST contract used by every other Ejentum shim, see the [ejentum-mcp README](https://github.com/ejentum/ejentum-mcp#wire-contract); for the MCP-over-streamable-HTTP contract, see the [MCP specification](https://modelcontextprotocol.io).

Field structure of an injection and a canonical dynamic-vs-adaptive comparison on the same query are documented in the [ejentum-mcp README](https://github.com/ejentum/ejentum-mcp#canonical-example-dynamic-vs-adaptive-on-the-same-query).

## The underlying MCP server

The same MCP server is available on three additional surfaces:

- Stdio via `npx -y ejentum-mcp`
- Hosted Streamable HTTP at `https://api.ejentum.com/mcp`
- Listed on the [Official MCP Registry](https://registry.modelcontextprotocol.io/) as `io.github.ejentum/ejentum-mcp`

## Compatibility

- Python 3.10+
- `llama-index-core>=0.13.0,<0.15`
- `llama-index-tools-mcp>=0.4.1,<0.5`

## License

[MIT](./LICENSE)


## Measured effects

The Ejentum harness is benchmarked publicly under CC BY 4.0 at [github.com/ejentum/benchmarks](https://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.
