Development Guide
Section titled “Development Guide”Guide for contributing to and developing YouLab.
Prerequisites
Section titled “Prerequisites”- Python 3.11+
- uv package manager
- Running Letta server (for integration testing)
Initial Setup
Section titled “Initial Setup”# Clone the repositorygit clone <repo-url>cd YouLab
# Run setup (installs deps + pre-commit hooks)make setupThis installs:
- All project dependencies
- Development tools (pytest, ruff, basedpyright)
- Pre-commit hooks for automatic verification
Project Structure
Section titled “Project Structure”src/youlab_server/├── agents/ # BaseAgent, templates, registry├── memory/ # Memory blocks and strategies├── pipelines/ # OpenWebUI Pipe integration├── server/ # FastAPI HTTP service│ └── strategy/ # Strategy agent endpoints├── observability/ # Logging and tracing├── config/ # Settings management└── main.py # CLI entry point
tests/├── conftest.py # Shared fixtures├── test_memory.py # Memory block tests├── test_templates.py # Agent template tests├── test_pipe.py # Pipeline tests└── test_server/ # HTTP service tests ├── test_endpoints.py ├── test_agents.py └── test_strategy/Development Workflow
Section titled “Development Workflow”1. Make Changes
Section titled “1. Make Changes”Edit files in src/youlab_server/.
2. Run Lint Fix Frequently
Section titled “2. Run Lint Fix Frequently”make lint-fixImportant: Run this after every file edit to catch issues early.
3. Verify Before Commit
Section titled “3. Verify Before Commit”# Quick check (lint + typecheck)make check-agent
# Full verification (lint + typecheck + tests)make verify-agent4. Pre-commit Hooks
Section titled “4. Pre-commit Hooks”Commits are automatically blocked if checks fail. The hooks run make verify before each commit.
Agent-Optimized Commands
Section titled “Agent-Optimized Commands”YouLab uses the “swallow success, show failure” pattern from HumanLayer:
| Command | What It Does |
|---|---|
make check-agent | Lint + typecheck with minimal output |
make test-agent | Tests only, fail-fast |
make verify-agent | Full verification suite |
On success: Minimal output like ✓ Ruff check, ✓ Typecheck
On failure: Full error output for debugging
Adding New Features
Section titled “Adding New Features”Adding a New Agent Template
Section titled “Adding a New Agent Template”- Define the template in
agents/templates.py:
MY_TEMPLATE = AgentTemplate( type_id="my-agent", display_name="My Agent", description="What this agent does", persona=PersonaBlock( name="MyAgent", role="Specific role", capabilities=["Capability 1", "Capability 2"], tone="professional", verbosity="concise", ),)- Register in the registry:
# In agents/default.py or where registry is configuredfrom youlab_server.agents.templates import MY_TEMPLATE
registry.register(MY_TEMPLATE)- Add tests in
tests/test_templates.py.
Adding a New API Endpoint
Section titled “Adding a New API Endpoint”- Add schema in
server/schemas.py:
class MyRequest(BaseModel): field: str
class MyResponse(BaseModel): result: str- Add endpoint in
server/main.py:
@app.post("/my-endpoint", response_model=MyResponse)async def my_endpoint(request: MyRequest) -> MyResponse: # Implementation return MyResponse(result="...")- Add tests in
tests/test_server/test_endpoints.py.
Adding Memory Block Fields
Section titled “Adding Memory Block Fields”- Extend block in
memory/blocks.py:
class HumanBlock(BaseModel): # Existing fields... new_field: str | None = None-
Update
to_memory_string()serialization. -
Add tests in
tests/test_memory.py.
Configuration for Development
Section titled “Configuration for Development”Create a .env file:
cp .env.example .envMinimum configuration:
# RequiredANTHROPIC_API_KEY=your-key
# Letta connectionLETTA_BASE_URL=http://localhost:8283
# Service settings (optional)YOULAB_SERVICE_HOST=127.0.0.1YOULAB_SERVICE_PORT=8100Running Services
Section titled “Running Services”Start Letta Server
Section titled “Start Letta Server”pip install lettaletta serverStart HTTP Service
Section titled “Start HTTP Service”uv run youlab-serverInteractive CLI
Section titled “Interactive CLI”uv run youlabDebugging
Section titled “Debugging”Enable Debug Logging
Section titled “Enable Debug Logging”LOG_LEVEL=debugView Traces in Langfuse
Section titled “View Traces in Langfuse”- Set Langfuse credentials in
.env - Visit your Langfuse dashboard
- Filter by
user_idoragent_id
Common Issues
Section titled “Common Issues”| Issue | Solution |
|---|---|
Letta connection failed | Ensure letta server is running |
Type errors | Run make typecheck for details |
Import errors | Run uv sync to update deps |
Code Style
Section titled “Code Style”General Principles
Section titled “General Principles”- Use type annotations everywhere
- Prefer composition over inheritance
- Keep functions focused and small
- Document non-obvious behavior
Naming Conventions
Section titled “Naming Conventions”| Type | Convention | Example |
|---|---|---|
| Classes | PascalCase | AgentManager |
| Functions | snake_case | get_agent |
| Constants | UPPER_SNAKE | DEFAULT_PORT |
| Private | _prefix | _cache |
Imports
Section titled “Imports”Organized by ruff:
- Standard library
- Third-party
- First-party (
youlab_server)
Related Pages
Section titled “Related Pages”- Testing - Test suite documentation
- Tooling - Development tools
- Configuration - Environment variables