Skip to content

fix(opencode): log tool execution error stack traces#16935

Open
jpcarranza94 wants to merge 2 commits intoanomalyco:devfrom
jpcarranza94:fix/log-tool-error-stack-trace
Open

fix(opencode): log tool execution error stack traces#16935
jpcarranza94 wants to merge 2 commits intoanomalyco:devfrom
jpcarranza94:fix/log-tool-error-stack-trace

Conversation

@jpcarranza94
Copy link

@jpcarranza94 jpcarranza94 commented Mar 10, 2026

Issue for this PR

Closes #16925

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a tool throws during execution, the tool-error handler in processor.ts converts the error to a string via .toString(), which discards the stack trace. No log.error() is emitted either, so the error is invisible in server logs — even at --log-level DEBUG.

This adds a single log.error() call before the existing .toString() conversion. The stack trace appears in the logs, existing behavior is unchanged.

How did you verify your code works?

Ran opencode serve --log-level DEBUG under sustained load (~800 sessions/hour). Before this change, tool errors like RangeError: Maximum call stack size exceeded only appeared embedded inside service=llm log entries. After this change, they show as standalone ERROR entries with full stack traces.

Screenshots / recordings

N/A — server-side logging change, no UI impact.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Fixes anomalyco#16925

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 10, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@jpcarranza94
Copy link
Author

The e2e (linux) failure is unrelated to this change — it's a flaky Playwright test in settings-keybinds (terminal toggle keybind works) failing on expect(locator).not.toBeVisible(). This PR only adds a log.error() call in processor.ts and doesn't touch any UI code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool execution errors lose stack traces — processor.ts discards .stack via .toString()

1 participant