You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenFang (RightNow-AI/openfang), a Rust-based Agent Operating System, implements a Merkle Hash-Chain Audit Trail (audit.rs) that creates a cryptographically linked, tamper-evident log of every agent action. Each entry is chained to the previous via SHA-256, making it impossible to modify or delete historical actions without breaking the chain. This provides enterprise-grade auditability for autonomous agent operations.
Hermes Agent currently logs conversations comprehensively via SQLite (hermes_state.py — sessions + messages tables) and saves session trajectories as JSON files. However, this logging is conversation-focused (what was said) rather than action-focused (what was done). There's no structured, security-grade record of "agent performed action X on resource Y at time T with result Z" — actions are embedded in tool call/response messages but not indexed or chain-linked. The existing append_audit_log in skills_hub.py only covers skill install/uninstall events.
A cryptographic audit trail would enable: compliance reporting, forensic analysis after incidents, trust verification for autonomous operations, and accountability for agents running on schedules via cron.
Chain Verification: verify_chain() walks the entire log and recomputes each hash from its components + the previous hash. Any tampering (insertion, deletion, modification) breaks the chain.
Storage: Append-only file (one JSON entry per line) + optional SQLite index for querying.
Query API: Filter by agent_id, action_type, time range, resource pattern.
Key Design Decisions
Append-only storage: Entries are never modified or deleted, only appended
Hash chaining: Each entry's hash depends on the previous, creating a tamper-evident sequence
Action-level granularity: Logs individual actions (tool calls, file writes, network requests), not just conversations
Separate from conversation history: The audit trail is a security/compliance artifact, not a conversation replay
Current State in Hermes Agent
What we have:
hermes_state.py: SQLite database with sessions and messages tables. Full conversation history with tool calls embedded as message content. FTS5 search. No hash chaining or tamper detection.
agent/trajectory.py: JSON session logs in ShareGPT format for RL training. No security properties.
gateway/hooks.py: Event hook system with lifecycle events (session:start, agent:step, agent:end, etc.). Python handlers in ~/.hermes/hooks/. This is the ideal integration point for an audit trail — hooks already fire on the right events.
tools/skills_hub.py: append_audit_log() for skill install/uninstall only. Simple text log, no chaining.
What's missing:
No structured action log (tool call → result as a first-class record)
No cryptographic chaining or tamper detection
No action-type classification (file operations vs. network vs. shell vs. secrets)
No query/filter API for "show me all file writes by this agent in the last hour"
Optional: sign the chain with an Ed25519 key for non-repudiation
Pros & Cons
Pros
Accountability: Know exactly what the agent did, when, and to what — essential for autonomous/cron operations
Tamper evidence: Hash chaining means any modification is detectable via verify_chain()
Incident forensics: After something goes wrong, query the trail to reconstruct the exact sequence of actions
Compliance: Enterprise users need audit trails for SOC 2, ISO 27001, etc.
Low overhead: SHA-256 + JSONL append is fast; the main cost is serializing action summaries
Natural integration point: gateway/hooks.py already fires events on the right lifecycle moments
Cons / Risks
Storage growth: Every tool call generates an entry. High-activity agents could generate large logs. Mitigated by retention policies and JSONL compression.
Performance: Hash computation on every tool call adds latency. SHA-256 is fast (~500ns per hash) so this is negligible.
Overview
OpenFang (RightNow-AI/openfang), a Rust-based Agent Operating System, implements a Merkle Hash-Chain Audit Trail (
audit.rs) that creates a cryptographically linked, tamper-evident log of every agent action. Each entry is chained to the previous via SHA-256, making it impossible to modify or delete historical actions without breaking the chain. This provides enterprise-grade auditability for autonomous agent operations.Hermes Agent currently logs conversations comprehensively via SQLite (
hermes_state.py— sessions + messages tables) and saves session trajectories as JSON files. However, this logging is conversation-focused (what was said) rather than action-focused (what was done). There's no structured, security-grade record of "agent performed action X on resource Y at time T with result Z" — actions are embedded in tool call/response messages but not indexed or chain-linked. The existingappend_audit_loginskills_hub.pyonly covers skill install/uninstall events.A cryptographic audit trail would enable: compliance reporting, forensic analysis after incidents, trust verification for autonomous operations, and accountability for agents running on schedules via cron.
Research Findings
How OpenFang's Audit Trail Works
OpenFang's implementation (
openfang-runtime/src/audit.rs) uses:AuditEntry Structure:
sequence: Monotonically increasing sequence numbertimestamp: ISO 8601 UTC timestampagent_id: Which agent performed the actionaction_type: Enum (ToolCall, ToolResult, FileWrite, FileRead, NetworkRequest, ShellExec, SecretAccess, ConfigChange)resource: What was acted upon (file path, URL, tool name)details: Serialized action parameters and resultsprev_hash: SHA-256 hash of the previous entry (genesis entry uses zeros)hash: SHA-256 of (sequence + timestamp + agent_id + action_type + resource + details + prev_hash)Chain Verification:
verify_chain()walks the entire log and recomputes each hash from its components + the previous hash. Any tampering (insertion, deletion, modification) breaks the chain.Storage: Append-only file (one JSON entry per line) + optional SQLite index for querying.
Query API: Filter by agent_id, action_type, time range, resource pattern.
Key Design Decisions
Current State in Hermes Agent
What we have:
hermes_state.py: SQLite database withsessionsandmessagestables. Full conversation history with tool calls embedded as message content. FTS5 search. No hash chaining or tamper detection.agent/trajectory.py: JSON session logs in ShareGPT format for RL training. No security properties.gateway/hooks.py: Event hook system with lifecycle events (session:start,agent:step,agent:end, etc.). Python handlers in~/.hermes/hooks/. This is the ideal integration point for an audit trail — hooks already fire on the right events.tools/skills_hub.py:append_audit_log()for skill install/uninstall only. Simple text log, no chaining.What's missing:
Relevant existing issues:
Implementation Plan
Classification: Core Codebase Change
This should be a core codebase change, not a skill or tool. Reasons:
What We'd Need
agent/audit_trail.py— AuditEntry dataclass, hash chain logic, storage, query APIgateway/hooks.pyevent systemrun_agent.pyaudit_queryfor the agent to search its own action historyhermes auditfor viewing/verifying/exporting the trailPhased Rollout
Phase 1: Core Audit Engine
AuditEntrydataclass with fields: sequence, timestamp, session_id, action_type, tool_name, resource, args_summary, result_summary, prev_hash, hashcompute_entry_hash()~/.hermes/audit/trail.jsonlverify_chain()function to validate integrityTOOL_CALL,TOOL_RESULT,FILE_WRITE,FILE_READ,SHELL_EXEC,WEB_REQUESTrun_agent.py(around line 2933+)hermes audit verify(check chain integrity),hermes audit tail(view recent entries)Phase 2: Query & Filter
hermes audit search --type SHELL_EXEC --after "2h ago"audit_querytool so the agent can review its own actionsPhase 3: Compliance & Export
Pros & Cons
Pros
verify_chain()gateway/hooks.pyalready fires events on the right lifecycle momentsCons / Risks
Open Questions
References
openfang-runtime/src/audit.rs