|
| 1 | +# crewai-ejentum |
| 2 | + |
| 3 | +A [CrewAI](https://crewai.com) tool that retrieves a task-matched **cognitive operation** from the [Ejentum](https://ejentum.com) Reasoning Harness and injects it into the agent's reasoning before it produces an answer. |
| 4 | + |
| 5 | +Each operation in the Ejentum library (679 of them, organized across four harnesses) is engineered in **two layers**: |
| 6 | + |
| 7 | +- a **natural-language procedure** the model can read, naming the steps to take and the failure pattern to refuse, and |
| 8 | +- 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, and escape paths for when the prescribed plan stops fitting the task at hand. |
| 9 | + |
| 10 | +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. |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +```bash |
| 15 | +pip install crewai-ejentum |
| 16 | +``` |
| 17 | + |
| 18 | +## Configuration |
| 19 | + |
| 20 | +Get a free Ejentum API key (100 calls, no card required) at <https://ejentum.com/pricing> and set it in your environment: |
| 21 | + |
| 22 | +```bash |
| 23 | +export EJENTUM_API_KEY="zpka_..." |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +```python |
| 29 | +from crewai import Agent, Task, Crew |
| 30 | +from crewai_ejentum import EjentumHarnessTool |
| 31 | + |
| 32 | +harness = EjentumHarnessTool() |
| 33 | + |
| 34 | +architect = Agent( |
| 35 | + role="Senior architect", |
| 36 | + goal="Evaluate technical decisions honestly", |
| 37 | + backstory="You are pragmatic and push back on sunk-cost framings.", |
| 38 | + tools=[harness], |
| 39 | +) |
| 40 | + |
| 41 | +task = Task( |
| 42 | + description=( |
| 43 | + "We've spent three months on the GraphQL gateway. It's mostly done. " |
| 44 | + "Should we keep going or pivot to REST? " |
| 45 | + "Call the Ejentum harness with mode='anti-deception' before answering." |
| 46 | + ), |
| 47 | + agent=architect, |
| 48 | + expected_output="A recommendation that separates past spending from prospective evaluation.", |
| 49 | +) |
| 50 | + |
| 51 | +Crew(agents=[architect], tasks=[task]).kickoff() |
| 52 | +``` |
| 53 | + |
| 54 | +## The four harnesses |
| 55 | + |
| 56 | +Pick the mode that matches what the agent is about to do: |
| 57 | + |
| 58 | +| Mode | Best for | Library size | |
| 59 | +|---|---|---| |
| 60 | +| `reasoning` | Analytical, diagnostic, planning, multi-step tasks spanning abstraction, time, causality, simulation, spatial, and metacognition | 311 operations | |
| 61 | +| `code` | Code generation, refactoring, review, and debugging across the software-engineering layer | 128 operations | |
| 62 | +| `anti-deception` | Prompts that pressure the agent to validate, certify, or soften an honest assessment, spanning sycophancy, hallucination, deception, adversarial framing, judgment, and executive control | 139 operations | |
| 63 | +| `memory` | Sharpening an observation already formed about cross-turn drift across the perception layer; filter-oriented, not write-oriented | 101 operations | |
| 64 | + |
| 65 | +## What an injection looks like |
| 66 | + |
| 67 | +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`: |
| 68 | + |
| 69 | +``` |
| 70 | +[NEGATIVE GATE] |
| 71 | +The server's response time was accepted as average, despite a suspicious |
| 72 | +rhythm break in its timing pattern. |
| 73 | +
|
| 74 | +[PROCEDURE] |
| 75 | +Step 1: Establish baseline timing profiles by extracting historical |
| 76 | +durations and intervals for each event type. Step 2: Compare each observed |
| 77 | +timing against its baseline and compute deviation magnitude. Step 3: |
| 78 | +Classify anomalies as too fast, too slow, too early, or too late, and rank |
| 79 | +by severity. ... Step 5: If deviation exceeds two standard deviations, |
| 80 | +probe root cause by tracing upstream dependencies. ... |
| 81 | +
|
| 82 | +[REASONING TOPOLOGY] |
| 83 | +S1:durations → FIXED_POINT[baselines] → N{dismiss_timing_deviations_ |
| 84 | +without_investigation} → for_each: S2:compare → S3:deviation → |
| 85 | +G1{>2sigma?} --yes→ S4:classify → S5:probe_cause → FLAG → continue --no→ |
| 86 | +S6:validate → continue → all_checked → OUT:anomaly_report |
| 87 | +
|
| 88 | +[TARGET PATTERN] |
| 89 | +Establish timing baselines by extracting historical response intervals. |
| 90 | +Compare current server response time to this baseline. ... |
| 91 | +
|
| 92 | +[FALSIFICATION TEST] |
| 93 | +If no event timing is flagged as suspiciously fast or slow relative to |
| 94 | +baseline, temporal anomaly detection was not active. |
| 95 | +
|
| 96 | +Amplify: timing baseline comparison; anomaly classification; security |
| 97 | +context elevation |
| 98 | +Suppress: average timing acceptance; outlier normalization |
| 99 | +``` |
| 100 | + |
| 101 | +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. |
| 102 | + |
| 103 | +## API reference |
| 104 | + |
| 105 | +```python |
| 106 | +EjentumHarnessTool(api_url: str = "...", timeout_seconds: float = 10.0) |
| 107 | +``` |
| 108 | + |
| 109 | +| Field | Default | Description | |
| 110 | +|---|---|---| |
| 111 | +| `api_url` | `https://ejentum-main-ab125c3.zuplo.app/logicv1/` | Override only if you self-host the Ejentum Logic API gateway. | |
| 112 | +| `timeout_seconds` | `10.0` | Per-call HTTP timeout. | |
| 113 | + |
| 114 | +`EJENTUM_API_KEY` is read from the environment at call time. |
| 115 | + |
| 116 | +The tool's `_run` accepts two arguments: |
| 117 | + |
| 118 | +- `query` (string, required): a 1-2 sentence description of the task the agent is about to work on. For `mode='memory'`, format as `"I noticed [X]. This might mean [Y]. Sharpen: [Z]."`. |
| 119 | +- `mode` (string, required): one of `reasoning`, `code`, `anti-deception`, `memory`. |
| 120 | + |
| 121 | +Returns the scaffold string. Errors are returned as human-readable strings (the tool never raises so the agent never crashes the run). |
| 122 | + |
| 123 | +## Compatibility |
| 124 | + |
| 125 | +- Python 3.10+ |
| 126 | +- `crewai>=0.40.0` |
| 127 | +- `requests>=2.31.0` |
| 128 | + |
| 129 | +## Resources |
| 130 | + |
| 131 | +- Ejentum homepage: <https://ejentum.com> |
| 132 | +- Free tier and pricing: <https://ejentum.com/pricing> |
| 133 | +- API reference: <https://ejentum.com/docs/api_reference> |
| 134 | +- "Why LLM Agents Fail" essay: <https://ejentum.com/blog/why-llm-agents-fail> |
| 135 | +- "Under Pressure" research paper: <https://doi.org/10.5281/zenodo.19392715> |
| 136 | +- CrewAI documentation: <https://docs.crewai.com> |
| 137 | + |
| 138 | +## License |
| 139 | + |
| 140 | +[MIT](./LICENSE) |
0 commit comments