Skip to main content

YAML-Letta

Tests Python 3.8+ License: MIT

YAML-driven agent configuration for Letta. Define your Letta agents using simple YAML files and create them with a single function call.

Installation

pip install yaml-letta

Quick Start

1. Define your agent in YAML

Create a file my_agent.yaml:

agent:
  name: "customer_support_agent"
  persona: "You are a helpful customer support representative."
  
  memory:
    human_name: "Customer"
    persona_name: "SupportBot"
  
  tools:
    - name: "search_knowledge_base"
      description: "Search internal knowledge base"
  
  llm:
    model: "openai/gpt-4.1"
    temperature: 0.7

2. Create the agent

import yaml_letta

# Simple one-liner (no custom tools)
agent = yaml_letta.create_agent_from_yaml("my_agent.yaml")

# With custom tools
builder = yaml_letta.create_builder()

def search_knowledge_base(query: str) -> str:
    return f"Search results for: {query}"

builder.register_tool("search_knowledge_base", search_knowledge_base)
agent = builder.build_from_file("my_agent.yaml")

Features

  • Simple YAML Configuration: Define agents declaratively
  • Tool Integration: Register Python functions as agent tools
  • Validation: Automatic validation of configurations
  • Letta Cloud & Self-hosted: Works with both Letta Cloud and self-hosted servers
  • Type Safety: Full type hints and validation with Pydantic

Configuration Reference

Agent Configuration

agent:
  name: "agent_name"              # Required: Agent identifier
  description: "Agent description" # Optional: Human-readable description
  persona: "Agent personality"     # Required: Agent's persona/system prompt
  
  memory:                         # Optional: Memory configuration
    human_name: "Human"           # Default: "Human"
    persona_name: "Assistant"     # Default: "Assistant"
    limit: 2000                   # Default: 2000
  
  tools:                          # Optional: List of tools
    - name: "tool_name"
      description: "Tool description"
      parameters:                 # Optional: Parameter definitions
        param_name:
          type: "string"
          description: "Parameter description"
          enum: ["option1", "option2"]  # Optional: Allowed values
  
  llm:                           # Optional: LLM configuration
    model: "openai/gpt-4.1"      # Default: "openai/gpt-4.1"
    temperature: 0.7             # Default: 0.7
    max_tokens: 1000             # Optional
  
  metadata:                      # Optional: Custom metadata
    version: "1.0"
    team: "engineering"

API Reference

Main Functions

# Simple agent creation
yaml_letta.create_agent_from_yaml(yaml_file, token=None, base_url=None)

# Advanced usage with tools
builder = yaml_letta.create_builder(token=None, base_url=None)
builder.register_tool(name, function)
agent = builder.build_from_file(yaml_file)

Connection Options

# Letta Cloud
agent = yaml_letta.create_agent_from_yaml("agent.yaml", token="your_api_key")

# Self-hosted Letta server
agent = yaml_letta.create_agent_from_yaml("agent.yaml", base_url="http://localhost:8283")

Examples

Basic Agent

import yaml_letta

# Create agent from YAML
agent = yaml_letta.create_agent_from_yaml("basic_agent.yaml")
print(f"Created agent: {agent.id}")

Agent with Custom Tools

import yaml_letta

# Create builder
builder = yaml_letta.create_builder()

# Define tools
def search_docs(query: str) -> str:
    """Search documentation for relevant information."""
    return f"Documentation results for: {query}"

def send_email(to: str, subject: str, body: str) -> str:
    """Send an email to the specified recipient."""
    return f"Email sent to {to} with subject: {subject}"

# Register tools
builder.register_tool("search_docs", search_docs)
builder.register_tool("send_email", send_email)

# Build agent
agent = builder.build_from_file("agent_with_tools.yaml")

# Interact with agent
response = builder.send_message(agent.id, "Help me find documentation about APIs")
print(response)

Configuration from Dictionary

import yaml_letta

config = {
    "agent": {
        "name": "my_agent",
        "persona": "You are a helpful assistant.",
        "llm": {"model": "openai/gpt-4.1"}
    }
}

builder = yaml_letta.create_builder()
agent = builder.build_from_dict(config)

Error Handling

The library provides detailed error messages for common issues:

try:
    agent = yaml_letta.create_agent_from_yaml("invalid.yaml")
except FileNotFoundError:
    print("YAML file not found")
except ValueError as e:
    print(f"Configuration error: {e}")
except RuntimeError as e:
    print(f"Agent creation failed: {e}")

Testing

# Run all tests
make test

# Interactive development shell
make test-interactive

# Clean up Docker resources
make clean

Local Testing

# Install test dependencies
pip install -r test-requirements.txt

# Run tests
pytest tests/ -v

Contributing

Contributions are welcome! Please read our Contributing Guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

  • Letta - The stateful agents framework
  • PraisonAI - Inspiration for YAML-driven agent configuration

Metadata

Release files for yaml-letta 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 yaml-letta 0.1.0
File Size Uploaded Provenance Actions
yaml_letta-0.1.0.tar.gz 16.0 kB Without provenance Details for yaml_letta-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yaml-letta 0.1.0
File Interpreter ABI Platform Actions
yaml_letta-0.1.0-py3-none-any.whl Python 3 none any Details for yaml_letta-0.1.0-py3-none-any.whl

Total release size: 25.3 kB

Release files / yaml_letta-0.1.0.tar.gz

Download URL yaml_letta-0.1.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ff0cc9333c5b41671412d1e6f13c73fe689b588e4f37e17539423c88f677abc7
BLAKE2b-256 checksum
How to use checksums
5431043798cefaa23a3ca9d4cbf617704a0c5cccfe1420249c46213d35087549
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

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

Download URL yaml_letta-0.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1008e3cc51db5e5bbd04bb6b278b5b76e4c2d7cef746d250afb5bd0761134d39
BLAKE2b-256 checksum
How to use checksums
c82c47a3c1eb9d77741940745edf51f7889c216d7e91c1e5b628eb043e13a886
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for yaml-letta 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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