When tools are called in parallel (e.g., update_todo_list + new_task),
the tool results accumulate in userMessageContent but aren't saved to
API history until all tools complete. When new_task triggers delegation,
the parent is disposed before these pending results are saved, causing
400 errors when the parent resumes (missing tool_result for tool_use).
This fix:
- Adds flushPendingToolResultsToHistory() method in Task.ts that saves
pending userMessageContent to API history
- Calls this method in delegateParentAndOpenChild() before disposing the
parent task
- Safe for both native/XML protocols and sequential/parallel execution
(returns early if there's nothing to flush)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Co-authored-by: Roo Code <roomote@roocode.com>
- Import resolveToolProtocol and TOOL_PROTOCOL from @roo-code/types
- Add tools and tool_choice to completion params when native protocol is enabled
- Handle tool_call_partial chunks in streaming response
- Add comprehensive tests for native tool support
Add supportsNativeTools: true to DeepSeek and Doubao model definitions,
enabling native OpenAI-compatible tool calling for these providers.
Both providers already extend OpenAiHandler which has built-in support
for native tools, so this change is all that's needed to enable the feature.
* feat: add model-specific tool customization via excludedTools and includedTools
- Add excludedTools and includedTools to ModelInfo schema
- Implement applyModelToolCustomization helper to filter tools based on model config
- Integrate model tool filtering into filterNativeToolsForMode for native protocol
- Add comprehensive tests for tool customization functionality
- Wire up modelInfo through buildNativeToolsArray and Task.ts
This allows providers to override which native tools are available on a per-model basis via MODEL_DEFAULTS, enabling better control over tool selection for models with specific needs.
* feat: add customTools for opt-in only tools
- Add customTools array to ToolGroupConfig for defining opt-in only tools
- Update getToolsForMode() to exclude customTools from default tool set
- Modify applyModelToolCustomization() to include customTools only via includedTools
- Add tests for customTools functionality
- Add comprehensive documentation with usage examples
customTools allows defining tools that are NOT available by default,
even when a mode includes their group. These tools are only available
when explicitly included via a model's includedTools configuration.
This enables:
- Gradual rollout of experimental tools
- Model-specific specialized capabilities
- Safe experimentation without affecting default tool sets
* Add assertions for customTools tests per review feedback
* test: add tests for including customTools via includedTools
* Update src/core/prompts/tools/__tests__/filter-tools-for-mode.spec.ts
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
---------
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
The pendingNewTaskToolCallId was being set AFTER startSubtask() returned.
However, startSubtask() contains a 500ms delay during which the subtask
could complete. If the subtask completed during this window, completeSubtask()
would be called before pendingNewTaskToolCallId was set, causing it to
fall through to the XML protocol path and add a text message instead of
a proper tool_result block, breaking the API conversation structure.
This fix moves the pendingNewTaskToolCallId assignment to happen BEFORE
calling startSubtask(), ensuring the ID is set before the subtask starts.
If the subtask creation fails, the pending ID is cleared.