agent-consistency
Tool success is not business success.
agent-consistency is a zero-dependency Python safety interlock for AI agent
workflows that take irreversible or customer-visible actions. It catches
false-success bugs: cases where a tool call returns success, but the real-world
business outcome is still false.
A refund API returns
200 OK. The provider status is stillpending. The agent is about to email "your refund is complete."agent-consistencyblocks the message and records why.
Traces show what happened. Evals score what was said. agent-consistency
decides whether the workflow was allowed to continue.
Live demo: watch a false-success bug get blocked | Quickstart | Benchmark | Production | Compliance
Scan Your Repo
Get a pre-integration false-success report card in under 30 seconds:
agent-consistency scan .
agent-consistency scan . --format markdown
agent-consistency scan . --fail-on high
agent-consistency scan https://github.com/org/repo
The scanner is conservative. Low-confidence findings say "Possible risk, needs
review" and should be treated as review prompts, not certain bugs. Use
--format markdown for a copyable report suitable for GitHub issues, PR
comments, or social posts.
Benchmark: raw caught 0/6; agent-consistency caught 6/6 on the deterministic
false-success suite in benchmark/. This is a reproducible scenario-suite
result, not a universal reliability guarantee.
Architecture
The image uses compact labels such as fresh=true, handoff_ok=true, and
outcome_ok=false for readability. Stored receipts use structured JSON fields.
See the diagram-to-receipt map and the generated
pending-refund receipt sample.
Install
python -m pip install agent-consistency
The False-Success Bug
A false-success bug happens when an agent reports completion before the real world agrees.
Common forms:
- Tool success without outcome success: a refund call returns
200 OK, but provider status is stillpending. - Stale-state success: an approval is made from policy v12 while v14 is current.
- Thin-handoff success: a downstream agent acts without required facts like previous refund count.
- Unsupported-claim success: a customer-visible message says "done" without evidence for the claim.
Output validation checks response shape. Tracing records the path taken. Neither blocks the next workflow step when the business outcome is still false.
Add One Outcome Gate
from agent_consistency import WorkflowRun
run = WorkflowRun("refund-ord-1", on_violation="record")
with run.step("refund-agent", "issue_refund", step_id="refund") as step:
provider_result = {"refund_id": "rf_1", "status": "pending"}
step.write_state("refund", provider_result, include_value=True)
step.verify_outcome(
"refund_settled",
lambda: provider_result["status"] == "settled",
failure_reason="refund provider did not confirm settlement",
details=provider_result,
)
receipt = run.receipts()[-1]
print(receipt.status) # failed
print(receipt.issues[0].message) # outcome 'refund_settled' failed...
The tool returned. The receipt says the outcome failed. In the default blocking mode, the same failed outcome raises before the customer message can run.
Find Risk Before Blocking
Start in detect mode before you refactor a workflow around gates:
from agent_consistency.integrations import detect_workflow
risk_report = detect_workflow(existing_workflow)
print(risk_report.to_dict())
Or run it against stored receipts in CI:
agent-consistency detect runs/demo-pending-refund/receipts.jsonl
detect reports missing gates, stale reads, dropped handoff facts, failed
outcomes, and customer-visible actions after unresolved or unverified outcomes.
It exits non-zero on high-severity risk. It cannot know what an agent claimed
unless your workflow declares the outcomes and evidence that matter.
Instrument Any Step
Use verified_step when you want to wrap an existing callable without changing
frameworks:
from agent_consistency import RefundSettlementVerifier, WorkflowRun, verified_step
run = WorkflowRun("refund-ord-1")
provider_status = lambda refund_id: {"refund_id": refund_id, "status": "settled"}
@verified_step(
run,
"refund-agent",
"issue_refund",
criticality="financial",
idempotency_key="refund:ord_1",
outcome_verifier=lambda refund: RefundSettlementVerifier(
refund["refund_id"],
provider_status,
),
)
def issue_refund():
return {"refund_id": "rf_1"}
Use reliability_gate as a context manager when you need direct access to the
receipt-backed step. If agent-consistency[otel] is installed, the API emits
standard gen_ai.* and agent_consistency.* span attributes.
CLI Receipts
agent-consistency report runs/demo-pending-refund/receipts.jsonl
agent-consistency detect runs/demo-pending-refund/receipts.jsonl
agent-consistency verify runs/demo-pending-refund/receipts.jsonl
agent-consistency schema
Receipts are a flight recorder for AI agents: portable evidence you can inspect after an incident to see state reads, handoff facts, artifacts, outcomes, and the blocked reason.
verify separates file integrity from run semantics, so a deliberately blocked
pending-refund run can report Integrity: verified and Run status: failed as expected.
Where It Fits
| Category | What it answers | What it misses without agent-consistency |
|---|---|---|
| Guardrails | Is the output shaped correctly? | Whether the business outcome happened. |
| Evals | Was the answer good in a test? | Whether this live workflow may continue. |
| Tracing | What happened? | Whether the next action should be blocked. |
| Orchestration | Which node runs next? | Whether the handoff facts and outcomes are valid. |
| Policy engines | What rule applied? | Whether the agent used a fresh policy snapshot. |
Keep those tools. Add receipts and gates where agents make claims about the world.
Docs
- Quickstart
- Detect mode
- Benchmark
- Leaderboard
- Diagram-to-receipt map
- Receipts and verification
- Outcome verification
- Production notes
- Release governance
- Compliance framing
- False-success bugs
- Why agent-consistency
Bug Zoo
The canonical false-success examples live in examples/:
minimal_outcome_gate.pyrefund_false_success.pyhandoff_contract.pystale_state.pycustomer_message_supported_claims.py
There is also a dependency-free LangGraph-style adapter example in
examples/langgraph_style_wrapper.py, plus CrewAI-style and AutoGen-style
examples in examples/crewai_style_adapter.py and
examples/autogen_style_adapter.py.
Microsoft Adapter
There are two Microsoft Agent Framework paths:
MicrosoftAgentFrameworkNativeIntegrationfor real async Agent Framework seams:Agent.run(...), async middleware, function/tool middleware, and streaming methods. Install it withagent-consistency[microsoft]on Python 3.10+.MicrosoftAgentFrameworkConsistencyAdapteras the dependency-light fallback for MAF-shaped callables.
from agent_consistency.integrations import MicrosoftAgentFrameworkNativeIntegration
integration = MicrosoftAgentFrameworkNativeIntegration(run_id="refund-maf")
refund_agent = integration.wrap_agent_run(
maf_refund_agent,
action="issue_refund",
criticality="financial",
outcome_name="refund_settled",
outcome_check=lambda result: result["status"] == "settled",
)
The native integration keeps Microsoft packages out of the base install and
uses the official Agent Framework middleware shape. See
Microsoft Agent Framework. The quickest
generic path is still in examples/instrument_existing_agent/.
CI also includes a microsoft-live job that installs the optional Microsoft
extra and runs a real agent_framework.Agent with a deterministic local
BaseChatClient provider, so the native wrapper is checked against the actual
package without requiring cloud credentials.
Development
python -m pip install -e ".[dev]"
python -m pytest
ruff check src tests examples
Apache-2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_consistency-0.3.2.tar.gz.
File metadata
- Download URL: agent_consistency-0.3.2.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
228968e8d9bb906b7d86c0cc6e33a0c82878eee5ab8cce94c8b8e43366152cd8
|
|
| MD5 |
bb240082b4c90e95b9dcb23beb636cdc
|
|
| BLAKE2b-256 |
940e633a4c2c5236f837f5959660541086e7a03eb059aee80ae0c4ba5b4fab7d
|
Provenance
The following attestation bundles were made for agent_consistency-0.3.2.tar.gz:
Publisher:
publish.yml on karimbaidar/agent-consistency
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_consistency-0.3.2.tar.gz -
Subject digest:
228968e8d9bb906b7d86c0cc6e33a0c82878eee5ab8cce94c8b8e43366152cd8 - Sigstore transparency entry: 1965670164
- Sigstore integration time:
-
Permalink:
karimbaidar/agent-consistency@10d1616b2a6e8a178b8ee2f8d8212d3cf552498d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/karimbaidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@10d1616b2a6e8a178b8ee2f8d8212d3cf552498d -
Trigger Event:
push
-
Statement type:
File details
Details for the file agent_consistency-0.3.2-py3-none-any.whl.
File metadata
- Download URL: agent_consistency-0.3.2-py3-none-any.whl
- Upload date:
- Size: 59.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9503b1caca10f1b8fee327d75b07c77640f68e4d0acab08fe81682061869ebd0
|
|
| MD5 |
2aa3ec3faa194cdebad647caf5904e2a
|
|
| BLAKE2b-256 |
06b06f15bbe14d3c4750d2a7c9b9feb9f708406e2f10b28fbaf612174018c48c
|
Provenance
The following attestation bundles were made for agent_consistency-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on karimbaidar/agent-consistency
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_consistency-0.3.2-py3-none-any.whl -
Subject digest:
9503b1caca10f1b8fee327d75b07c77640f68e4d0acab08fe81682061869ebd0 - Sigstore transparency entry: 1965670321
- Sigstore integration time:
-
Permalink:
karimbaidar/agent-consistency@10d1616b2a6e8a178b8ee2f8d8212d3cf552498d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/karimbaidar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@10d1616b2a6e8a178b8ee2f8d8212d3cf552498d -
Trigger Event:
push
-
Statement type: