* Add native tool calling support to OpenAI-compatible
* Fix OpenAI strict mode schema validation by adding converter methods to BaseProvider
- Add convertToolsForOpenAI() and convertToolSchemaForOpenAI() methods to BaseProvider
- These methods ensure all properties are in required array and convert nullable types
- Remove line_ranges from required array in read_file tool (converter handles it)
- Update OpenAiHandler and BaseOpenAiCompatibleProvider to use helper methods
- Eliminates code duplication across multiple tool usage sites
- Fixes: OpenAI completion error: 400 Invalid schema for function 'read_file'
---------
Co-authored-by: daniel-lxs <ricciodaniel98@gmail.com>
* fix: format tool responses for native protocol
- Add toolResultFormatting utilities for protocol detection
- ReadFileTool now builds both XML and native formats
- Native format returns clean, readable text without XML tags
- Legacy conversation history conversion is protocol-aware
- All tests passing (55 total)
* refactor: use isNativeProtocol from @roo-code/types
Remove duplicate implementation and import from types package instead
* refactor: centralize toolProtocol configuration checks
- Created src/utils/toolProtocol.ts with getToolProtocolFromSettings() utility
- Replaced all direct vscode.workspace.getConfiguration() calls with centralized utility
- Updated 6 files to use the new utility function
- All tests pass and TypeScript compilation succeeds
* refactor: use isNativeProtocol function from types package
When read_file encountered errors (e.g., file not found), it would call
handleError() which internally calls pushToolResult(), then continue to
call pushToolResult() again with the final XML. In native protocol mode,
this created two tool_result blocks with the same tool_call_id, causing
400 errors on subsequent API calls.
This fix replaces handleError() with task.say() for error notifications.
The agent still receives error details through the XML in the single
final pushToolResult() call.
This change works for both protocols:
- Native: Only one tool_result per tool_call_id (fixes duplicate issue)
- XML: Only one text block with complete XML (cleaner than before)
Agent visibility preserved: Errors are included in the XML response
sent to the agent via pushToolResult().
Tests: All 44 tests passing. Updated test to verify say() is called.
The OpenAI tool schema required both 'path' and 'line_ranges' in FileEntry,
but the TypeScript type definition marks lineRanges as optional. This caused
the AI to fail when trying to read files without specifying line_ranges.
Changes:
- Updated read_file tool schema to only require 'path' parameter
- line_ranges remains available but optional, matching TypeScript types
- Aligns with implementation which treats lineRanges as optional throughout
Fixes issue where read_file tool kept failing with missing parameters.
* fix: filter native tools by mode restrictions
Native tools are now filtered based on mode restrictions before being sent to the API, matching the behavior of XML tools. Previously, all native tools were sent to the API regardless of mode, causing the model to attempt using disallowed tools.
Changes:
- Created filterNativeToolsForMode() and filterMcpToolsForMode() utility functions
- Extracted filtering logic from Task.ts into dedicated module
- Applied same filtering approach used for XML tools in system prompt
- Added comprehensive test coverage (10 tests)
Impact:
- Model only sees tools allowed by current mode
- No more failed tool attempts due to mode restrictions
- Consistent behavior between XML and Native protocols
- Better UX with appropriate tool suggestions per mode
* refactor: eliminate repetitive tool checking using group-based approach
- Add getAvailableToolsInGroup() helper to check tools by group instead of individually
- Refactor filterNativeToolsForMode() to reuse getToolsForMode() instead of duplicating logic
- Simplify capabilities.ts by using group-based checks (60% reduction)
- Refactor rules.ts to use group helper (56% reduction)
- Remove debug console.log statements
- Update tests and snapshots
Benefits:
- Eliminates code duplication
- Leverages existing TOOL_GROUPS structure
- More maintainable - new tools in groups work automatically
- All tests passing (26/26)
* fix: add fallback to default mode when mode config not found
Ensures the agent always has functional tools even if:
- A custom mode is deleted while tasks still reference it
- Mode configuration becomes corrupted
- An invalid mode slug is provided
Without this fallback, the agent would have zero tools (not even
ask_followup_question or attempt_completion), completely breaking it.
* refactor(task): wrap initial user message in <feedback> instead of <task> to prevent focus drift after context-management
Rationale: After a successful context-management event, framing the next user block as feedback reduces model focus drift. Mentions parsing already supports <feedback>, and tool flows (attemptCompletion, responses) are aligned. No change to loop/persistence.
* refactor(mentions): drop <task> parsing; standardize on <feedback>; update tests
openai-native: include reasoning.encrypted_content only when reasoningEffort is set; prevent Responses API error on non-reasoning models. types: remove supportsVerbosity from gpt-5-chat-latest to avoid invalid verbosity error. Fixes#9225
* Migrate conversation continuity to plugin-side encrypted reasoning items (Responses API)
Summary
We moved continuity off OpenAI servers and now maintain conversation state locally by persisting and replaying encrypted reasoning items. Requests are stateless (store=false) while retaining the performance/caching benefits of the Responses API.
Why
This aligns with how Roo manages context and simplifies our Responses API implementation while keeping all the benefits of continuity, caching, and latency improvements.
What changed
- All OpenAI models now use the Responses API; system instructions are passed via the top-level instructions field; requests include store=false and include=["reasoning.encrypted_content"].
- We persist encrypted reasoning items (type: "reasoning", encrypted_content, optional id) into API history and replay them on subsequent turns.
- Reasoning summaries default to summary: "auto" when supported; text.verbosity only when supported.
- Atomic persistence via safeWriteJson.
Removed
- previous_response_id flows, suppressPreviousResponseId/skipPrevResponseIdOnce, persistGpt5Metadata(), and GPT‑5 response ID metadata in UI messages.
Kept
- taskId and mode metadata for cross-provider features.
Result
- ZDR-friendly, stateless continuity with equal or better performance and a simpler codepath.
* fix(webview): remove unused metadata prop from ReasoningBlock render
* Responses API: retain response id for troubleshooting (not continuity)
Continuity is stateless via encrypted reasoning items that we persist and replay. We now capture the top-level response id in OpenAiNativeHandler and persist the assistant message id into api_conversation_history.json solely for debugging/correlation with provider logs; it is not used for continuity or control flow.
Also: silence request-body debug logging to avoid leaking prompts.
* remove DEPRECATED tests
* chore: remove unused Task types file to satisfy knip CI
* fix(task): properly type cleanConversationHistory and createMessage args in Task to address Dan's review