Skip to main content
Five calls are the stable core of RootSign: init(), session(), @trace(), wrap_tools() and verification. The planned TypeScript SDK mirrors this surface. Everything else that rootsign exports is lower-level and listed at the end.
core.py

rootsign.init()

Configures RootSign once, at startup: which agent is recording, and the settings in force. Every argument is keyword-only and optional, so rootsign.init() alone is enough to record.
str
default:"the script's file name"
The agent’s name, 2 to 200 characters. Together with environment it identifies the agent. Without it, the name of the running script is used, or rootsign-agent in a notebook or REPL.
str
default:"your operating-system user name"
The team or person accountable for the agent, 2 to 200 characters. Falls back to unknown when the user name is shorter.
development | staging | production
default:"development"
Where the agent runs. The same agent name can exist separately in each environment.
low | medium | high | critical
default:"medium"
How much harm the agent’s actions can do, recorded on the agent for reviewers.
langgraph | crewai | autogen | custom | unknown
default:"unknown"
The agent framework, recorded on the agent. It does not change how tools are wrapped.
str
Up to 2,000 characters.
str
The model the agent uses, up to 100 characters.
list[str]
Tool names the agent is meant to use, recorded on the agent.
list[str]
Labels for the rules the agent falls under, recorded on the agent.
Returns None. Raises ValueError for a value outside the allowed list or the length limits above, or when init() is called again in the same process with different arguments:
Notes
  • init() does no I/O. The agent is registered, in agents.jsonl or the PostgreSQL agents table, when the first session opens. Problems that need I/O, such as a missing extra or an unwritable data folder, also surface then.
  • Calling init() again with the same arguments does nothing.
  • The ROOTSIGN_ settings are read here and stay fixed for the process. Configuration explains when each setting is read.
  • An agent’s attributes are stored when it is first registered. If a later run passes different values for the same agent and environment, RootSign keeps the stored ones and logs a warning naming the difference.
The length limits apply on every backend since the release after RootSign 0.3.1. Before, the JSONL backend accepted any length, and PostgreSQL rejected the value only when the first session opened.

rootsign.session()

Opens a session, the unit that RootSign chains and verifies. Every traced call inside the block is recorded into it, in order. The session’s open and close are recorded too.
str
What the agent is being asked to do. Recorded on the session.
str
The end user the agent is acting for, if your application has one.
UUID
An agent ID from rootsign.register_agent(). Omit it to use the agent from init().
IngestClient
Where records are written. Omit it to use the backend from init(). A client that session() builds itself is closed when the session ends; one you pass in is left open.
Yields a SessionContext: Raises Notes
  • If the block raises, the session is recorded as failed and the exception propagates. Otherwise it is recorded as completed.
  • Traced calls find the session through a context variable, so concurrent sessions in different asyncio tasks stay separate.
  • Calling a traced function after the block has ended raises RootSignNotInitializedError.
RecordPersistenceError here was added after RootSign 0.3.1. In 0.3.1 and earlier, a session that could not be opened raised the underlying PermissionError or OSError.

ctx.record_decision()

Records what the agent decided, and why, and links it to the next action recorded in the session. It does nothing and returns None unless ROOTSIGN_CAPTURE_DECISIONS=true. ROOTSIGN_REASONING_DEPTH sets how much of the reasoning is kept; Configuration has the limits.

@rootsign.trace()

Records every call of the decorated function as an action in the current session: the arguments and the result, each with its hash, and the hash that chains the action to the one before it.
str
default:"the function's __name__"
The name recorded for each call.
RedactionConfig
Rules applied to the arguments and the result before they are hashed and stored. Redact PII covers the built-in configs.
bool
default:"False"
Hold each call until a person approves it. Only for plain functions. Require human approval walks through it.
Callable[[str, dict], dict]
Builds what the approver is shown, from the tool name and the redacted input. By default: the tool name and the first 500 characters of the redacted input.
float
default:"2.0"
How often a held call checks for a decision, on PostgreSQL.
float
default:"300.0"
How long a held call waits, on PostgreSQL, before it is refused as timed out.
SessionContext
Record into this session instead of the current one. Pass it together with ingest_client.
IngestClient
Write through this client instead of the current session’s.
Returns an async function. A decorated function is always async, even when the original is not, so call it with await. Raises, when the decorated function is called: When decorating, NotImplementedError is raised for require_approval=True on a LangChain or CrewAI tool object. Notes
  • Decorating a LangChain BaseTool or a CrewAI tool wraps it the same way as wrap_tools().
  • A call that cannot be recorded does not fail: RootSign logs a WARNING and returns the function’s result. The exceptions are held calls, which never run without a record, and the cloud transport with ROOTSIGN_ON_RECORD_LOSS=fail, which raises RecordPersistenceError.

rootsign.wrap_tools()

Instruments framework tools so every call is recorded, the same way as @trace(). wrap_tools() takes LangChain tools, the kind LangGraph’s ToolNode uses, and needs pip install 'rootsign[langgraph]'. wrap_crewai_tools() takes CrewAI tools and needs pip install 'rootsign[crewai]'.
list
required
The tools to instrument.
SessionContext
Record into this session instead of the current one. Pass it together with client.
IngestClient
Write through this client instead of the current session’s.
RedactionConfig
As for @trace().
langchain_tools.py
Returns a list of the same tool objects, instrumented in place, so the originals are wrapped too. Tools that are already instrumented are left as they are, so wrapping twice is harmless. Raises TypeError when an item is not a tool of that framework. Nothing in the list is wrapped then:
Notes
  • Wrap tools wherever you build them, inside or outside a session. Each call looks up the session it runs in, and a call outside any session raises RootSignNotInitializedError.
  • require_approval is not available for framework tools. Put @rootsign.trace(require_approval=True) on the plain function the tool calls.
  • The LangGraph and CrewAI pages show complete agents.

Verify a session

Recompute every hash in a session and return the verdict. Neither function prints anything or exits.
str | Path
required
A JSONL session file or spool file. verify_session_local() only.
UUID
required
A session in the PostgreSQL store. verify_session() only.
AsyncSession
required
An open SQLAlchemy async session, for example from rootsign.database.AsyncSessionLocal(). verify_session() only.
Returns a VerifyResult: verdict (VALID, TAMPERED or INCOMPLETE), valid, record_count, first_invalid_sequence, missing_ranges, error and summary. Verify a session describes each field. Raises FileNotFoundError from verify_session_local() when the file does not exist.
Neither function reports “nothing to verify” separately. An empty file returns TAMPERED, and an unknown session ID returns VALID with 0 records. Check that the session exists before you rely on the result, or use rootsign verify, which exits 3 in these cases.

Beyond the core calls

rootsign also exports the pieces the core calls are built from. They are importable and documented in their docstrings, but they are not part of the stable core, and they can change between releases. Use RootSign without init() shows register_agent() and the clients in use: The exceptions are listed in Errors.

Configuration

Every environment variable, and when each is read.

Any Python function

A walkthrough of @rootsign.trace() on plain functions.