Skip to main content

Creating Scaffolds

Learn how to build custom scaffolds that extend your agent with persistent memory, tools, and reactive capabilities.

Basic Scaffold Structure

Every scaffold inherits from BaseContextScaffold:
Minimum requirements:
  • Inherit from BaseContextScaffold
  • Set unique scaffold_type
  • Implement render() method

Adding State

Use Pydantic models for type-safe state:

Adding Operations

Expose methods as agent tools with @operation:

Complete Example: Todo Scaffold

Reactive Rendering

Scaffolds re-render automatically on context changes:

Initialization and Setup

Override __init__ for custom setup:

Accessing Agent Properties

Scaffolds have full access to the agent:

TTL and Component Lifecycle

Control when scaffold content expires:

Error Handling

Graceful error handling in operations:

Best Practices

Operations become tools - docstrings are shown to the agent:
Use Pydantic validators:
Avoid expensive operations in render:
Nested Pydantic models for structure:

Testing Scaffolds

Advanced Patterns

State Synchronization

Conditional Rendering

Multi-Component Rendering

What’s Next?

Scaffold IPC

Learn scaffold communication patterns

Built-in Scaffolds

Explore InternalNotes, FileManager, Shell

Operation Decorator

Complete @operation documentation

Scaffolds API

Full BaseContextScaffold API reference