Tool errors should be returned to Agent instead of crashing the Action #4911

Open
opened 2026-02-16 17:46:28 -05:00 by yindo · 0 comments
Owner

Originally created by @Maybank01 on GitHub (Jan 12, 2026).

Originally assigned to: @thdxr on GitHub.

Problem Description

When a tool call fails during a GitHub Action run, the entire Action crashes with an error instead of returning the error to the Agent so it can handle/retry/work around the issue.

Example Error

\\
POST /repos/xxx/pulls - 422 with id ...
HttpError: Validation Failed: {"resource":"PullRequest","code":"custom","message":"No commits between main and opencode/dispatch-xxx"}
Error: Process completed with exit code 1.
\\

What Happened

  1. Agent completed its work but made no file changes
  2. OpenCode infrastructure still tried to create a PR
  3. GitHub API returned 422 (No commits between branches)
  4. The entire Action crashed

Expected Behavior

The error should be returned to the Agent as tool output, allowing the Agent to:

  1. Understand that no changes were made
  2. Skip PR creation
  3. Respond appropriately to the user

Current Behavior

Tool errors cause the entire GitHub Action to exit with code 1, preventing:

  • Agent from handling the error
  • Agent from providing a meaningful response
  • Graceful degradation

Suggested Fix

In \packages/opencode/src/cli/cmd/github.ts, the \createPR\ function should:

  1. Check for "No commits between branches" error specifically
  2. Return this as a non-fatal condition
  3. Let the Agent decide how to respond

\\ ypescript
async function createPR(base: string, branch: string, title: string, body: string) {
// ... existing code ...

try {
const pr = await withRetry(() =>
octoRest.rest.pulls.create({ owner, repo, head: branch, base, title, body })
)
return pr.data.number
} catch (e) {
if (e.message?.includes("No commits between")) {
console.log("No changes to create PR for")
return null // Signal no PR was created
}
throw e
}
}
\\

Environment

  • OpenCode version: latest
  • Trigger: workflow_dispatch
  • Event: Running agent via custom prompt

Related

This is a fundamental design consideration - tool errors in an agentic system should be feedback to the agent, not fatal errors.

Originally created by @Maybank01 on GitHub (Jan 12, 2026). Originally assigned to: @thdxr on GitHub. ## Problem Description When a tool call fails during a GitHub Action run, the entire Action crashes with an error instead of returning the error to the Agent so it can handle/retry/work around the issue. ### Example Error \\\ POST /repos/xxx/pulls - 422 with id ... HttpError: Validation Failed: {"resource":"PullRequest","code":"custom","message":"No commits between main and opencode/dispatch-xxx"} Error: Process completed with exit code 1. \\\ ### What Happened 1. Agent completed its work but made no file changes 2. OpenCode infrastructure still tried to create a PR 3. GitHub API returned 422 (No commits between branches) 4. The entire Action crashed ### Expected Behavior The error should be returned to the Agent as tool output, allowing the Agent to: 1. Understand that no changes were made 2. Skip PR creation 3. Respond appropriately to the user ### Current Behavior Tool errors cause the entire GitHub Action to exit with code 1, preventing: - Agent from handling the error - Agent from providing a meaningful response - Graceful degradation ### Suggested Fix In \packages/opencode/src/cli/cmd/github.ts\, the \createPR\ function should: 1. Check for "No commits between branches" error specifically 2. Return this as a non-fatal condition 3. Let the Agent decide how to respond \\\ ypescript async function createPR(base: string, branch: string, title: string, body: string) { // ... existing code ... try { const pr = await withRetry(() => octoRest.rest.pulls.create({ owner, repo, head: branch, base, title, body }) ) return pr.data.number } catch (e) { if (e.message?.includes("No commits between")) { console.log("No changes to create PR for") return null // Signal no PR was created } throw e } } \\\ ### Environment - OpenCode version: latest - Trigger: workflow_dispatch - Event: Running agent via custom prompt ### Related This is a fundamental design consideration - tool errors in an agentic system should be feedback to the agent, not fatal errors.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4911