Skip to content

[Bug] Gemini 3.7 Flash video input fails with 502: routed provider emitted undeclared client tool "get_video_duration" #2458

Description

@GoldenLoaf24h

Client or integration

OpenAI-compatible Chat Completions / Multi-modal API (/v1/chat/completions)

Area

Tools / MCP / Provider compatibility

Summary

When sending a video payload (video_url with data URI or URL) to google-antigravity/gemini-3.7-flash (or Gemini 2.5/3.1 multimodal endpoints), the upstream Vertex / Antigravity provider internally emits built-in server-side helper function calls (such as get_video_duration, get_video_info, or video_analysis:get_video_info) to inspect video metadata before finishing the turn.

Because these tools are internally generated by Google's multimodal runtime and were not explicitly provided in the client's tools array, OpenCodeX's undeclared tool security guard (declaredToolNames check in src/bridge.ts line 1041-1045 and src/server/responses-undeclared-tool-guard.ts) immediately intercepts and aborts the response with HTTP 502:

502 Bad Gateway
{"error":{"message":"routed provider emitted undeclared client tool \"get_video_duration\"; only request-declared tools may be called","type":"server_error","param":null,"code":"upstream_server_error"}}

Expected: Either internal provider-native multimodal inspection tools (e.g. get_video_duration, get_video_info, video_analysis:*) are recognized as provider-internal and allowed/executed transparently, or bypassed in the client tool name declaration guard.

Reproduction

  1. Route a chat completion request to google-antigravity/gemini-3.7-flash with a video attachment via /v1/chat/completions:
    {
      "model": "google-antigravity/gemini-3.7-flash",
      "messages": [
        {
          "role": "user",
          "content": [
            { "type": "text", "text": "Summarize this video" },
            { "type": "video_url", "video_url": { "url": "data:video/mp4;base64,..." } }
          ]
        }
      ]
    }
  2. Observe HTTP 502 response returned from OpenCodeX proxy:
    {
      "error": {
        "message": "routed provider emitted undeclared client tool \"get_video_duration\"; only request-declared tools may be called",
        "code": "upstream_server_error"
      }
    }

Version

@bitkyc08/opencodex@2.31.0 (also verified in 2.26.0)

Operating system

Windows 11 / Linux (x86_64)

Provider and model

google-antigravity/gemini-3.7-flash

Logs or error output

HTTP/1.1 502 Bad Gateway
Content-Type: application/json

{
  "error": {
    "message": "routed provider emitted undeclared client tool \"get_video_duration\"; only request-declared tools may be called",
    "type": "server_error",
    "param": null,
    "code": "upstream_server_error"
  }
}

Upstream error from Vertex AI / Antigravity streaming bridge:
Vertex AI response truncated upstream before the turn completed (MALFORMED_FUNCTION_CALL / undeclared tool get_video_duration)

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions