Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Dec 18, 2025

Summary

Fixes an issue where MCP servers (like fetch) using format: "uri" in their tool schemas would cause OpenAI Native provider to reject requests with:

ApiProviderError: Invalid request to Responses API - Invalid schema for function 'mcp--fetch--fetch': In context=('properties', 'url'), 'uri' is not a valid format.

Root Cause

OpenAI's Structured Outputs (strict mode) only supports these JSON Schema format values:

  • date-time, time, date, duration
  • email, hostname, ipv4, ipv6, uuid

The uri format (and others like uri-reference, iri, etc.) are not supported.

Solution

Updated normalizeToolSchema() in src/utils/json-schema.ts to:

  1. Add explicit format field handling to the Zod schema
  2. Strip unsupported format values while preserving supported ones
  3. Apply this recursively to all nested properties

Testing

Added 12 new tests covering:

  • Preservation of all 9 supported format values
  • Stripping of unsupported formats (uri, uri-reference, etc.)
  • Nested and deeply nested property handling
  • MCP fetch server schema simulation

All 4857 tests pass.

References


Important

This PR fixes JSON Schema format compatibility with OpenAI and introduces a task-level protocol lock for consistent tool usage.

  • Behavior:
    • normalizeToolSchema() in json-schema.ts now strips unsupported JSON Schema format values (e.g., uri) for OpenAI compatibility.
    • Introduces task-level protocol lock in Task class to ensure consistent tool protocol usage.
  • Functions:
    • Updates resolveToolProtocol() to prioritize task-level protocol lock.
    • Adds detectToolProtocolFromHistory() to determine protocol from conversation history.
  • Testing:
    • Adds tests for normalizeToolSchema() to verify stripping of unsupported formats.
    • Adds tests for resolveToolProtocol() and detectToolProtocolFromHistory() to ensure correct protocol resolution and detection.

This description was created by Ellipsis for 132e366. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug Something isn't working labels Dec 18, 2025
@roomote
Copy link
Contributor

roomote bot commented Dec 18, 2025

Rooviewer Clock   See task on Roo Cloud

Sync review completed. No new issues found. 1 previously flagged issue remains unresolved.

  • Remove empty else block in src/core/task/Task.ts at lines 1748-1749
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 18, 2025
…lity

When using OpenAI Native provider with MCP servers (like fetch), the API
rejects schemas containing format values not supported by Structured Outputs.

OpenAI only supports: date-time, time, date, duration, email, hostname,
ipv4, ipv6, uuid

This change updates normalizeToolSchema() to strip unsupported format
values (like 'uri', 'uri-reference') while preserving supported ones.

Fixes PostHog issue: 019b3341-35fb-76b1-8aba-ef36d698f9a2
@daniel-lxs daniel-lxs force-pushed the fix/openai-uri-format-validation branch from 132e366 to a92fb7c Compare December 18, 2025 23:19
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 18, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Dec 18, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Dec 18, 2025
@hannesrudolph hannesrudolph mentioned this pull request Dec 19, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 19, 2025
@cte cte merged commit c3a4d14 into main Dec 19, 2025
18 of 19 checks passed
@cte cte deleted the fix/openai-uri-format-validation branch December 19, 2025 00:57
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Dec 19, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants