Skip to main content

LangChain callback handler for Viatoris — emit a signed Viatoris receipt for every LangChain tool call

Project description

Viatoris LangChain Adapter

A drop-in LangChain callback handler that emits a cryptographically signed Viatoris receipt for every tool call your agent makes.

No rewrite. No latency. Receipt submission is fire-and-forget on a background thread and never raises — Viatoris is designed to never crash your agent.

Install

pip install viatoris-langchain

This pulls in viatorisai (the core SDK) and works with any langchain-core>=0.1.0 agent.

Usage

Get an API key and create an agent passport at dashboard.viatoris.ai, then save the returned private_key_jwk somewhere your agent can read it. After that, one line of integration:

from viatoris_langchain import ViatorisCallbackHandler

handler = ViatorisCallbackHandler(
    org_api_key="at_live_...",
    agent_did="did:web:example.com:agents:scout",
    private_key_jwk=saved_key,
    key_id="did:web:example.com:agents:scout#key-1",
)

# Add to any LangChain agent — every tool call gets a signed receipt
agent = AgentExecutor(agent=..., tools=..., callbacks=[handler])

That's it. Run your agent normally. Every on_tool_end produces a signed ActionReceipt with the tool name, inputs, outputs, and a success/failure status. Browse them at dashboard.viatoris.ai/audit or query them through the Viatoris API.

Tracking LLM and chain calls too

By default the handler only emits receipts for tool calls — that's almost always what you want for an audit trail. If you also want to receipt every raw LLM call or every chain step, opt in:

handler = ViatorisCallbackHandler(
    org_api_key="at_live_...",
    agent_did="did:web:example.com:agents:scout",
    private_key_jwk=saved_key,
    key_id="did:web:example.com:agents:scout#key-1",
    track_llm=True,
    verbose=True,
)
Option Default What it tracks
track_llm False Every on_llm_start/on_llm_end pair (one receipt per LLM call)
track_chains False Every on_chain_start/on_chain_end pair (one receipt per chain step)
capability "langchain" The capability field on every receipt — useful for filtering in the dashboard
verbose False Print a one-liner each time a receipt is queued

Both track_llm and track_chains produce a lot of receipts on a busy agent. Tools-only is the recommended default for production.

How it works

LangChain emits callbacks at every stage of agent execution. This handler:

  1. Stores tool inputs by run_id on on_tool_start.
  2. On on_tool_end, looks up the stored input, builds an ActionReceipt, signs it with your agent's Ed25519 key, and submits it to the Viatoris receipt service on a background thread.
  3. On on_tool_error, does the same but with result="failure" and the error in the outputs.

Every method body is wrapped in a try/except — if the SDK, the network, or anything else throws, your agent keeps running.

Documentation

Full Viatoris guide at viatoris.ai/quickstart.

Questions? Email jared@viatoris.ai.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viatoris_langchain-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viatoris_langchain-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file viatoris_langchain-0.1.0.tar.gz.

File metadata

  • Download URL: viatoris_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for viatoris_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 497664b4f00d40c417d20bb122412f62e464aa7bf9f770cc4e5563999e014175
MD5 77b8ef7e3180a2b0dff197e73a1e1b1d
BLAKE2b-256 5433fa940b4c13cdbafefd221f31a63aa322637ca0830bf1bb062be2bd72da20

See more details on using hashes here.

File details

Details for the file viatoris_langchain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for viatoris_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d512138d2cf279d04d847f802d5b30eb5fa080d6ec397f2b37da1b62ee893800
MD5 253635bd7d9fda8ae8421c20a45fa9b2
BLAKE2b-256 4be1130226366e551659d2286578121050169489d513128aa5051a329880b36c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page