Files
chenhg5-cc-connect/agent/opencode
cg33 f4d36dbbdf fix(opencode): surface tool rejection error as text to prevent empty response (#178) (#1247)
When opencode rejects a tool call in default mode (e.g. bash permission
denied), it emits a tool_use event with status="error" then exits without
generating any follow-up text. This caused the engine to fall through to
the "(空响应)" / "(empty response)" placeholder since textParts was empty.

Fix: when handleToolUse receives status="error" with a non-empty error
message, emit an EventText containing the rejection reason. This ensures
textParts is populated and the user sees why the command was blocked (e.g.
"The user rejected permission to use this specific tool call.") rather
than a silent empty response.

Three scenarios handled:
- Permission denied (default mode): error text surfaced ✓
- Tool completed successfully: no change ✓
- Error with no message: no spurious empty EventText ✓

To avoid permission rejections entirely, set mode="yolo" in config or
configure opencode's permission settings to allow the required tools.

Fixes #178

Co-authored-by: root <root@UYQQVGRAEKQKNQP>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 21:18:25 +08:00
..