Skip to main content

sayou-pydantic-ai

Persistent memory and workspace storage for Pydantic AI agents. Write files, search content, and persist conversation history — all through a single toolset.

Built on sayou, the file-system inspired context store for AI agents.

Install

pip install sayou-pydantic-ai

Quick Start

from pydantic_ai import Agent
from sayou_pydantic_ai import SayouToolset

agent = Agent("openai:gpt-4o", toolsets=[SayouToolset()])
result = await agent.run("Save a note about our meeting decisions")

Zero config. The agent gets 7 workspace tools and a local SQLite store at ~/.sayou/. Files persist across sessions.

Tools

Tool Description
workspace_write Create or update files (supports YAML frontmatter)
workspace_read Read files with token budget control
workspace_list List files and subfolders
workspace_search Full-text and metadata search
workspace_grep Content search with line context
workspace_glob Pattern matching (**/*.md, docs/**)
workspace_kv Key-value store for config/state

Optional tools (opt-in)

Tool Description
workspace_delete Soft-delete files
workspace_history Version history
workspace_links File-to-file links
workspace_chunks Chunk-based file reading

Enable them with the tools parameter:

from sayou_pydantic_ai.toolset import ALL_TOOLS

SayouToolset(tools=ALL_TOOLS)                          # Everything
SayouToolset(tools={"read", "write", "search", "delete"})  # Pick what you need

Persist Conversation History

from sayou.workspace import Workspace
from sayou_pydantic_ai import SayouToolset, SayouMessageHistory

async with Workspace() as ws:
    history = SayouMessageHistory(ws, conversation_id="project-alpha")
    agent = Agent("openai:gpt-4o", toolsets=[SayouToolset(workspace=ws)])

    # Load previous messages
    messages = await history.load()

    # Run with history
    result = await agent.run("Continue our discussion", message_history=messages)

    # Save for next session
    await history.save(result.all_messages())

Options:

  • max_messages=50 — keep only the last N messages
  • ttl_seconds=86400 — auto-expire after 24 hours

Choose Your Tools

# Default: 7 core tools
SayouToolset()

# Minimal: just read and write
SayouToolset(tools={"read", "write"})

# Full: all 11 tools including delete
SayouToolset(tools=ALL_TOOLS)

# Custom prefix
SayouToolset(tool_prefix="ws")      # ws_read, ws_write, ...
SayouToolset(tool_prefix="")        # read, write, ... (no prefix)

Dependency Injection

Use from_deps when the workspace comes from your agent's dependency system:

from dataclasses import dataclass
from sayou.workspace import Workspace
from sayou_pydantic_ai import SayouToolset

@dataclass
class MyDeps:
    workspace: Workspace

agent = Agent(
    "openai:gpt-4o",
    deps_type=MyDeps,
    toolsets=[SayouToolset.from_deps(lambda d: d.workspace)],
)

Configuration

Database

By default, sayou uses SQLite at ~/.sayou/sayou.db. For production, point to MySQL or any SQLAlchemy-compatible database:

SayouToolset(database_url="mysql+aiomysql://user:pass@host/db")

Or set the environment variable:

export SAYOU_DATABASE_URL="mysql+aiomysql://user:pass@host/db"

Workspace identity

SayouToolset(
    workspace=Workspace(
        slug="my-project",
        org_id="my-org",
        user_id="agent-1",
    )
)

How It Works

SayouToolset implements Pydantic AI's AbstractToolset interface. When the agent runs:

  1. get_tools() returns tool definitions with JSON schemas
  2. The LLM sees tools like workspace_write(path, content) and calls them
  3. call_tool() dispatches to the corresponding Workspace method
  4. Results are returned to the LLM as strings

Files are stored with version history. Every write creates a new version — nothing is lost.

SayouMessageHistory uses sayou's built-in KV store to serialize/deserialize Pydantic AI's ModelMessage objects via TypeAdapter.

License

Apache 2.0

Metadata

Release files for sayou-pydantic-ai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sayou-pydantic-ai 0.1.0
File Size Uploaded
sayou_pydantic_ai-0.1.0.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sayou-pydantic-ai 0.1.0
File Interpreter ABI Platform
sayou_pydantic_ai-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.0 kB

Release files / sayou_pydantic_ai-0.1.0.tar.gz

Download URL sayou_pydantic_ai-0.1.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c5be3dcc649abee70b0f9f5a4f8e93a6321fb11bfd2a90689c116b5e9df049fe
BLAKE2b-256 checksum
How to use checksums
0d4b99f26449aada38c5b38d13125a86924abde1807e30f444635e9a7e3ed016
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0

Release files / sayou_pydantic_ai-0.1.0-py3-none-any.whl

Download URL sayou_pydantic_ai-0.1.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7364d877304177c6d7db05f805741c489726654f40cc020718442fb926e65a58
BLAKE2b-256 checksum
How to use checksums
b4f25b279fba478f84fd1e2155b8a7eac98d128e6640d167fbf1a4acfe5301a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page