packages/computeruse/crates/computeruse-mcp-agent/docs/WORKFLOW_OUTPUT_STRUCTURE.md
This document describes the expected output structure for ComputerUse workflows to properly integrate with the CLI and backend systems.
ComputerUse workflows return structured data that allows the CLI and backend to:
When a workflow is executed via execute_sequence, it returns the following structure:
{
"status": "success | partial_success | error",
"results": [...],
"executed_tools": 5,
"total_duration_ms": 1234,
"output": { ... } // Optional, if output parser is defined
}
status (string): The execution-level status
"success": All steps executed successfully"partial_success": Some steps failed but execution continued"error": Critical failure that stopped executionresults (array): Array of individual step results
executed_tools (number): Count of steps that were executed
total_duration_ms (number): Total execution time in milliseconds
output (object): Optional structured data from the output parser
The output field is generated by the workflow's output parser (JavaScript code) and should follow this structure for optimal CLI rendering:
{
"success": true,
"state": "success | failure | skipped",
"message": "Human-readable message about the result",
"data": { ... } | [...],
"error": "Error details if failed",
"validation": { ... },
"skipped": false
}
success (boolean): Whether the workflow achieved its business goal
true: The workflow successfully completed its intended taskfalse: The workflow failed to achieve its goal (even if technically executed)message (string): Human-readable description of the result
state (string): Explicit workflow state
"success": Business goal achieved"failure": Business goal not achieved"skipped": Workflow skipped due to conditionsdata (any): The extracted/processed data
error (string): Detailed error information
success: falsevalidation (object): Additional validation information
skipped (boolean): Whether the workflow was skipped
The CLI interprets workflow states as follows:
| State | Success | Message | Icon | Color |
|---|---|---|---|---|
| Success | true | Custom or default | ✅ | Green |
| Failure | false | Custom or default | ❌ | Red |
| Skipped | false + skipped: true | Custom or default | ⏭️ | Yellow |
// Output parser code
const items = tree.findAll('[data-testid="invoice"]');
return {
success: items.length > 0,
message: `Found ${items.length} invoices`,
data: items.map(item => ({
id: item.getAttribute('data-id'),
amount: item.querySelector('.amount')?.text,
date: item.querySelector('.date')?.text
}))
};
// Output parser code
const loginForm = tree.find('#login-form');
const errorMsg = tree.find('.error-message');
return {
success: false,
message: errorMsg?.text || "Login failed",
error: "Invalid credentials provided",
validation: {
usernameField: !!tree.find('#username'),
passwordField: !!tree.find('#password'),
errorDisplayed: !!errorMsg
}
};
// Output parser code
const prerequisite = tree.find('.required-element');
if (!prerequisite) {
return {
success: false,
skipped: true,
message: "Workflow skipped - required element not found",
data: null
};
}
// Continue with normal processing...
// Output parser code (no UI tree, processing API response)
const response = sequenceResult.results?.[0]?.result;
if (response?.status === 200) {
return {
success: true,
message: `Retrieved ${response.data.length} records`,
data: response.data
};
} else {
return {
success: false,
message: "API request failed",
error: response?.error || "Unknown error",
data: null
};
}
To ensure your workflow output is properly structured:
success and messagesuccess accurately reflects business logic successsuccess: true, include meaningful datasuccess: false, include helpful error details// Good practice: Ensure data types
return {
success: Boolean(items.length > 0), // Ensure boolean
message: String(statusText), // Ensure string
data: items || [] // Provide default
};
The ComputerUse CLI (computeruse command) uses this structure to:
data field for user reviewBackend systems can use this structure to:
Planned improvements to the output structure: