Skip to main content

The attention layer for LLM agents — see what the model fires before it ships.

Project description

StateProbe

PyPI License Python Tests

The attention layer for LLM agents.

Your agent already drifted — wrong focus, stale context, confidently editing files you never asked about. StateProbe catches it before the agent ships the answer. Works with Claude Code, Cursor, Cline, Continue, and any MCP host.

English | 简体中文


Why

LLM agents drift. They miss the user's actual point, get steered by stale context, or burn cycles on the wrong subtopic. Today's fix is "rewrite the prompt and pray." StateProbe gives you a sharper tool:

  • See what the agent is about to focus on, before it answers
  • Decide to continue, rewrite the focus, ask a boundary question, or cut stale context
  • Audit the actual output afterwards and surface drift

Runs locally. Costs zero LLM tokens by default. Plugs into any MCP host.

Install

pip install stateprobe

For MCP integration (Claude Code, Cursor, Cline, Continue):

pip install "stateprobe[mcp]"

For activation projection on open-source DeepSeek (optional):

pip install "stateprobe[lab]"

30-second demo

Before the agent answers, preview its planned focus:

stateprobe skill preview \
  --context-text "Focus on safety; do not include deprecated APIs." \
  --plan-text "I will list deprecated APIs and explain why they are unsafe."

After the agent answers, audit alignment with user requirements:

stateprobe skill overlay \
  --context examples/skill_attention_context.txt \
  --output examples/skill_attention_output.txt

Or run the legacy prompt diagnostic, with the included smart_but_not_answering demo:

stateprobe demo

What it gives back

stateprobe skill preview returns a JSON activation_decision — your agent host branches on it:

Action Meaning
continue Aligned. Agent can speak.
rewrite_planned_focus Plan misses user's actual must. Don't ship. Rewrite focus first.
ask_boundary_question Visual / creative ambiguity. Ask the user one yes/no first.
cut_context_contamination Agent is following stale context. Cut the old direction first.

stateprobe skill overlay returns an interrupt_level (ok / watch / interrupt) plus attention_gaps and control_levers for the next turn.

Full schemas: Skill spec, MCP server.

Two product lines

Line What Status
Skill — Agent Attention HUD External control layer. Text-to-text task attention. Works with closed and open models. ✅ Available
Lab — Activation Projection Projects prompt activations onto Persona Vectors on open-source DeepSeek-R1-Distill-Qwen. Opt-in. ✅ Available
Enterprise — Runtime Probe Future direction: hidden states, router traces, expert routing on open-source models. 🛠 Not yet implemented

Boundary: closed-source APIs (OpenAI, Claude) cannot expose hidden states — for them, StateProbe runs the text-level Skill layer only. Open-source models (DeepSeek, Qwen, Llama) unlock the Lab layer. OpenAI/Claude 物理上读不到 hidden states; the Lab layer requires open weights.

How it differs

promptfoo Guardrails AI LangSmith StateProbe
Analyzes Output quality Output safety Call traces Agent's planned attention before output
When After release Runtime Production Before each turn
LLM API needed Yes Yes Yes No (default)

Complementary, not competitive. promptfoo / Guardrails check what came out; StateProbe shapes what's about to come out.

Architecture

Hybrid evidence pipeline (ADR_009): independent contributors emit confidence-weighted evidence, aggregated into 8 behavior axes. Static rules are always on (zero cost); the LLM and Lab layers are opt-in and stack on top.

Layer Purpose Cost
Static Mode (StaticRuleContributor) Regex rules. Always on. Zero
LLM judge (LLMJudgeContributor) LLM semantic evidence. Opt-in via --llm-augment. API call
DeepSeek Lab (LabContributor) Hidden-state projection on DeepSeek-R1-Distill-Qwen-1.5B. Opt-in via --lab-augment. Local GPU
Black-box Eval (independent) Runs original / rewritten prompts on a target model and scores outputs. API call

Theoretical foundation:

DeepSeek-first, not DeepSeek-only — see DeepSeek roadmap.

Roadmap

  • v0.3 (current) — Skill HUD, MCP server, Lab activation projection on 4 axes
  • v0.3.1 — Remaining 4 axes; embedding contributor for offline fallback; VS Code / Cursor extension
  • v0.4 — MoE expert routing contributor on DeepSeek-MoE
  • v0.5 — Named steering vectors; output-time intervention API

See CHANGELOG for the full version history.

Documentation

  • Skill spec — attention HUD reference
  • MCP server — Claude Code / Cursor / Cline / Continue setup
  • Architecture — hybrid evidence pipeline
  • FAQ — common objections answered
More docs — evidence model, ADRs, roadmaps, contributor guides

中文文档(含 China 镜像、PowerShell 编码 fix、完整命令样例):README.zh-CN.md

Contributing

Rule library quality = the project's core value. If you find a prompt pattern that isn't detected, a misfire, or want a new target preset — open an issue or PR.

Each rule contribution must include: pattern / affected axis / direction / weight / mechanism / paper citation. See CONTRIBUTING.md.

python scripts/acceptance_check.py

License

MIT — see LICENSE.


Built on Anthropic interpretability and DeepSeek-AI open research. This tool turns those findings into something agent hosts and prompt engineers can use every day, without having to actually answer the question of how the model "thinks" — just what it's about to focus on next.

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

stateprobe-0.3.0.tar.gz (122.7 kB view details)

Uploaded Source

Built Distribution

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

stateprobe-0.3.0-py3-none-any.whl (105.6 kB view details)

Uploaded Python 3

File details

Details for the file stateprobe-0.3.0.tar.gz.

File metadata

  • Download URL: stateprobe-0.3.0.tar.gz
  • Upload date:
  • Size: 122.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for stateprobe-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f6621f675f19007d44597a37cfeced4e8c28dffc4350721eac449326a2b9b69f
MD5 8ea6d6ab4abd69984fec17c720564cdd
BLAKE2b-256 3ef31865d5f5f53d3e9a3dbd2d34f466811ee42704cdd1307331f9ab121e986b

See more details on using hashes here.

File details

Details for the file stateprobe-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: stateprobe-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 105.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for stateprobe-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a1bdd917d471b89e976aa8ba8fea0530e039e39d289c29faebb6c84db9946e1
MD5 439a65bbd69191b56d6452ab3dc400e8
BLAKE2b-256 00afcf244793ff61a9b3dee8b02832ccb55b68cc40ccd0feb155f7e7a37cab17

See more details on using hashes here.

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