Application framework for building AI agents with Pydantic AI - environment abstractions, session management, and hierarchical agent patterns
Project description
Ya Agent SDK
Yet Another Agent SDK
Yet Another Agent SDK for building AI agents with Pydantic AI. Used at my homelab for research and prototyping.
Key Features
- Environment-based Architecture: Protocol-based design for file operations, shell access, and resources. Built-in
LocalEnvironmentandSandboxEnvironment, easily extensible for custom backends (SSH, S3, cloud VMs, etc.) - Fully Typed: Complete type annotations validated with pyright (standard mode). Enjoy full IDE autocompletion and catch errors before runtime
- Resumable Sessions: Export and restore
AgentContextstate for multi-turn conversations across restarts - Hierarchical Agents: Subagent system with task delegation, tool inheritance, and markdown-based configuration
- Tool Search: Dynamic tool discovery for large tool libraries -- agents find and load only the tools they need, reducing context bloat by 85%+ while maintaining accuracy across hundreds of tools
- Skills System: Markdown-based instruction files with hot reload and progressive loading
- Human-in-the-Loop: Built-in approval workflows for sensitive tool operations
- Toolset Architecture: Extensible tool system with pre/post hooks for logging, validation, and error handling
- Event System: Lifecycle and sideband events for execution tracking, with streaming support for real-time monitoring
- Media Upload: Pluggable media upload (S3, custom backends) with automatic binary-to-URL conversion for images and videos
- Message Bus: Inter-agent communication with subscriber-based delivery, supporting multimodal content and user steering
- Resumable Resources: Export and restore resource states (like browser sessions) across process restarts
- Browser Automation: Docker-based headless Chrome sandbox for safe browser automation
- Streaming Support: Real-time streaming of agent responses and tool executions
Installation
# Recommended: install with all optional dependencies
pip install ya-agent-sdk[all]
uv add ya-agent-sdk[all]
# Or install individual extras as needed
pip install ya-agent-sdk[docker] # Docker sandbox support
pip install ya-agent-sdk[web] # Web tools (tavily, firecrawl, markitdown)
pip install ya-agent-sdk[document] # Document processing (pymupdf, markitdown)
pip install ya-agent-sdk[s3] # S3 media upload (boto3)
pip install ya-agent-sdk[tool-search] # Semantic tool search (fastembed)
Project Structure
This repository contains:
- ya_agent_sdk/ - Core SDK with environment abstraction, toolsets, and session management
- yaacli/ - Reference CLI implementation with TUI for interactive agent sessions
- examples/ - Code examples demonstrating SDK features
- docs/ - Documentation for SDK architecture and APIs
Quick Start
Using the SDK
from ya_agent_sdk.agents import create_agent, stream_agent
# create_agent returns AgentRuntime (not a context manager)
runtime = create_agent("openai:gpt-4o")
# stream_agent manages runtime lifecycle automatically
async with stream_agent(runtime, "Hello") as streamer:
async for event in streamer:
print(event)
Using YAACLI CLI
For a ready-to-use terminal interface, try yaacli - a TUI reference implementation built on top of ya-agent-sdk:
# Run directly with uvx (no installation needed)
uvx yaacli
# Or install globally
uv tool install yaacli
pip install yaacli
Features:
- Rich terminal UI with syntax highlighting and streaming output
- Built-in tool approval workflows (human-in-the-loop)
- Session management with conversation history
- Browser automation support via Docker sandbox
- MCP (Model Context Protocol) server integration
Examples
Check out the examples/ directory:
| Example | Description |
|---|---|
| general.py | Complete pattern with streaming, HITL approval, and session persistence |
| deepresearch.py | Autonomous research agent with web search and content extraction |
| browser_use.py | Browser automation with Docker-based headless Chrome sandbox |
For Agent Users
If you're using an AI agent (e.g., Claude, Cursor) that supports skills:
- Clone this repo: The SKILL.md file in the repository root provides comprehensive guidance for agents
- Download release package: Get the latest
SKILL.zipfrom the Releases page (automatically built during each release)
Configuration
Copy examples/.env.example to examples/.env and configure your API keys.
Documentation
- AgentContext & Sessions - Session state, resumable sessions, extending context
- Streaming & Hooks - Real-time streaming, lifecycle hooks, event handling
- Events - Lifecycle events, sideband events, event correlation, custom events
- Toolset Architecture - Create tools, use hooks, handle errors, extend Toolset
- Tool Search - Dynamic tool discovery with keyword and embedding search strategies
- Subagent System - Hierarchical agents, builtin presets, markdown configuration
- Skills System - Markdown-based skills, hot reload, pre-scan hooks
- Message Bus - Inter-agent communication, multimodal messages, user steering
- Media Upload - S3 media upload, custom backends, history filter integration
- Custom Environments - Environment lifecycle, resource management
- Resumable Resources - Export and restore resource states across restarts
- Model Configuration - Provider setup, gateway mode
- Logging Configuration - Configure SDK logging levels
Development
See CONTRIBUTING.md for development setup and guidelines.
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 ya_agent_sdk-0.52.1.tar.gz.
File metadata
- Download URL: ya_agent_sdk-0.52.1.tar.gz
- Upload date:
- Size: 853.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd089efe1b1465db50470e296e0eb1cf56a4bccf30e1254a263175da7748ebad
|
|
| MD5 |
0f94088bae53311bee88565fa68876c0
|
|
| BLAKE2b-256 |
c378ba4a426f8bef6f4718160a1960bec1c8247979f123ac58c476b410ebdc2b
|
File details
Details for the file ya_agent_sdk-0.52.1-py3-none-any.whl.
File metadata
- Download URL: ya_agent_sdk-0.52.1-py3-none-any.whl
- Upload date:
- Size: 313.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60fb8e31722ce3e264fb2621c469d2503db485ed4ebf67d39a30585599ac9eae
|
|
| MD5 |
86d55f485b473cdb6658957bc7694fa9
|
|
| BLAKE2b-256 |
88adac056c184503ad54dea2c46ff4691127b4f32fa4cca56f308b4f97ca167f
|