Skip to main content
Glama

rollback

Destructive

Roll back completed steps of a workflow in reverse order, skipping irreversible steps, and set the workflow state to 'failed'.

Instructions

[WRITE] Abort a workflow and rollback completed steps in reverse order.

Works in any state except 'completed'. Irreversible steps are skipped. The workflow state is set to 'failed' after rollback.

Args: workflow_id: The workflow ID to rollback.

Returns: Rollback results for each step.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflow_idYes

Implementation Reference

  • WorkflowExecutor.rollback() — the core rollback logic: sets state to ROLLING_BACK, iterates completed steps in reverse, dispatches each step's rollback_tool with rollback_params, collects results, and sets state to FAILED.
    def rollback(self, wf: Workflow) -> dict[str, Any]:
        """Rollback completed steps in reverse order."""
        wf.state = WorkflowState.ROLLING_BACK
        wf.log("rollback_started")
        self._store.save(wf)
    
        rollback_results = []
        for step in reversed(wf.completed_steps()):
            if not step.rollback_tool:
                rollback_results.append({
                    "step": step.index,
                    "tool": step.tool,
                    "status": "skipped",
                    "reason": "no rollback defined",
                })
                continue
    
            try:
                resolved_rb = self._resolve_step_refs(step.rollback_params, wf.steps)
                result = self._dispatch(step.skill, step.rollback_tool, resolved_rb)
                step.status = "rolled_back"
                rollback_results.append({
                    "step": step.index,
                    "tool": step.rollback_tool,
                    "status": "success",
                    "result": result,
                })
                wf.log("rollback_step", f"Step {step.index}: {step.rollback_tool} → success")
            except Exception as exc:
                rollback_results.append({
                    "step": step.index,
                    "tool": step.rollback_tool,
                    "status": "failed",
                    "error": str(exc),
                })
                wf.log("rollback_failed", f"Step {step.index}: {step.rollback_tool} → {exc}")
                # Continue rolling back other steps even if one fails
    
            self._store.save(wf)
    
        wf.state = WorkflowState.FAILED
        wf.log("rollback_completed")
        self._store.save(wf)
    
        result = wf.to_dict()
        result["rollback_results"] = rollback_results
        return result
  • The MCP tool handler function 'rollback' — decorated with @mcp.tool and @vmware_tool, loads the workflow from store, validates it's not completed, then delegates to WorkflowExecutor.rollback().
    @mcp.tool(annotations={"readOnlyHint": False, "destructiveHint": True, "idempotentHint": False, "openWorldHint": True})
    @vmware_tool(risk_level="high")
    def rollback(workflow_id: str) -> dict:
        """[WRITE] Abort a workflow and rollback completed steps in reverse order.
    
        Works in any state except 'completed'. Irreversible steps are skipped.
        The workflow state is set to 'failed' after rollback.
    
        Args:
            workflow_id: The workflow ID to rollback.
    
        Returns:
            Rollback results for each step.
        """
        try:
            wf = _get_store().load(workflow_id)
            if not wf:
                return {"error": f"Workflow '{workflow_id}' not found"}
    
            if wf.state == WorkflowState.COMPLETED:
                return {"error": f"Workflow '{workflow_id}' is already completed, cannot rollback"}
    
            return _get_executor().rollback(wf)
        except Exception as e:
            return {"error": str(e), "hint": f"Rollback failed for '{workflow_id}'. Use get_workflow_status() to check state."}
  • WorkflowStep dataclass — defines rollback_tool (str) and rollback_params (dict) fields used by the rollback logic.
    @dataclass
    class WorkflowStep:
        index: int
        action: str
        skill: str
        tool: str
        params: dict[str, Any]
        status: str = "pending"  # pending | running | success | failed | skipped | rolled_back
        result: Any = None
        started_at: str = ""
        completed_at: str = ""
        rollback_tool: str = ""
        rollback_params: dict[str, Any] = field(default_factory=dict)
        group_id: str = ""  # non-empty = parallel-group sibling; agent may dispatch concurrently with peers
  • WorkflowState enum — includes ROLLING_BACK state used during rollback execution.
    class WorkflowState(str, Enum):
        DRAFT = "draft"
        PENDING = "pending"
        RUNNING = "running"
        MONITORING = "monitoring"
        AWAITING_APPROVAL = "awaiting_approval"
        COMMITTING = "committing"
        ROLLING_BACK = "rolling_back"
        COMPLETED = "completed"
        FAILED = "failed"
        BLOCKED_BY_POLICY = "blocked_by_policy"
  • Workflow.completed_steps() — helper method returning list of steps with status 'success', used by executor.rollback() to determine which steps to roll back.
    def completed_steps(self) -> list[WorkflowStep]:
        return [s for s in self.steps if s.status == "success"]
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate destructiveHint=true, and the description adds behavioral details: order of rollback, skipping irreversible steps, setting state to 'failed', and return of results. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, well-structured with sections, and front-loads the key action. Every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having no output schema, the description includes return information. It covers purpose, usage conditions, behavioral details, and the single parameter completely, making it self-sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by explaining the only parameter 'workflow_id' with a clear purpose, which the schema lacks.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb and resource combination ('Abort a workflow and rollback completed steps in reverse order'), which clearly distinguishes it from sibling tools like run_workflow or plan_workflow.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly states the state condition ('Works in any state except completed') and what happens to irreversible steps, providing clear guidance on when to use. It lacks explicit mentions of alternatives but context is sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zw008/VMware-Pilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server