Skip to content

Quick Start

The await_command tool runs a command and waits for it to complete:

await_command({
command: "npm run build",
maxDuration: 300
})

Realistic Example: GitHub Actions Workflow

Section titled “Realistic Example: GitHub Actions Workflow”
await_command({
command: "gh run watch 9847321 --exit-status",
maxDuration: 600,
successPattern: "completed.*success",
errorPattern: "failed|cancelled",
persistLogs: true,
summarize: { enabled: true }
})
{
"status": "success",
"exitCode": 0,
"elapsedMs": 127450,
"logPath": "/tmp/opencode-await-a1b2c3/output.log",
"summary": "Workflow completed successfully in 2m 7s. All 3 jobs passed: lint (12s), test (45s), build (68s). No warnings or errors detected.",
"searchableKeywords": ["lint", "test", "build", "success", "passed"],
"output": "Refreshing run status every 3 seconds...\n✓ lint completed (12s)\n✓ test completed (45s)\n✓ build completed (68s)\nRun 9847321 completed with 'success'",
"outputTruncated": false,
"matchedPattern": "completed with 'success'"
}

Pattern Matching with “Did You Mean” Suggestions

Section titled “Pattern Matching with “Did You Mean” Suggestions”

When searching for a specific pattern that doesn’t match, the summarizer identifies similar matches:

await_command({
command: "docker ps -a",
maxDuration: 30,
successPattern: "my-web-app",
summarize: { enabled: true }
})
{
"status": "error",
"exitCode": 0,
"elapsedMs": 1250,
"logPath": "/tmp/opencode-await-x7y8z9/output.log",
"summary": "Pattern 'my-web-app' not found in output. Did you mean: 'my-webapp' (container running), 'mywebapp-redis' (container exited)?",
"searchableKeywords": ["my-webapp", "mywebapp-redis", "nginx", "postgres"],
"matchedPattern": null
}
await_command({
command: "npm run build",
maxDuration: 300,
persistLogs: true,
summarize: { enabled: true }
})
{
"status": "success",
"exitCode": 0,
"elapsedMs": 45230,
"logPath": "/tmp/opencode-await-d4e5f6/output.log",
"summary": "Build completed. 142 modules bundled (1.2MB). 2 warnings: unused import in src/utils.ts:12, deprecated API in src/api.ts:45.",
"searchableKeywords": ["modules", "bundled", "warnings", "utils.ts", "api.ts"]
}

Run follow-up commands based on the result:

await_command({
command: "npm run build",
maxDuration: 300,
onSuccess: "npm run deploy",
onFailure: "npm run notify-failure"
})
FieldTypeDescription
status"success" | "error" | "timeout"Outcome of the command
exitCodenumberProcess exit code
elapsedMsnumberExecution time in milliseconds
logPathstring?Path to persisted log file (if persistLogs: true)
summarystring?AI-generated summary (if summarize.enabled: true)
searchableKeywordsstring[]?Keywords for searching the log file
summarizeErrorstring?Error if summarization failed
outputstringCommand output (truncated if large)
outputTruncatedbooleanWhether output was truncated
matchedPatternstring?The pattern that matched (if any)