Skip to main content

OpenTerms adapter for CrewAI — sign and emit ORS v0.1 receipts for tool calls.

Project description

crewai-openterms

CrewAI adapter for OpenTerms — wraps any callable so each invocation emits a signed ORS v0.1 receipt before the tool runs.

Depends on openterms-py>=0.1.0 for canonicalization, signing, and the HTTP client. One signing path is shared with langchain-openterms.

Install

pip install crewai-openterms

CrewAI itself is not a hard runtime dependency. CrewAI's BaseTool API has shifted repeatedly across the 0.x line (constructor signatures, the _run-vs-run hook, pydantic model versions), so this adapter wraps a plain callable — the function-tool pattern, which is stable across CrewAI versions. Plug the wrapped function into CrewAI however your project already does (Tool(name=..., func=...), the @tool decorator, or as the body of a BaseTool._run).

Quickstart

from openterms import IngestClient, generate_keypair
from openterms_crewai import OpenTermsToolConfig, wrap_tool

sk, _ = generate_keypair()
client = IngestClient(
    base_url="http://localhost:3000",
    workspace_id="00000000-0000-4000-8000-0000000000aa",
    key_id="my-key",
    private_key=sk.private_bytes_raw(),
    agent_id="crew-agent",
)
config = OpenTermsToolConfig(
    client=client,
    agent_id="crew-agent",
    terms_url="https://example.com/terms",
    terms_hash="a" * 64,
    emit_post_action=True,
)

def search(query: str) -> str:
    """Pretend to look something up."""
    return f"results for: {query}"

wrapped_search = wrap_tool(search, config=config, tool_name="search")

# Plug into CrewAI:
#   from crewai.tools import Tool
#   tool = Tool(name="search", func=wrapped_search, description="...")

Decorator form:

from openterms_crewai import openterms_tool

@openterms_tool(config, tool_name="search")
def search(query: str) -> str:
    return f"results for: {query}"

See examples/quickstart.py for a runnable copy.

Configuration

OpenTermsToolConfig carries:

  • client — the openterms.IngestClient.
  • agent_id — placed on every receipt.
  • terms_url, terms_hash — terms binding for the receipts.
  • emit_post_action — when True, emit a second receipt after the tool returns with post_state_hash = SHA-256 of the stringified result. Default False.
  • strict — when True, re-raise openterms.IngestError; default False (failures logged, tool still runs).

What this adapter does

  • Wraps a callable. Each invocation emits a signed ORS receipt with action_type="tool_call" and action_context = {tool_id, args}. Argument introspection is best-effort (inspect.signature first, positional fallback for builtins / C callables).
  • Optionally emits a post-action receipt sharing the same receipt_id as the pre-action receipt.
  • Logs and continues on ingest failures by default. The tool's return value is always passed through.

What this adapter does NOT do

  • It does not depend on CrewAI at runtime. Tests run without crewai installed. The wrapper is callable-based.
  • It does not run an ingest service. You must point IngestClient at a running OpenTerms API.
  • It does not handle auth, host a JWKS, or manage keys. See openterms for the underlying scope.
  • It does not buffer or retry. A failed emission is logged once (or re-raised if strict=True).
  • It does not subclass CrewAI's BaseTool. That subclass tends to break across CrewAI minor versions. If you need a BaseTool subclass, build one in your project that calls into a wrap_tool-produced callable from inside _run.

Repository

Source and issue tracker: jstibal/openterms-trace.

License

Apache-2.0.

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

crewai_openterms-1.0.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

crewai_openterms-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file crewai_openterms-1.0.0.tar.gz.

File metadata

  • Download URL: crewai_openterms-1.0.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for crewai_openterms-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b0c6cdf567afdbc2aebbef285c8e2264f9d642458cc33b81c0c1566a7daa087f
MD5 3c5e0fa3867d3b69e0273ddd7b2888ab
BLAKE2b-256 32533055f2291deeebdcca8d1fee7820db79c92efacc1f29c443003b8377a488

See more details on using hashes here.

File details

Details for the file crewai_openterms-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for crewai_openterms-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8849d425378d4d59c608c69054340a1d30aaa52bde4019b18b04013a10d77349
MD5 cb39dd1dae799afc8ac03ed9375867f0
BLAKE2b-256 c0a8f014ffa766d0b83acdf23eec1c2e6077faf5a3b8308d0176c34a07671b1a

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