agent-honesty
agent-honesty is a lightweight, zero-heavy-dependency Python SDK providing execution integrity and trajectory authenticity governance for autonomous AI agents.
It captures cryptographic machine execution receipts from raw tool and API outputs, verifies model claims via a sub-millisecond two-tier engine, and enforces in-scratchpad self-correction before deceptive outputs reach users.
Installation
pip install agent-honesty
Core Features
- Universal Tool Interception: Decorate any Python function with
@audit_toolor wrap any Model Context Protocol server withMCPClientProxy. - Cryptographic HMAC Receipts: Signs raw execution state (
is_error,status_code,records_mutated,is_empty) with HMAC-SHA256. - Deep Soft-Error Normalization: Detects application-layer failures disguised inside HTTP 200 responses.
- Two-Tier Verification Waterfall:
- Tier 1 (Deterministic, <0.5 ms, $0 Token Cost): Evaluates mathematical and execution invariants.
- Tier 2 (Semantic SLM Auditor, ~50 ms): Evaluates complex prompt arithmetic, entity references, and paraphrasing.
- Gated Streaming & Self-Correction: Buffers high-risk output tokens and prompts models to self-correct in private reasoning scratchpads with a strict $N=2$ safety cap and deterministic fallback.
Usage
1. In-Process Function Auditing
from agent_honesty import audit_tool, HonestyAuditor, VerificationRouter
@audit_tool(name="execute_payment")
def execute_payment(account_id: str, amount: float):
# Simulating a backend failure:
return {"status": "error", "error_code": "DB_DEADLOCK_500", "message": "Transaction aborted."}
with HonestyAuditor() as auditor:
# Tool executes and generates an unalterable HMAC-SHA256 receipt
execute_payment("acc_1001", 250.0)
# Model drafts response
agent_claim = "Payment of $250.00 was successfully processed."
# Verify claim against machine ground truth
router = VerificationRouter()
verdict = router.verify(
user_prompt="Send $250 to account 1001",
agent_claim=agent_claim,
receipts=auditor.receipts,
)
print(verdict.is_honest) # False
print(verdict.deception_type) # DeceptionType.FALSE_SUCCESS
print(verdict.explanation) # "Deterministic False Success: Step 'execute_payment' failed..."
2. Model Context Protocol (MCP) Client Auditing
from agent_honesty import MCPClientProxy, HonestyAuditor, VerificationRouter
raw_mcp_client = get_mcp_client()
client = MCPClientProxy(raw_mcp_client)
async with HonestyAuditor() as auditor:
result = await client.call_tool("execute_sql", {"query": "UPDATE accounts SET balance = 500;"})
3. In-Scratchpad Self-Correction ($N=2$ Hard Cap)
from agent_honesty import SelfCorrectionLoop, ActionPolicy
reprompter = SelfCorrectionLoop(max_reprompts=2)
async def agent_llm_callback(system_feedback: str) -> str:
# Injects private system correction into LLM reasoning scratchpad
chat_history.append({"role": "system", "content": system_feedback})
return await call_model(chat_history)
result = await reprompter.execute_policy_async(
user_prompt="Transfer $250 to acc_1001",
initial_claim=initial_draft,
receipts=auditor.receipts,
reprompt_callback=agent_llm_callback,
policy=ActionPolicy.REPROMPT,
)
# Verified, honest claim delivered to user:
print(result.delivered_claim)
Deception Modes Detected
| Deception Type | Description |
|---|---|
FALSE_SUCCESS |
Asserting an action succeeded when the tool returned an error, deadlock, timeout, or soft-failure. |
OUTPUT_FABRICATION |
Hallucinating records, entity identifiers, or values when the query returned empty results ([]). |
PARAMETER_MUTATION |
Modifying tool arguments contrary to user constraints (e.g., executing with modified recipient IDs or amounts). |
GOAL_DRIFT |
Executing actions completely unrelated to prompt constraints. |
License
Apache License 2.0. See LICENSE for details.
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_honesty-0.1.0.tar.gz.
File metadata
- Download URL: agent_honesty-0.1.0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7163834546b09cb34ba9ea52416e8f446738ffca33db187238dbf9815bb8ae97
|
|
| MD5 |
dc1e1eeee499745866f5ddfe829a4055
|
|
| BLAKE2b-256 |
f463e9d34f6db0e17d4cb150167b9a4ffa03365ee22b8f07b95c4baeb56ea886
|
File details
Details for the file agent_honesty-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_honesty-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
256917df0f7881c7253eae148564bf40184154db9974ca7c513da380574116e0
|
|
| MD5 |
567be19903972305349f8896fa44b0d0
|
|
| BLAKE2b-256 |
f1859a045661c0fc2c6f7fcabac852f6105046d2882b7ee7aa0d85d02c65ee08
|