Skip to content

API reference

Complete API documentation for the Tenro Python SDK.

Modules

Module Description
tenro Main exports: init, Tenro, Construct
tenro.construct Test harness for simulating and verifying
tenro.linking Decorators: @link_agent, @link_llm, @link_tool
tenro.errors Exception hierarchy

Quick import guide

# Decorators (most common)
from tenro import link_agent, link_llm, link_tool

# Test harness (for type hints)
from tenro import Construct

# Exceptions (for error handling)
from tenro import TenroError, TenroVerificationError

Common patterns

Linking and testing

from tenro import link_agent, link_llm, link_tool, Provider
from tenro.simulate import llm, tool
from tenro.testing import tenro

@link_tool("search")
def search(query: str) -> list[str]:
    return api.search(query)

@link_llm(Provider.OPENAI)
def call_llm(prompt: str) -> str:
    return openai.chat.completions.create(...)

@link_agent("MyAgent")
def my_agent(input: str) -> str:
    docs = search(input)
    return call_llm(f"Summarize: {docs}")

# In tests
@tenro
def test_agent():
    tool.simulate(search, result=["doc1"])
    llm.simulate(Provider.OPENAI, response="Summary")

    my_agent("query")

    tool.verify_many(search, count=1)
    llm.verify()

Error handling

from tenro import TenroError, TenroVerificationError, link_tool
from tenro.simulate import tool

@link_tool("search")
def search(query: str) -> list[str]:
    return api.search(query)

try:
    tool.verify_many(search, count=5)  # But only called 1 time
except TenroVerificationError as e:
    print(f"Verification failed: {e}")