Skip to main content

What is Execute Terminal Command?

Execute Terminal Command is a specialized tool that allows your agent to run PowerShell commands on the Windows machine during workflow execution. This enables system-level operations, file manipulations, and integrations that go beyond GUI interactions.
In your prompts, always refer to this tool as execute_terminal_command (lowercase, with underscores).
PowerShell Only: This tool executes PowerShell commands on Windows. Do NOT use Unix/Bash syntax. Always use proper PowerShell cmdlets and syntax.

Why This Tool Exists

Many enterprise workflows require system-level operations:
  • File system operations (copy, move, delete, rename)
  • System administration tasks
  • API calls and web requests
  • Data processing and transformation
  • Integration with command-line tools
  • Batch operations on multiple files
The execute_terminal_command tool ensures these operations are performed consistently, even during cached workflow runs.

Session Behavior

Persistent by default: execute_terminal_command reuses the same PowerShell session by default within a workflow run.
  • Variables, the current directory, and other shell state can carry over between consecutive terminal commands

Timeout Behavior

By default, execute_terminal_command waits up to 30 seconds for a command to complete. For long-running operations, you can specify a custom timeout using the duration parameter.
Cyberdriver 1.0.2+: If a one-shot PowerShell command reaches its timeout, Cyberdriver returns control to Cyberdesk but lets the command keep running in the background. To avoid runaway resource usage, Cyberdriver allows up to 10 timed-out background PowerShell commands at once; additional timed-out commands are terminated until a background slot is released.

Using Duration Parameter

Background Execution

On Cyberdriver 1.0.2+, when a one-shot command exceeds its timeout and a background slot is available, it continues running in the background while the workflow proceeds. This is useful for:
  • Fire-and-forget operations
  • Long-running background tasks
  • Commands that write output to files
Example:

Best Practices for Long Commands

  1. Redirect output to files - Use > output.txt or -RedirectStandardOutput
  2. Don’t rely on command output - If timeout is reached, stdout/stderr will be empty
  3. Verify completion separately - Use subsequent commands or focused_action to check results
  4. Use appropriate timeouts - Match duration to expected command runtime
Example with file output:

PowerShell Syntax Guide

❌ Unix/Bash Commands (DON’T USE)

✅ PowerShell Equivalents (USE THESE)

How to Prompt for Terminal Commands

Best Practices

  1. Use PowerShell Syntax: Always use proper PowerShell cmdlets
  2. Include ConvertTo-Json: For commands that return objects, pipe to ConvertTo-Json to avoid truncation
  3. Handle Dynamic Commands: Use input variables for commands that change between runs
  4. Specify Full Paths: Use absolute paths when working with files
  5. Error Handling: Consider what should happen if a command fails
  6. Use a Workflow Allowlist For Sensitive Flows: If a workflow only needs a small set of terminal commands, configure the workflow’s terminal command allowlist so the agent can only run those approved command templates

Prompt Template

Workflow Terminal Allowlist

Cyberdesk workflows can optionally define a terminal command allowlist in the workflow editor. When present:
  • The allowlist is enforced server-side before a command is sent to Cyberdriver.
  • The agent may only run commands that match one of the approved command templates, or the resolved command produced from that template for the current run.
  • Allowlist templates may include input values like {value}, sensitive values like {$value}, runtime values like {{value}}, and loop-item runtime values like {{loop_item}}.
  • working_directory is not allowed with an active allowlist. Prefer explicit paths inside the approved command itself.
  • Dynamic input or runtime variables are still fine as long as the resulting command matches an approved template.
Recommended pattern: list one approved PowerShell command per line in the workflow editor, then prompt the agent to use only those approved commands for terminal work.

Using Persistent Shell State

Real-World Examples

File Operations

API Integration

Data Processing

System Information

Common PowerShell Commands

File and Directory Operations

Text Processing

Web Requests

Dynamic Commands with Variables

Using Workflow Input Variables

Using Runtime Variables

Building Dynamic Commands

Conditional Command Execution

Sensitive Variables in Terminal Commands

Use {$variable} for secrets required by terminal actions (e.g., tokens). Secrets are never logged or sent to LLMs and are resolved only at execution time. Avoid echoing them in command output or saving them to files.

Best Practices

  • Do not print secrets (avoid Write-Host of secret values)
  • Prefer passing secrets to commands that do not echo them to stdout
  • Never persist secrets to disk or logs
  • If a command would reveal the secret in output, capture only status and verify success via UI with focused_action

Example

Advanced Patterns

Batch Processing

System Monitoring

Log Analysis

Integration with Other Tools

With File Export

With Focused Action

Creating Reports

Error Handling

Checking Command Success

Graceful Failures

Best Practices Summary

  1. Always use PowerShell syntax, not Unix/Bash commands
  2. Pipe object output to ConvertTo-Json to see full results
  3. Use absolute paths for file operations
  4. Consider using -Force parameters to avoid prompts
  5. Handle errors gracefully with -ErrorAction
  6. Test complex commands before including in workflows
  7. Use input variables for dynamic command components
  8. Reuse the default persistent session when follow-up commands depend on earlier shell state