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()
rootsign.init() alone is enough to record.
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.The team or person accountable for the agent, 2 to 200 characters. Falls back to
unknown when the user name is shorter.Where the agent runs. The same agent name can exist separately in each environment.
How much harm the agent’s actions can do, recorded on the agent for reviewers.
The agent framework, recorded on the agent. It does not change how tools are wrapped.
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:
init()does no I/O. The agent is registered, inagents.jsonlor the PostgreSQLagentstable, 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()
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.SessionContext:
Raises
Notes
- If the block raises, the session is recorded as
failedand the exception propagates. Otherwise it is recorded ascompleted. - 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()
None unless ROOTSIGN_CAPTURE_DECISIONS=true. ROOTSIGN_REASONING_DEPTH sets how much of the reasoning is kept; Configuration has the limits.
@rootsign.trace()
Rules applied to the arguments and the result before they are hashed and stored. Redact PII covers the built-in configs.
Hold each call until a person approves it. Only for plain functions. Require human approval walks through it.
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.
Record into this session instead of the current one. Pass it together with
ingest_client.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
BaseToolor a CrewAI tool wraps it the same way aswrap_tools(). - A call that cannot be recorded does not fail: RootSign logs a
WARNINGand returns the function’s result. The exceptions are held calls, which never run without a record, and the cloud transport withROOTSIGN_ON_RECORD_LOSS=fail, which raisesRecordPersistenceError.
rootsign.wrap_tools()
@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]'.
langchain_tools.py
TypeError when an item is not a tool of that framework. Nothing in the list is wrapped then:
- 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_approvalis 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
An open SQLAlchemy async session, for example from
rootsign.database.AsyncSessionLocal(). verify_session() only.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.
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.
Related
Configuration
Every environment variable, and when each is read.
Any Python function
A walkthrough of @rootsign.trace() on plain functions.