Skip to content

feat(task-tool): emit diagnostic when subagent returns no text part (#24447) - #28021

Closed
PeterPonyu wants to merge 1 commit into
anomalyco:devfrom
PeterPonyu:feat/opencode-24447-tasktool-empty-result-diagnostics
Closed

PeterPonyu wants to merge 1 commit into
anomalyco:devfrom
PeterPonyu:feat/opencode-24447-tasktool-empty-result-diagnostics

Conversation

@PeterPonyu

@PeterPonyu PeterPonyu commented May 17, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #24447

Type of change

  • Bug fix

What does this PR do?

The task tool previously returned an empty <task_result> when a subagent response had no text part, which made missing output indistinguishable from an intentionally empty response.

This PR preserves intentionally empty text parts, but emits a short diagnostic when no text part exists. The diagnostic includes the finish reason, error if present, and the part types returned by the subagent. Regression tests cover text output, intentionally empty text, and missing text parts.

This replaces auto-closed PR #27888 with a template-compliant PR body.

How did you verify your code works?

From packages/opencode:

  • bun test test/tool/task.test.ts — 18 passed, 0 failed
  • bun typecheck — passed

Screenshots / recordings

N/A — runtime-only task tool serialization change.

Checklist

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

…nomalyco#24447)

When a subagent session completes without producing any text part, the
parent now receives a structured diagnostic block instead of a silent
empty <task_result>. The block includes the finish reason, any error
details, and the list of part types actually produced, making it
straightforward to distinguish an intentional empty reply (text part
present but empty) from a missing-text-part scenario.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@niStee

niStee commented May 27, 2026

Copy link
Copy Markdown

This is an interesting approach! Just out of curiosity, how does returning a diagnostic string here interact with the FallbackProvider? If the tool returns a string instead of throwing an error when a model fails to return text, won't that prevent the fallback chain from intercepting the failure and switching to the backup model?

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TaskTool returns no diagnostic context when subagent result text is empty or missing

2 participants