Skip to main content
This guide covers advanced patterns for building production-ready AI applications with Slide. These patterns have been tested in real-world scenarios and represent best practices from the community.

Configuration Management

Configuration file pattern

Use YAML configuration files to manage agent settings, especially useful for:
  • Sharing configuration between CLI and Python code
  • Environment-specific configurations (dev, staging, prod)
  • Team collaboration (version control)
  • Quick experimentation without code changes
1

Create a Config File

Create agent-config.yaml:
2

Load Agent from Config

Use Agent.from_config() to create your agent:
3

Environment Variables

Keep secrets safe using environment variable substitution:
The ${VAR_NAME} syntax automatically substitutes values from your environment variables.
4

Custom Tools

Load custom tools from Python files:
Tool files should export a TOOLS list:

Advanced: Programmatic config manipulation

For maximum flexibility, load and modify configs before creating the agent:

Multi-environment pattern

Use different configs for different environments:
Or use environment variables in a single config:
See examples/003_agent_from_config.py for complete runnable examples and the Agent API reference for full documentation.

Agent Patterns

Tool selection pattern

Dynamically select tools based on the task:

Validation pattern

Ensure agent outputs meet requirements:

Persistence Patterns

Context window management

Manage long conversations efficiently:

Branching conversations

Support multiple conversation branches:

Tool patterns

Retry with Fallback

Implement robust tool execution:

Tool composition

Create complex tools from simple ones:

Streaming Patterns

Buffered Streaming

Optimize streaming for better UX:

Progress Tracking

Track progress for long-running operations:

Error handling patterns

Graceful Degradation

Handle errors without failing completely:

Production Patterns

Health Monitoring

Monitor agent health in production:

Next steps

Testing Patterns

Test these patterns

Performance

Optimize pattern performance

Examples

See patterns in action

API Reference

Complete API docs