Skip to content

feat: enrich subtask handoff with structured context summaries (Phase 1 of #12330)#12332

Open
roomote-v0[bot] wants to merge 2 commits into
mainfrom
feature/enhanced-subtask-handoff-summary
Open

feat: enrich subtask handoff with structured context summaries (Phase 1 of #12330)#12332
roomote-v0[bot] wants to merge 2 commits into
mainfrom
feature/enhanced-subtask-handoff-summary

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented May 12, 2026

Related GitHub Issue

Closes: #12330 (Phase 1)

Description

This PR attempts to address Issue #12330 by implementing Phase 1: Enhanced context handoff visibility between parent and child tasks during delegation.

When a subtask completes via attempt_completion, the handoff back to the parent now includes a structured summary of what the subtask accomplished, rather than just the raw completion text. This gives both the parent LLM and the user much better visibility into the subtask's work.

Key implementation details:

  • SubtaskSummary type (packages/types/src/history.ts): New structured type capturing mode, files modified/read, commands executed, tool usage counts, and todo completion stats.
  • buildSubtaskSummary utility (src/core/task/buildSubtaskSummary.ts): Scans the child task's API conversation history to extract tool_use blocks and build metadata. Also provides formatSubtaskSummaryForApi for enriched parent LLM context.
  • AttemptCompletionTool: Builds the structured summary on subtask completion, with try/catch fallback to plain text for robustness.
  • reopenParentFromDelegation: Parses the structured summary, uses enriched markdown format for the API history (so the parent LLM gets files changed, mode, commands, etc.) and passes raw JSON to the UI message.
  • ChatRow UI: Detects JSON summaries and renders structured data with mode badge, file lists, command lists, and todo progress. Falls back to plain markdown for backward compatibility.
  • Fully backward compatible: Plain-text summaries from older tasks still render correctly.

Test Procedure

  • 19 new unit tests in src/core/task/__tests__/buildSubtaskSummary.spec.ts covering:
    • File extraction from write_to_file, apply_diff, read_file, execute_command tool_use blocks
    • Deduplication of modified files
    • Long command truncation
    • Tool usage summary extraction
    • Todo stats computation
    • Edge cases (empty history, non-array content, user messages)
    • formatSubtaskSummaryForApi output formatting
  • Verified all existing delegation tests still pass (newTaskTool.spec.ts, history-resume-delegation.spec.ts, nested-delegation-resume.spec.ts, new-task-delegation.spec.ts)

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on subtask handoff enrichment
  • Self-Review: Performed thorough self-review
  • Testing: 19 new tests added, all existing delegation tests pass
  • Documentation Impact: No user-facing docs changes needed for this phase
  • Contribution Guidelines: Read and agreed

Documentation Updates

No user-facing documentation changes required. This enhancement is transparent to existing workflows.

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Phase 1 of #12330 - improves context handoff visibility between
parent and child tasks during delegation.

Changes:
- Add SubtaskSummary type to @roo-code/types for structured handoff data
- Create buildSubtaskSummary utility that extracts files modified/read,
  commands executed, tool usage, and todo stats from task history
- Modify AttemptCompletionTool to build structured summary on completion
- Update reopenParentFromDelegation to format enriched API history text
  so the parent LLM gets better context about what the subtask did
- Update ChatRow UI to render structured summaries with mode badge,
  file lists, command lists, and todo progress
- Add i18n translation keys for new UI elements
- Add 19 tests for buildSubtaskSummary and formatSubtaskSummaryForApi
- Backward compatible: plain-text summaries still work as before
@easonLiangWorldedtech
Copy link
Copy Markdown

Thanks for the quick work on this!

I noticed the check-translations check is failing. It seems the new strings for the "Task Delegation" section need to be added to the translation files. Could you fix that?

Overall the implementation looks clean and non-intrusive. Appreciate you getting the first version out so fast.

@roomote

@roomote-v0
Copy link
Copy Markdown
Contributor Author

roomote-v0 Bot commented May 12, 2026

Fixaroo Clock   See task

Added the 4 missing subtask translation keys (filesModified, filesRead, commandsExecuted, todoStats) to all 17 non-English locale chat.json files. Translation validation script passes clean.

View commit | Revert commit

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

Labels

Enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Support parallel execution of specialized agents and improve context handoff between modes

2 participants