"The True is the whole." — G.W.F. Hegel
Hegelion applies dialectical reasoning to LLMs: forcing models to argue with themselves before reaching conclusions. This produces better reasoning for questions and better code for implementations.
| Mode | Pattern | Use Case |
|---|---|---|
| Dialectical Reasoning | Thesis → Antithesis → Synthesis | Deep analysis of questions, philosophy, strategy |
| Autocoding | Player → Coach → Iterate | Verified code implementations with independent review |
Both modes use the same principle: force the model to oppose itself before concluding. This catches blind spots that single-pass approaches miss.
New in v0.4.0 — Based on Block AI's g3 agent research.
Single-agent coding tools often:
- Declare success prematurely ("I have successfully implemented all requirements!")
- Accumulate context pollution over long sessions
- Miss edge cases because they verify their own work
Two roles iterate until requirements are verified:
REQUIREMENTS (Source of Truth)
│
▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ PLAYER │────▶│ COACH │────▶│ ADVANCE │
│ Implements │ │ Verifies │ │ State │
│ code & tests │ │ independently │ │ │
└───────────────┘ └───────────────┘ └───────┬───────┘
▲ │
│ ┌───────────┐ │
└──────────────│ APPROVED? │◀───────────────┘
└───────────┘
│ │
No Yes
│ │
▼ ▼
Continue Done
Player: Implements requirements, writes tests, responds to feedback. Does NOT declare success.
Coach: Independently verifies each requirement, ignores player's self-assessment, outputs structured checklist.
"Discard the player's self-report of success. Have the coach perform independent evaluation."
The coach catches issues by re-reading requirements and actually running tests—not by trusting what the player says it did.
In Claude Code, Cursor, or any MCP-enabled editor:
You: Use autocoding_init with these requirements:
- Add user authentication to src/api.py
- Add tests in tests/test_auth.py
- All tests must pass
[Session initializes]
You: Generate player_prompt and implement
[Player writes code and tests]
You: Generate coach_prompt and verify
[Coach: ✓ auth endpoint exists, ✗ missing password validation test]
You: Call autocoding_advance and continue
[Loop until COACH APPROVED]
State passing note: player_prompt returns a player prompt plus an updated state advanced to phase: "coach" for the next call. For clarity, prompt outputs include current_phase (prompt phase) and next_phase (returned state's phase). All structured outputs include schema_version for client stability.
| Tool | Purpose |
|---|---|
autocoding_init |
Start session with requirements checklist |
player_prompt |
Generate implementation prompt |
coach_prompt |
Generate verification prompt |
autocoding_advance |
Update state after coach review |
autocoding_single_shot |
Combined prompt for simpler tasks |
autocoding_save / autocoding_load |
Persist and resume sessions |
| Problem | Single Agent | Coach-Player |
|---|---|---|
| Anchoring | Drifts from requirements | Requirements anchor every turn |
| Verification | Self-assessment (unreliable) | Independent verification |
| Context | Accumulates pollution | Fresh context each turn |
| Completion | Open-ended | Explicit approval gates |
For questions requiring deep analysis, Hegelion forces three separate LLM calls:
[Call 1] Thesis → LLM commits to a position
[Call 2] Antithesis → LLM attacks that position (separate call, no hedging)
[Call 3] Synthesis → LLM reconciles the opposition
| Method | Calls | Result |
|---|---|---|
| Raw | 1 | "It depends on definitions..." |
| Enhanced | 1 | "Hold both views in tension..." |
| Hegelion | 3 | Novel framework with testable predictions |
When the model must commit to a thesis, then genuinely attack it in a separate call, the synthesis surfaces insights that single-call approaches shortcut.
Example: "Is free will compatible with determinism?"
Hegelion synthesis (after thesis and antithesis):
The deadlock dissolves when we recognize free will exists on a spectrum of self-authorship:
- Minimal freedom: Acting on desires without external coercion
- Reflective freedom: Second-order endorsement—I want to want this
- Narrative freedom: Acting consistently with a coherent life narrative
- Constitutive freedom: Recursive self-modification through deliberate habituation
Research proposal: Use fMRI to scan participants under (1) snap judgments, (2) brief reflection, (3) extended deliberation. Hypothesis: Condition (3) shows strongest correlation with self-reported decision "ownership."
This 4-level framework emerged from actually arguing with itself—not from asking for "thesis/antithesis/synthesis" in one prompt.
pip install hegelion
# MCP setup for Claude Desktop (macOS)
hegelion-setup-mcp --write "$HOME/Library/Application Support/Claude/claude_desktop_config.json"Or use the Python API:
import asyncio
from hegelion import run_dialectic
async def main():
result = await run_dialectic("Is AI conscious?")
print(result.synthesis)
asyncio.run(main())Or CLI:
hegelion --stream "Is consciousness fundamental or emergent?"| Option | Description |
|---|---|
use_council |
Three critics: Logician, Empiricist, Ethicist |
use_judge |
Final quality evaluation |
use_search |
Grounds arguments with web search |
response_style |
sections, json, or synthesis_only |
pip install hegelionFor MCP integration (works with any MCP-enabled editor):
# Claude Desktop (macOS)
hegelion-setup-mcp --write "$HOME/Library/Application Support/Claude/claude_desktop_config.json"
# Then restart Claude DesktopSupported editors: Claude Desktop, Claude Code, Cursor, VS Code + GitHub Copilot, Windsurf, Google Antigravity, Gemini CLI
See MCP Integration Guide for setup instructions.
- MCP Integration — Setup for Claude Desktop, Cursor, VS Code + Copilot, Windsurf, Antigravity, Gemini CLI
- Python API — Full API reference
- CLI Reference — Command-line usage
- Configuration — Backends and feature toggles
- Technical Specification — Output schemas, phase specs
Issues and PRs welcome. For significant changes, open a discussion first.
- Schema versioning: All structured outputs include
schema_versionfor client stability - Phase clarity:
player_promptandcoach_promptnow includecurrent_phaseandnext_phasefields - Improved error handling: Invalid phase transitions return clear errors with
expected,received, andhintfields - State validation: Malformed state inputs return structured error responses instead of exceptions
- Autocoding system: Player-coach dialectical loop based on Block AI's g3 agent
- MCP tools:
autocoding_init,player_prompt,coach_prompt,autocoding_advance - Session persistence with
autocoding_save/autocoding_load - Single-shot mode for simpler use cases
- CLI streaming with
--streamflag - MCP progress notifications
- 470+ tests passing
License: MIT