Skip to content

Fix background task result retrieval so an agent can read a subagent's final answer#5459

Open
andrescera wants to merge 3 commits into
code-yeongyu:devfrom
andrescera:feature/background-task-result-retrieval
Open

Fix background task result retrieval so an agent can read a subagent's final answer#5459
andrescera wants to merge 3 commits into
code-yeongyu:devfrom
andrescera:feature/background-task-result-retrieval

Conversation

@andrescera

@andrescera andrescera commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Fix background task result retrieval so an agent can read a subagent's final answer

The problem. When an agent delegates work to run in the background and later asks for the result, it frequently can't get the one thing it needs: the subagent's final answer. Asking for the result returns the entire background conversation — including very large intermediate output like full build and test logs — instead of the recent, relevant part. The option meant to return "just the most recent message" doesn't actually narrow anything, so even when the agent explicitly asks for the ending, it still receives everything, and the final answer at the very end gets dropped before the agent can see it. In practice the agent asks again and again, never receives the conclusion, and its own working memory fills with noise it never wanted.

When it started. The "most recent message" option was added in v4.10.0 (commit 6092c8e), on top of result formatting that had never limited large intermediate output.

The solution. Make result retrieval honor what the caller asks for. A request for the most recent part of a background task returns a bounded slice from the end that reliably contains the final answer, whether the task is finished or still running, and the final answer is shown first so it can't be cut off. Bulky intermediate output no longer crowds out that answer, and a caller's choice to leave heavy detail out is respected even while the task is still in progress. Lightweight status checks stay small and cheap; only an explicit request for full detail returns more.


Summary by cubic

Fixes background task result retrieval so agents reliably get a subagent’s final answer without being buried by logs. Adds bounded tail slicing and truncation for smaller, cheaper status checks.

  • Bug Fixes
    • Honor from_end for both full_session and completed results; when no limit is given, return the last 20 messages.
    • Completed results lead with the “Final answer,” followed by a bounded “Older context” (size set by message_limit, default 20).
    • Respect include_thinking and include_tool_results: explicit values are honored; defaults are on only while the task is active.
    • Truncate tool_result blocks to 2000 chars with an ellipsis to avoid log bloat.
    • Preserve the “No new output since last check” notice; added tests for tail slicing, truncation, and include-flag behavior.

Written for commit 3ebb341. Summary will update on new commits.

Review in cubic

@github-actions github-actions Bot added the opencode OpenCode edition: packages/omo-opencode label Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

opencode OpenCode edition: packages/omo-opencode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant