Skip to main content

Overview

Canvas provides a persistent text document system that integrates seamlessly with Agent. When you pass a Canvas to an Agent, the agent automatically receives tools to read and edit the canvas, enabling intelligent document management through natural language tasks. How it works:
  • Create a Canvas with a name (documents persist as .txt files)
  • Pass the Canvas to Agent during initialization via the canvas parameter
  • The Agent automatically registers canvas tools (get_current_state_of_canvas and change_in_canvas)
  • During task execution, the agent can intelligently read, update, and organize canvas content
  • Canvas content is automatically cleaned (code blocks removed) and persisted to disk

Quick Start

Basic Canvas Integration

from upsonic import Canvas, Agent, Task

# Create canvas and pass it to agent
canvas = Canvas("My Project Notes")
agent = Agent("openai/gpt-4o", canvas=canvas)

# Agent automatically has access to canvas tools
task = Task("Add a project overview section to the canvas")
result = agent.do(task)

Meeting Notes Example

from upsonic import Canvas, Agent, Task

# Create canvas-enabled agent
canvas = Canvas("Meeting Notes")
agent = Agent("openai/gpt-4o", canvas=canvas)

# Agent can create and organize meeting notes
task = Task("""
Create comprehensive meeting notes for our weekly team standup including:
- Attendees and their roles
- Key discussion points
- Action items with owners
- Next meeting agenda
""")

result = agent.do(task)
# Agent automatically updates the canvas during execution

Configuration Guide

Canvas with Custom Model

from upsonic import Canvas, Agent, Task

# Canvas can use a different model for editing operations
canvas = Canvas("Technical Notes", model="openai/gpt-4o-mini")
agent = Agent("openai/gpt-4o", canvas=canvas)

task = Task("Create a project summary document")
result = agent.do(task)

Real-World Examples

Document Updates

from upsonic import Canvas, Agent, Task

canvas = Canvas("Project Documentation")
agent = Agent("openai/gpt-4o", canvas=canvas)

# Agent can review and update existing canvas content
task = Task("""
Review and update the project documentation with:
- Latest technical specifications
- Updated API endpoints
- New deployment procedures
- Security best practices
""")

result = agent.do(task)

Technical Documentation

from upsonic import Canvas, Agent, Task

canvas = Canvas("API Documentation")
agent = Agent("openai/gpt-4o", canvas=canvas)

task = Task("""
Create comprehensive API documentation for our user management endpoints:
- Authentication methods
- Request/response examples
- Error handling
- Rate limiting
""")

result = agent.do(task)

Tips and Best Practices

  • Use descriptive canvas names - “Project Documentation” vs “Doc1”
  • Let the agent organize content - The agent intelligently places and updates sections
  • Canvas persists automatically - Documents are saved as .txt files in your working directory
  • Agent handles formatting - Code blocks and formatting are automatically cleaned