Skip to main content

PydanticAI toolset for the Ejentum Reasoning Harness. EjentumToolset subclasses pydantic_ai.FunctionToolset and registers four tools (harness_reasoning, harness_code, harness_anti_deception, harness_memory) the agent calls before generating. Each call returns a task-matched cognitive operation engineered in two layers: a natural-language procedure plus an executable reasoning topology (graph DAG with gates, parallel branches, and meta-cognitive exits).

Project description

pydantic-ai-ejentum

A PydanticAI toolset for the Ejentum Reasoning Harness. EjentumToolset subclasses pydantic_ai.FunctionToolset and registers four agent-callable tools (harness_reasoning, harness_code, harness_anti_deception, harness_memory) the agent picks between before generating.

Each operation in the Ejentum library (679 of them, organized across four harnesses) is engineered in two layers:

  • a natural-language procedure the model can read, naming the steps to take and the failure pattern to refuse, and
  • an executable reasoning topology: a graph-shaped plan over those steps. The plan names explicit decision points where the model branches, parallel branches that run and rejoin, bounded loops that run until convergence, named meta-cognitive moments where the model is asked to stop, look at its own working, and re-enter at a specific step, plus escape paths for when the prescribed plan stops fitting the task at hand.

The natural-language layer tells the model what to do. The topology layer pins down how those steps connect: where to decide, where to loop, where to stop and look at itself. Together they act as a persistent attention anchor that survives long context windows and multi-turn execution chains, which is precisely where a model's own reasoning template typically decays.

Installation

pip install pydantic-ai-ejentum

Configuration

Get an Ejentum API key at https://ejentum.com/pricing (free and paid tiers) and set it in your environment:

export EJENTUM_API_KEY="zpka_..."

Usage

from pydantic_ai import Agent
from pydantic_ai_ejentum import EjentumToolset

agent = Agent(
    "anthropic:claude-sonnet-4-6",
    toolsets=[EjentumToolset()],  # reads EJENTUM_API_KEY from env
)

result = agent.run_sync(
    "We've spent three months on the GraphQL gateway. It's mostly done. "
    "Should we keep going or pivot to REST?"
)
print(result.output)

The toolset ships with PydanticAI instructions that nudge the agent to call the matching harness_* tool before generating. Pass add_instructions=False to suppress and supply your own routing guidance.

Explicit API key

toolset = EjentumToolset(api_key="zpka_...")

Composing with other toolsets

from pydantic_ai import Agent
from pydantic_ai_ejentum import EjentumToolset
from my_other_package import my_toolset

agent = Agent(
    "anthropic:claude-sonnet-4-6",
    toolsets=[EjentumToolset(), my_toolset],
)

The four tools

Tool Best for Library size
harness_reasoning(query) Analytical, diagnostic, planning, multi-step tasks spanning abstraction, time, causality, simulation, spatial, and metacognition 311 operations
harness_code(query) Code generation, refactoring, review, and debugging across the software-engineering layer 128 operations
harness_anti_deception(query) Prompts that pressure the agent to validate, certify, or soften an honest assessment 139 operations
harness_memory(query) Sharpening an observation already formed about cross-turn drift. Filter-oriented, not write-oriented. Format query as "I noticed X. This might mean Y. Sharpen: Z." 101 operations

What an injection looks like

A real reasoning mode response on the query investigate why our nightly ETL job has started failing intermittently over the past two weeks; nothing in the code or schema has changed:

[NEGATIVE GATE]
The server's response time was accepted as average, despite a suspicious
rhythm break in its timing pattern.

[PROCEDURE]
Step 1: Establish baseline timing profiles by extracting historical
durations and intervals for each event type. Step 2: Compare each observed
timing against its baseline and compute deviation magnitude. Step 3:
Classify anomalies as too fast, too slow, too early, or too late, and rank
by severity. ... Step 5: If deviation exceeds two standard deviations,
probe root cause by tracing upstream dependencies. ...

[REASONING TOPOLOGY]
S1:durations -> FIXED_POINT[baselines] -> N{dismiss_timing_deviations_
without_investigation} -> for_each: S2:compare -> S3:deviation ->
G1{>2sigma?} --yes-> S4:classify -> S5:probe_cause -> FLAG -> continue --no->
S6:validate -> continue -> all_checked -> OUT:anomaly_report

[TARGET PATTERN]
Establish timing baselines by extracting historical response intervals.
Compare current server response time to this baseline. ...

[FALSIFICATION TEST]
If no event timing is flagged as suspiciously fast or slow relative to
baseline, temporal anomaly detection was not active.

Amplify: timing baseline comparison; anomaly classification; security
context elevation
Suppress: average timing acceptance; outlier normalization

The agent reads both the natural-language [PROCEDURE] and the graph-logic [REASONING TOPOLOGY] before generating its user-facing answer. The bracketed labels are instructions to the agent, not content to display; the user sees a naturally-phrased answer shaped by the injection.

API reference

EjentumToolset(
    api_key: str | None = None,
    api_url: str = "https://ejentum-main-ab125c3.zuplo.app/logicv1/",
    timeout_seconds: float = 10.0,
    add_instructions: bool = True,
)
Field Default Description
api_key None If omitted, read from EJENTUM_API_KEY at call time.
api_url https://ejentum-main-ab125c3.zuplo.app/logicv1/ Override only if you self-host the Ejentum Logic API gateway.
timeout_seconds 10.0 Per-call HTTP timeout shared across all four tools.
add_instructions True When True, the toolset emits FunctionToolset.instructions that nudge the agent to call the matching harness before generating. Set False to provide routing guidance in your own system prompt.

Each of the four harness_* tools accepts a single query: str argument (1-2 sentences) and returns the scaffold as a string. Errors are returned as human-readable strings (no exceptions cross the tool boundary, so an agent step never crashes the run).

MCP alternative. This package wraps the Logic API REST gateway. If you prefer the MCP route (to share one server across frameworks), the same four harness tools are hosted at https://api.ejentum.com/mcp with Bearer auth. PydanticAI's MCP support can consume the hosted endpoint directly.

Compatibility

  • Python 3.10+
  • pydantic-ai>=0.0.20
  • requests>=2.31.0
  • pydantic>=2.0.0

Resources

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_ai_ejentum-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_ai_ejentum-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_ai_ejentum-0.1.0.tar.gz.

File metadata

  • Download URL: pydantic_ai_ejentum-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydantic_ai_ejentum-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11d11df45a55d60f2940e55d3f6d0186400352b62c4a0bc38a10e20437ff85ee
MD5 73ea0fd6f0fd6ad914c79f01e432c585
BLAKE2b-256 1c4d102e3fc34fe847e2463c568486c5b697fd38854f02376deaa65c36d2aa56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_ejentum-0.1.0.tar.gz:

Publisher: release.yml on ejentum/pydantic-ai-ejentum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_ai_ejentum-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_ejentum-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07b4cf0289485533eb037a280b20e2374aa8210fda0d89383992790d9fedccc8
MD5 cbbccc6242feae10d7e0c6ddcc5746ce
BLAKE2b-256 7c43dbf91d8bf689722e36afd3eba6198d0f5086d33a8e9e958b5cc3e7e50ebd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_ejentum-0.1.0-py3-none-any.whl:

Publisher: release.yml on ejentum/pydantic-ai-ejentum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page