# StackAI Computer

StackAI Computer is a built-in tool provider that gives your AI workflows direct access to isolated sandbox environments. It bridges the gap between language model reasoning and real-world computation by enabling your agents to run shell commands, execute scripts, navigate the web, and produce files.

StackAI Computer surfaces two distinct execution environments, each designed for a different class of task:

* Code Interpreter (terminal sandbox): A Linux environment with a pre-installed suite of data-processing libraries.&#x20;
* Desktop (browser sandbox): A full desktop environment running a real browser, controlled by an AI agent.&#x20;

The two sandbox types are fully isolated from each other and never share state.<br>

## Available Actions

### **1. Terminal Tool**

The Terminal tool allows you to execute shell commands in a secure and isolated sandbox environment. You can use it to install packages, process files, run scripts, and create output files that downstream nodes can use.

Terminal works the best when it is used as a [tool within the AI Agent node](https://docs.stackai.com/workflow-builder/llms/llm-node/tools), so that the large language models can run commands automatically.

<figure><img src="https://3697023207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFSlso1Kjob5CLDrh0dVn%2Fuploads%2FhiEFYER8Q2eoA33Fcv8l%2FTerminal%20tool.gif?alt=media&#x26;token=588cabbd-7fb2-4375-a453-770bfe2427d1" alt=""><figcaption></figcaption></figure>

#### **Inputs**

<table data-full-width="true"><thead><tr><th width="122.984375">Name</th><th width="556.01171875">Descriptions</th><th>Required</th></tr></thead><tbody><tr><td>Command</td><td>The shell command to execute. Supports bash, Python one-liners, piped commands, and multi-step chains with <code>&#x26;&#x26;</code>. </td><td>Yes</td></tr><tr><td>Description</td><td>A short (2–5 word) label describing the intent of this command. Shown in the UI during execution (e.g., "Parsing CSV data").</td><td>No</td></tr><tr><td>Terminal Sandbox ID</td><td>When left blank, each new session will have a randomly generated ID.<br><br>You can also pass in the ID of an existing sandbox session to reuse the environment. </td><td>No</td></tr><tr><td>Enable New Files</td><td><p><code>Enable New Files</code> is enabled by default. </p><p></p><p>When enabled, new files created during execution can be downloaded and accessed by downstream nodes.</p></td><td>No</td></tr></tbody></table>

#### Outputs

<table data-full-width="true"><thead><tr><th width="188.4609375">Parameter</th><th width="116.359375">Type</th><th width="471.8671875">Description</th></tr></thead><tbody><tr><td><code>stdout</code></td><td>string</td><td>Standard output from the command.</td></tr><tr><td><code>stderr</code></td><td>string</td><td>Standard error output from the command.</td></tr><tr><td><code>exit_code</code></td><td>integer</td><td>The exit code returned by the command. <code>0</code> indicates success; any non-zero value indicates failure.</td></tr><tr><td><code>success</code></td><td>boolean</td><td><code>true</code> if <code>exit_code</code> is <code>0</code>.</td></tr><tr><td><code>terminal_sandbox_id</code></td><td>string</td><td>The ID of the sandbox session used for this execution. </td></tr><tr><td><code>new_files</code></td><td>array</td><td>List of files created during execution. Each entry includes <code>name</code>, <code>path</code>, <code>size_bytes</code>, and a <code>download_url</code> (a signed URL ready for immediate use).</td></tr><tr><td><code>image_data</code></td><td>array</td><td>Base64-encoded image data for any image files created during execution, enabling direct visual analysis by the AI.</td></tr></tbody></table>

#### Session Persistence

The `terminal_sandbox_id` lets you chain multiple Terminal nodes together within the same isolated environment. This is useful when you need to:

* Install a package in one step and use it in the next
* Build up data or files incrementally across multiple commands
* Share intermediate results between nodes without writing to external storage

#### Working with Files

**Workflow Files**

Workflow files (e.g. files uploaded through the Files node) are available at `/home/user/` at the start of each session.

Since the Terminal tool runs in a sandbox, it will not have access to local files on the computer.

**Output Files**

When `Enable New Files` is enabled, files created during the session will be automatically saved to `/home/user/` . The signed download URLs of these files are returned in the output parameter `new_files`.

**Knowledge Base Files**

Terminal Tool can access files in the knowledge base. When an AI Agent node has both Terminal Tool and Knowledge Base, you will see an option to enable File Access for the Terminal Tool.

<div align="left"><figure><img src="https://3697023207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFSlso1Kjob5CLDrh0dVn%2Fuploads%2FP7LF4pqQaKOXDzEr7b8V%2Fimage.png?alt=media&#x26;token=01d4d3d8-0301-44b5-a7ef-36c945471f00" alt="" width="375"><figcaption></figcaption></figure></div>

While Search KB Tool is best as finding relevant content semantically, the Terminal tool is better for processing and transforming the files. The Terminal tool lets you:

* **Work with the original file**: parse a spreadsheet, extract specific pages from a PDF, run OCR on an image, etc.
* **Run actions beyond searching**: aggregate across an entire file, run computations, reformat data, extract structured output (JSON, CSV) from unstructured documents
* **Handle file formats that don't chunk well**: large Excel files, ZIP archives, binary formats, multi-sheet workbooks
* **Chain processing steps**: download a file, transform it, and write the result back to `/home/user/` so downstream nodes get the processed version

### 2. Canvas

Canvas is a built-in document workspace that lives alongside your chat. When an agent creates a file, like a report, a draft, or a structured document, it automatically appears in Canvas on the right side of the chat interface so you can read, edit, and download it without leaving the conversation.

<figure><img src="https://3697023207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFSlso1Kjob5CLDrh0dVn%2Fuploads%2FdqYkYoqF9UvJcCIPAMVF%2FCanvas.gif?alt=media&#x26;token=b4a2aa1c-b326-4e69-9997-4f4efa02d62a" alt=""><figcaption></figcaption></figure>

#### Enabling Canvas

To use Canvas in your workflow, you need to add two tools to your **AI Agent node**:

1. **Terminal:** allows the AI to run code in a secure sandbox environment
2. **Canvas Share File:** allows the AI to send files generated in the sandbox to the Canvas panel

Once both tools are added to the AI Agent node, the AI can create and share files directly to Canvas during a conversation. You don't need to explicitly instruct the model to use these tools, it automatically detects their presence and will use them whenever you ask it to generate a document.

#### **Chat Interface Setup**

Canvas requires restricting access to the chat interface by email or group. This is configured in the **Security** section of the interface settings — specifically under the **Enable SSO Protection** toggle. You do not need SSO set up at the organization level; the toggle simply unlocks access control for the interface.

To enable it, open your workflow and navigate to the **Interface** tab. Scroll down to the **Security** section and toggle **Enable SSO Protection** on. An access control dialog will appear — use the **Select users and groups** dropdown to add the individuals or groups who should have access. Your own email is included by default. Remember to **save and publish** the interface after making any changes.

#### Recommended Models

Canvas works best with capable frontier models that can reliably generate well-structured documents. We recommend using models from the **GPT-5 family** (OpenAI) or the **Claude 4.6 family** (Anthropic), as these models produce high-quality output and handle document formatting consistently.

#### Opening a File

When the agent generates a file, it automatically opens in the Canvas on the right side of the page. A file card with the filename and a short description also appears in the chat. If needed, you can click it to reopen the file in the Canvas.

The panel opens automatically the first time a file is created in a conversation.

#### Editing Documents

Canvas supports live editing for **Markdown** files. Click anywhere in the document to start typing. The editor supports:

* Headings (H1, H2, H3)
* Ordered and unordered lists
* Tables
* Code blocks
* Blockquotes
* Links and images

Changes are saved automatically after a short pause. The save status icon in the top-right corner of the panel shows whether your changes are synced:

| Icon             | Meaning            |
| ---------------- | ------------------ |
| Spinning loader  | Saving in progress |
| Dashed circle    | Unsaved changes    |
| Warning triangle | Sync error         |
| Hidden           | All changes saved  |

#### Version History

Canvas records a new version once per conversation turn. If the model updates a file, that creates a version.&#x20;

<figure><img src="https://3697023207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFSlso1Kjob5CLDrh0dVn%2Fuploads%2Fca82a44Mv8eKZOGdxvz3%2FClipboard-20260324-182624-106.gif?alt=media&#x26;token=ae739332-983e-48a4-a449-04628833e530" alt=""><figcaption></figcaption></figure>

If you then edit that file, another version is created. However, if you continue editing within the same turn, your changes overwrite the previous edit rather than creating additional versions. To browse the history:

1. Click the history icon in the Canvas toolbar
2. A dropdown shows each version with its timestamp and authorship (Human or AI)
3. Click any version to preview it in read-only mode
4. Click **Back to latest** to return to the current version

#### **Annotating and Asking the Model to Apply Edits**

Canvas supports a collaborative editing loop between you and the LLM. Instead of describing every change in the chat, you can annotate the document directly and then ask the model to act on your notes.

<figure><img src="https://3697023207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFSlso1Kjob5CLDrh0dVn%2Fuploads%2FPp1QnWMt8DVQn3VlUTnp%2Fannotation%20edits.gif?alt=media&#x26;token=4606e556-c0f3-4497-8c84-a9086d442c98" alt=""><figcaption></figcaption></figure>

To use this workflow:

1. Open the document in Canvas and click anywhere to start editing
2. Leave your comments, corrections, or instructions inline — for example, rewrite this section, add a table here, or make this more concise
3. Go back to the chat and ask the model to go over your edits, for example: *"I've left some notes in the document — can you go through them and apply the changes?"*
4. The model will read the current state of the document, process your annotations, and update the file in Canvas with a new version

This is useful when you want to guide the output without rewriting things yourself — you annotate, the model finishes.

{% hint style="info" %}
You can mix inline edits with chat instructions. For example, fix a paragraph directly yourself and leave a note for the model on another section — the model will only act on what you explicitly ask it to.
{% endhint %}

#### Downloading Files

Click the **Download** button to save the current file to your computer. The button is disabled while there are unsaved changes, wait for the save indicator to clear before downloading.

You can also download a specific historical version by navigating to it first and then downloading.

#### Supported File Types

| Type             | View | Edit |
| ---------------- | ---- | ---- |
| Markdown (`.md`) | Yes  | Yes  |
| HTML (`.html`)   | Yes  | No   |

#### File Scope

Files in Canvas are scoped to a specific conversation and are only accessible to the user who created them. Each conversation has its own isolated workspace, so files from one chat won't appear in another.

#### Downloading in Other Formats

The Download button currently exports files in their original format only (`.md` or `.html`). If you need the document in a different format, such as PDF, DOCX, Excel, or others, ask the AI directly in the chat. For example:

* *"Can you export this as a PDF?"*
* *"Convert this document to a Word file."*
* *"Save this as an Excel spreadsheet."*

The AI will generate the file in the requested format and share it to Canvas for download.

#### **Version History**

Canvas records a new version once per conversation turn. If the model updates a file, that creates a version.

If you then edit that file, another version is created. However, if you continue editing within the same turn, your changes overwrite the previous edit rather than creating additional versions. To browse the history:

1. Click the history icon in the Canvas toolbar
2. A dropdown shows each version with its timestamp and authorship (Human or AI)
3. Click any version to preview it in read-only mode
4. Click **Back to latest** to return to the current version

#### Content Writer Template

This documentation page covers the core setup and usage of Canvas. For a more complete, end-to-end example, explore the **Content Writer** agent template available in Stack AI.

The Content Writer template is a pre-built AI agent configured with a structured system prompt designed to produce well-formatted reports and written documents. It demonstrates best practices for using Canvas in a real workflow:

* How to craft a system prompt that instructs the AI to always output results as a Canvas file
* How to structure the agent so it consistently produces clean, well-organized Markdown documents
* How to combine the **Terminal** and **Canvas Share File** tools to automate document generation end-to-end

To try it, open the **Templates** section in Stack AI and search for "Content Writer". You can use it as-is or customize the system prompt to match your own use case.

<figure><img src="https://3697023207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFSlso1Kjob5CLDrh0dVn%2Fuploads%2FzKXh8OA1L9pDS5pX2YFL%2FContent%20Writer%20Agent.gif?alt=media&#x26;token=8c4184ac-06b3-4810-9593-c0fb4ed2f61d" alt=""><figcaption></figcaption></figure>
