Skip to content

Fix MCP gating on openai#55

Merged
ScriptSmith merged 2 commits into
mainfrom
openai-mcp-gating
Jun 9, 2026
Merged

Fix MCP gating on openai#55
ScriptSmith merged 2 commits into
mainfrom
openai-mcp-gating

Conversation

@ScriptSmith

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a 400 error from OpenAI's Responses API where a reconstructed function_call item had its id field set to the raw call_… value instead of the required fc_…-namespaced value. A new helper function_call_item_id derives the correct fc_-namespaced item id from the parked call_id, while call_id continues to carry the original parked value.

  • Adds function_call_item_id with three branches: pass-through for already-fc_-namespaced IDs, prefix swap for call_-style IDs, and a generic fc_ prefix for all other formats.
  • Updates resolve_approval to call the new helper when building FunctionToolCall.id, and refreshes tests to assert the id/call_id split for the standard OpenAI case.

Confidence Score: 5/5

Safe to merge — the change is a targeted, well-tested fix for the OpenAI 400 on replayed function calls.

The logic is narrow and correct: function_call_item_id covers all three meaningful call_id shapes, the unit test exercises each branch, and the integration test verifies the id/call_id split end-to-end. No existing behavior changes for non-OpenAI providers since they ignore the item id.

No files require special attention.

Important Files Changed

Filename Overview
src/services/mcp/resume.rs Introduces function_call_item_id to derive an fc_-namespaced item id from a parked call_id, fixing the OpenAI 400; updates resolve_approval and tests accordingly.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Hadrian
    participant DB as Approvals DB
    participant OpenAI

    Client->>Hadrian: POST /responses (mcp_approval_response, approve: true/false)
    Hadrian->>DB: "take_by_id_and_org (claim & delete row)"
    DB-->>Hadrian: "McpPendingApproval { call_id: "call_abc123", ... }"
    Note over Hadrian: function_call_item_id("call_abc123") → "fc_abc123"
    Hadrian->>Hadrian: "Build FunctionToolCall { id: "fc_abc123", call_id: "call_abc123" }"
    Hadrian->>Hadrian: "Build FunctionCallOutput { call_id: "call_abc123" }"
    Hadrian->>OpenAI: "Replay input [ function_call(id="fc_abc123"), function_call_output(call_id="call_abc123") ]"
    OpenAI-->>Hadrian: 200 OK (id starts with fc_ ✓)
    Hadrian-->>Client: Response
Loading

Reviews (3): Last reviewed commit: "Review fixes" | Re-trigger Greptile

Comment thread src/services/mcp/resume.rs Outdated
@ScriptSmith

Copy link
Copy Markdown
Member Author

@greptile-apps

@ScriptSmith ScriptSmith merged commit b02e923 into main Jun 9, 2026
20 checks passed
@ScriptSmith ScriptSmith deleted the openai-mcp-gating branch June 9, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant