Overview

Agents working on text-based tasks are highly prone to rewriting the text unnecessarily, editing parts that shouldn’t be modified, and introducing errors. This creates a process where developers must manually make adjustments and continuously implement checkpoints, especially when handling text-based use cases.

Within the Upsonic framework, we have a Canvas feature specifically designed to address this issue and provide a direct solution. This feature includes specialized and sensitive functions tailored for creating and editing a text canvas.

Creating an Canvas

A Canvas is created with a specific name and can be assigned to a Task or class as a tool. This enables Agents or Direct operations to easily perform text edits.

from upsonic import Canvas

my_travel_guide_canvas = Canvas("Travel Guide") # Creating an canvas with an uniqe name

Putting Canvas to Agent

You can add them directly as elements within the canvas parameter of a Agent, configuring your task to utilize this Canvas.

from upsonic import Agent
from upsonic import Canvas

my_travel_guide_canvas = Canvas("Travel Guide") # Creating an canvas with an uniqe name

agent = Agent(
	name="My Travel Agent",
	canvas=my_travel_guide_canvas # Adding canvas
)

Running the canvas

Once your tasks are executed by the agent, the canvas retains all modifications in a consistent state. This enables you to query or display the final version of the text after all edits have been applied. By decoupling text state from the agent logic, you gain better control over the output, making it easier to debug, review, or pass the final content into downstream systems like editors, emails, or publishing pipelines.

from upsonic import Task, Agent, Canvas


# My Agent with Canvas
my_travel_guide_canvas = Canvas("Travel Guide") # Creating an canvas with an uniqe name
agent = Agent(
	name="My Travel Agent",
	canvas=my_travel_guide_canvas # Adding canvas
)


# My Tasks
task = Task("Generate a plan to visit cities in Canad")
task2 = Task("Edit the canvas first section with Hi guys")

# Completing my Tasks
agent.do(task)
agent.do(task2)


# Getting canvas final state
print(my_travel_guide_canvas.get_current_state_of_canvas())