Conversation
This commit addresses two issues when running tasks via the Task tool: 1. Todo list display: When a subagent calls TodoWrite, the todos are now parsed and forwarded to the UI via a new ToolEvent::TodoUpdated event. The SubagentTaskDisplay in the TUI is then updated to show the todos with their status (pending, in_progress, completed). 2. HTTP 413 Payload Too Large: Tool outputs from subagent tool calls are now truncated to 32KB to prevent the cumulative context from exceeding backend payload limits. This is especially important for tools like Grep or Read that can return large outputs. Changes: - Add ToolEvent::TodoUpdated variant to events.rs - Detect TodoWrite calls in spawn_subagent and send todo updates to UI - Truncate tool outputs > 32KB with a clear truncation message - Handle TodoUpdated event in handle_tool_event to update app_state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses two issues when running tasks via the Task tool (subagent delegation):
Issue 1: Todo list not displaying during delegation
When a subagent is delegated a task, the user sees:
But the subagent's todo list (with [pending], [in_progress], [completed] items) never appears.
Root cause: The subagent runs in a background task and executes tools directly via the registry. When it calls TodoWrite, the result is never sent back to the UI.
Fix: Detect TodoWrite calls in
spawn_subagent, parse the todos from the arguments, and send a newToolEvent::TodoUpdatedevent to the UI. The event handler then updates theSubagentTaskDisplay.todosfield.Issue 2: HTTP 413 Payload Too Large
After the subagent runs for a while, the user sees:
Root cause: The subagent accumulates messages and tool results in its context. Large tool outputs (from Grep, Read, etc.) can cause the total payload to exceed backend limits.
Fix: Truncate tool outputs to 32KB maximum in the subagent's tool execution loop. A clear truncation message is appended so the model knows the output was truncated.
Changes
ToolEvent::TodoUpdatedvariantTodoUpdatedeventTodoUpdatedevent to updateapp_state