Skip to content

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

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

feat(task-tool): emit diagnostic when subagent returns no text part#27888
PeterPonyu wants to merge 1 commit into
anomalyco:devfrom
PeterPonyu:feat/opencode-24447-tasktool-empty-result-diagnostics

Conversation

@PeterPonyu
Copy link
Copy Markdown

Summary

  • TaskTool.runTask previously collapsed a missing-text-part scenario into a silent empty string via result.parts.findLast(…)?.text ?? "", giving the parent no indication of why the result was empty.
  • This PR emits a structured diagnostic block instead, containing the finish reason, any error details, and the part types that were produced, whenever no text part exists.
  • An intentionally empty text part (text === "") is preserved as-is, keeping the existing behaviour for that case.

Test plan

Three new cases added to packages/opencode/test/tool/task.test.ts:

  • Subagent returns a text part with content → output contains that text (happy path unchanged)
  • Subagent returns a text part with empty string → output wraps "" in <task_result></task_result>, no diagnostic block emitted
  • Subagent returns no text part → output contains "Subagent completed without a text response.", "finish:", "error:", and "parts:" lines

Related

🤖 Generated with Claude Code

…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 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 16, 2026
@github-actions github-actions Bot closed this May 16, 2026
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.

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

1 participant