Pydantic AI tool adapters for Copass — drop-in discover/interpret/search tools for Pydantic AI agents
Project description
copass-pydantic-ai
Copass retrieval as Pydantic AI tools. The LLM decides whether to discover, interpret, or search — you don't write the tool-calling loop.
Prerequisites
Install the Copass CLI and bootstrap your account:
npm install -g @copass/cli
copass login # email OTP
copass setup # creates a sandbox, writes .olane/refs.json
copass apikey create --name my-app # prints an olk_... key — shown once, save it
| Output | Use as |
|---|---|
olk_... key printed by copass apikey create |
api_key on CopassRetrievalClient (typically via COPASS_API_KEY env) |
sandbox_id in ./.olane/refs.json |
sandbox_id on copass_tools (typically via COPASS_SANDBOX_ID env) |
Ingest some content so retrieval has something to return:
copass ingest path/to/file.md
Install
pip install copass-pydantic-ai pydantic-ai
Requires Python 3.10+.
Quickstart
import os
from pydantic_ai import Agent
from copass_pydantic_ai import CopassRetrievalClient, copass_tools
# COPASS_API_KEY is the olk_... token from `copass apikey create`.
# COPASS_SANDBOX_ID is from .olane/refs.json (written by `copass setup`).
client = CopassRetrievalClient(
api_url=os.environ.get("COPASS_API_URL", "https://ai.copass.id"),
api_key=os.environ["COPASS_API_KEY"],
)
discover, interpret, search = copass_tools(
client=client,
sandbox_id=os.environ["COPASS_SANDBOX_ID"],
)
agent = Agent(
"anthropic:claude-opus-4-7",
tools=[discover, interpret, search],
)
result = await agent.run("what do we know about checkout retry behavior?")
print(result.output)
If it worked, the answer cites concepts from whatever you ingested. Run twice with a shared window (see below) — the second call won't re-surface items the agent already used.
Why this, not the raw API
- LLM chooses the retrieval shape. Three tools; the model picks the right one per turn.
- Pydantic AI-native. Type hints become the schema; docstrings become descriptions. No decorator dance.
- Trimmed responses. Tools return only what the model needs — no sandbox/query echoes.
Tools
| Tool | When the LLM calls it |
|---|---|
discover |
"What's relevant?" — ranked menu of pointers |
interpret |
"Tell me about these specific items." — brief pinned to canonical_ids |
search |
"Answer this directly." — full synthesized answer |
Window-aware retrieval
Pass any object with a get_turns() method:
class MyWindow:
def __init__(self):
self.turns: list[dict[str, str]] = []
def get_turns(self) -> list[dict[str, str]]:
return self.turns
window = MyWindow()
discover, interpret, search = copass_tools(
client=client,
sandbox_id=project_refs["sandbox_id"],
window=window,
)
Every retrieval call forwards window.get_turns() as history so the server excludes already-seen content.
Low-level client
If you don't want the Pydantic AI wrapping, CopassRetrievalClient is a minimal async httpx client you can use directly:
menu = await client.discover("sb_...", query="...")
brief = await client.interpret("sb_...", query="...", items=[["cid1", "cid2"]])
answer = await client.search("sb_...", query="...")
Related
@copass/ai-sdk,@copass/langchain,@copass/mastra— same shape for TypeScript frameworks@copass/mcp— standalone MCP server for Claude Code / Desktop / Cursor
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file copass_pydantic_ai-1.0.1.tar.gz.
File metadata
- Download URL: copass_pydantic_ai-1.0.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07348570aef9d871c5737e00ac588fd804287cdc4ac008d086557912eb652ff0
|
|
| MD5 |
36056a6835b1bdf19689ed063a6f6217
|
|
| BLAKE2b-256 |
1e8dacbc1b58c1d0c4c2ed2bf8666d0245cc01889cb5eefe02462ab10b454f49
|
Provenance
The following attestation bundles were made for copass_pydantic_ai-1.0.1.tar.gz:
Publisher:
release-python.yml on olane-labs/copass
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
copass_pydantic_ai-1.0.1.tar.gz -
Subject digest:
07348570aef9d871c5737e00ac588fd804287cdc4ac008d086557912eb652ff0 - Sigstore transparency entry: 1438938120
- Sigstore integration time:
-
Permalink:
olane-labs/copass@8410a8e102ab55a90147652ca1b8c7df14f1c404 -
Branch / Tag:
refs/heads/production - Owner: https://github.com/olane-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@8410a8e102ab55a90147652ca1b8c7df14f1c404 -
Trigger Event:
push
-
Statement type:
File details
Details for the file copass_pydantic_ai-1.0.1-py3-none-any.whl.
File metadata
- Download URL: copass_pydantic_ai-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac05de67dc4a8d81b665ba202e15de63cdbb1bb5c020842434ab80a9f678d873
|
|
| MD5 |
d1407fc83662570b12b902e855b66350
|
|
| BLAKE2b-256 |
7f1f8d4170d76da8982cf32a082317f7667bc12102fcd1c1714ba418fcc30f34
|
Provenance
The following attestation bundles were made for copass_pydantic_ai-1.0.1-py3-none-any.whl:
Publisher:
release-python.yml on olane-labs/copass
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
copass_pydantic_ai-1.0.1-py3-none-any.whl -
Subject digest:
ac05de67dc4a8d81b665ba202e15de63cdbb1bb5c020842434ab80a9f678d873 - Sigstore transparency entry: 1438938145
- Sigstore integration time:
-
Permalink:
olane-labs/copass@8410a8e102ab55a90147652ca1b8c7df14f1c404 -
Branch / Tag:
refs/heads/production - Owner: https://github.com/olane-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@8410a8e102ab55a90147652ca1b8c7df14f1c404 -
Trigger Event:
push
-
Statement type: