SCANUE v22 is a brain-inspired, multi-agent CLI that orchestrates specialized “PFC region” agents using LangGraph. It focuses on decomposing a task (DLPFC) and then conditionally invoking only the necessary specialist agents (VMPFC/OFC/ACC) before final integration (MPFC).
This repository was previously referred to as SCANJS, a deprecated project by another developer. To reflect the enhancements introduced—such as human-in-the-loop (HITL) mechanisms and customized fine-tuned models—the project has been rebranded as SCANUE-V22.
For clarity:
- Instances of "SCANJS" in older documentation or code refer to pre-rebranding materials
- The current version reflects multiple iterations leading to this enhanced release
- DLPFC Agent: Task delegation and executive control
- VMPFC Agent: Emotional regulation and risk assessment
- OFC Agent: Reward processing and outcome evaluation
- ACC Agent: Conflict detection and error monitoring
- MPFC Agent: Value-based decision-making
- Python: 3.11+
- An LLM provider: OpenAI, Ollama (local), or HuggingFace (endpoint/TGI)
- Environment variables (only if needed by your provider):
- OpenAI:
OPENAI_API_KEY - HuggingFace:
HUGGINGFACEHUB_API_TOKEN - Legacy fallback model names (optional):
DLPFC_MODEL,VMPFC_MODEL,OFC_MODEL,ACC_MODEL,MPFC_MODEL
- OpenAI:
-
Clone the repository:
git clone https://github.com/iLevyTate/scanue-v22.git cd scanue-v22 -
Install:
pip install -e . # add ".[dev]" for pytest, ruff and mypy
Dependencies are declared in
pyproject.toml. -
(Optional) Set up environment variables in a
.envfile (recommended) -
Run the application:
# Interactive mode (prompts for a task, then offers to collect feedback) scanue # or: python main.py # One-shot mode (runs a single task non-interactively and exits) scanue "How should I structure my team's weekly meetings?"
The primary configuration is config/agents.yaml (a ready-to-edit copy is
provided at config/agents.example.yaml). Each agent can use a different
provider/model:
- Ollama (local): set
provider: "ollama"and (optionally)base_url(default ishttp://localhost:11434) - OpenAI: set
provider: "openai"and either setOPENAI_API_KEYor putapi_key:in the YAML - HuggingFace: set
provider: "huggingface"and either setHUGGINGFACEHUB_API_TOKENor putapi_key:in the YAML
See docs/local_models.md for examples and recommendations.
- User inputs a task or problem
- DLPFC Agent: Breaks down the task and delegates which specialist agents are needed
- Specialized agents run (only if delegated):
- VMPFC: Emotional regulation
- OFC: Reward processing
- ACC: Conflict detection
- MPFC: Integrates all prior insights into the final response
- (Optional) User provides feedback (persisted to
feedback_history.json)
pip install -e ".[dev]"
pytest tests/ # 217 tests, fully offline — no provider, no API key
ruff check .
mypy main.py workflow.py agents utils scriptsCI runs all three on every push and pull request, across Python 3.11–3.13.
The suite proves the logic but never contacts a model. To validate against your actual provider — schema compliance, token capture, context headroom — run:
python scripts/validate.pyIt runs one real task in a temporary state directory (your feedback_history.json
and logs/ are untouched) and prints a pass/fail report. Exit code 0 means every
hard check passed.
Specialists fail independently: if VMPFC cannot reach its model, the run
continues without it rather than aborting. When that happens the CLI says so
explicitly, and the session log records degraded: true alongside
agent_errors. A failed agent's output is excluded from MPFC's synthesis
and MPFC is told which perspective is missing, so a partial analysis is never
presented as a complete one.
DLPFC decides which specialists a task needs. It first asks the model for a
schema-validated decision (with_structured_output), which the provider
constrains during generation — nothing has to be parsed out of prose. If the
model or provider can't do that, it falls back to parsing the text reply.
Every run records how the decision was made, in logs/session_*.json under the
task_delegation stage:
delegation_source |
Meaning |
|---|---|
structured_output |
Schema-validated — the model stated its decision |
structured_text |
Parsed from - VMPFC Agent: YES lines |
semantic |
Inferred from keywords in the reply |
pattern |
Inferred from loose regex matches |
heuristic |
Nothing matched; task-complexity guess |
resilient_fallback |
DLPFC failed; safe default set was used |
Only structured_output reflects an explicit choice by the model — everything
else is inference, and a fallback also emits a WARNING. To check how your
models are behaving:
grep -h '"delegation_source"' logs/session_*.json | sort | uniq -c | sort -rnA high fallback rate usually means the model is too small to follow the schema; DLPFC drives all routing, so it benefits most from your strongest model.
Each run writes logs/session_*.json (kept to the 50 most recent) containing,
per stage: the resolved model and provider, the rendered prompt, token usage and
finish reason, duration, and any error — plus run-level totals and
wall_clock_ms. Token counts and the elapsed time are printed after each run.
A finish_reason of length means the response was cut off mid-generation;
those stages are named in the summary rather than passing as complete answers.
Diagnostics are logged to stderr. The default level is WARNING; raise it to see
prompt construction, routing decisions, and provider traffic:
SCANUE_LOG_LEVEL=DEBUG python main.py "your task"Key modules:
main.py: CLI entrypoint, feedback persistence, session loggingworkflow.py: LangGraph workflow graph (stages + dynamic delegation)agents/: agent implementations (base.py,dlpfc.py,specialized.py) and the provider/modelfactory.pyutils/config.py: YAML config loader with legacy env-var fallbackconfig/agents.yaml: per-agent model/provider configurationdocs/local_models.md: guide for Ollama / HuggingFace / OpenAI configurationCHANGELOG.md: notable changes per releasetests/: pytest suite covering agents, workflow, HITL, and CLIscripts/validate.py: one-command validation against a real providerfeedback_history.json: persistent Human-in-the-Loop (HITL) feedback (gitignored)logs/: per-run session logs (gitignored)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Thanks to all contributors who have helped shape SCANUE-V22
- Special thanks to the cognitive science community for their research and insights