[GH-ISSUE #77] Tool results error with OpenCode - no captured functionCall history was available for replay #67

Closed
opened 2026-02-27 15:38:12 +03:00 by kerem · 2 comments
Owner

Originally created by @LevinFaber on GitHub (Feb 25, 2026).
Original GitHub issue: https://github.com/NikkeTryHard/zerogravity/issues/77

Issue: Tool results error with OpenCode - "no captured functionCall history was available for replay"

Error Description

When using ZeroGravity with OpenCode and tool calling (MCP servers), I get this error:

Bad Request: {"error":{"message":"Tool results were provided, but no captured functionCall history was available for replay. Refusing to forward malformed tool_result turn.","type":"invalid_request_error","code":400}}

Environment

  • Client: OpenCode with MCP servers enabled
  • ZeroGravity Version: v1.3.8
  • Setup: Docker container via OrbStack on macOS ARM64
  • API Endpoint: Using Gemini protocol (/v1beta)

Model Configuration

{
  "zerogravity": {
    "npm": "@ai-sdk/google",
    "name": "ZeroGravity (Gemini)",
    "options": {
      "apiKey": "not-needed",
      "baseURL": "http://localhost:8741/v1beta"
    },
    "models": {
      "opus-4.6": {
        "name": "Opus 4.6",
        "limit": { "context": 200000, "output": 65536 }
      },
      "sonnet-4.6": {
        "name": "Sonnet 4.6",
        "limit": { "context": 200000, "output": 65536 }
      },
      "gemini-3-flash": {
        "name": "Gemini 3 Flash",
        "limit": { "context": 128000, "output": 65536 }
      },
      "gemini-3.1-pro": {
        "name": "Gemini 3.1 Pro",
        "limit": { "context": 128000, "output": 65536 }
      },
      "gemini-3.1-pro-low": {
        "name": "Gemini 3.1 Pro (Low)",
        "limit": { "context": 128000, "output": 65536 }
      }
    }
  }
}

Steps to Reproduce

  1. Configure OpenCode with ZeroGravity provider using Gemini protocol
  2. Start a conversation that triggers tool calls (read, write)
  3. Tool call is executed, then the agent crashes
  4. Error occurs when tool results are sent back

Diagnostic Report

generated_at: "2026-02-25T13:28:23Z"
format: TOON/1.0
report_status:
  timed_out: false
  timeout_seconds: 20
  elapsed_ms: 861
system:
  os: Darwin
  kernel: "25.1.0"
  arch: arm64
  in_docker: false
zerogravity:
  version: "1.3.8"
  edition: release
  dev_build: false
  build_commit: 1dfc698e2465
  zg_binary: "<install_dir>/zerogravity-config/zg"
service:
  running: true
  proxy_port: 8741
  mitm_port: 8742
  pid: "91195"
  uptime: "43:03"
  memory_rss_kb: 293696
config:
  config_dir: ~/.config/zerogravity
  token_file_exists: false
  token_env_set: false
  api_key_set: false
ls_binary:
  found: true
  path: /Applications/Antigravity.app/Contents/Resources/app/extensions/antigravity/bin/language_server_macos_arm
  size_bytes: 150410704
  executable: true
api:
  health: "{\"status\":\"ok\"}"
  models: "{\"object\":\"list\",\"data\":[{\"id\":\"opus-4.6\",...}]}"
  quota: "{\"last_updated\":\"2026-02-25T13:27:40...\",\"plan\":{\"plan_name\":\"Pro\"...}}"
  usage: "{\"mitm\":{\"total_requests\":4...}}"
logs:
  exists: false
traces:
  date: "2026-02-25"
  total_today: 0

Additional Context

  • The error suggests that when OpenCode sends tool_result messages, ZeroGravity doesn't have the corresponding functionCall history to replay
  • This happens with the Gemini protocol (/v1beta)
  • Service is running and healthy, models are accessible
  • Regular chat completions work fine, only tool calling fails

Questions

  1. Does ZeroGravity support tool/function calling through the Gemini protocol endpoint?
  2. Is there a specific format required for tool results that differs from standard OpenAI/Gemini format?
  3. Should I use a different endpoint (/v1 instead of /v1beta) for better tool calling support?

Thank you for this awesome project! Looking forward to getting tool calling working.

Originally created by @LevinFaber on GitHub (Feb 25, 2026). Original GitHub issue: https://github.com/NikkeTryHard/zerogravity/issues/77 # Issue: Tool results error with OpenCode - "no captured functionCall history was available for replay" ## Error Description When using ZeroGravity with OpenCode and tool calling (MCP servers), I get this error: ``` Bad Request: {"error":{"message":"Tool results were provided, but no captured functionCall history was available for replay. Refusing to forward malformed tool_result turn.","type":"invalid_request_error","code":400}} ``` ## Environment - **Client**: OpenCode with MCP servers enabled - **ZeroGravity Version**: v1.3.8 - **Setup**: Docker container via OrbStack on macOS ARM64 - **API Endpoint**: Using Gemini protocol (`/v1beta`) ## Model Configuration ```json { "zerogravity": { "npm": "@ai-sdk/google", "name": "ZeroGravity (Gemini)", "options": { "apiKey": "not-needed", "baseURL": "http://localhost:8741/v1beta" }, "models": { "opus-4.6": { "name": "Opus 4.6", "limit": { "context": 200000, "output": 65536 } }, "sonnet-4.6": { "name": "Sonnet 4.6", "limit": { "context": 200000, "output": 65536 } }, "gemini-3-flash": { "name": "Gemini 3 Flash", "limit": { "context": 128000, "output": 65536 } }, "gemini-3.1-pro": { "name": "Gemini 3.1 Pro", "limit": { "context": 128000, "output": 65536 } }, "gemini-3.1-pro-low": { "name": "Gemini 3.1 Pro (Low)", "limit": { "context": 128000, "output": 65536 } } } } } ``` ## Steps to Reproduce 1. Configure OpenCode with ZeroGravity provider using Gemini protocol 2. Start a conversation that triggers tool calls (read, write) 3. Tool call is executed, then the agent crashes 4. Error occurs when tool results are sent back ## Diagnostic Report ```yaml generated_at: "2026-02-25T13:28:23Z" format: TOON/1.0 report_status: timed_out: false timeout_seconds: 20 elapsed_ms: 861 system: os: Darwin kernel: "25.1.0" arch: arm64 in_docker: false zerogravity: version: "1.3.8" edition: release dev_build: false build_commit: 1dfc698e2465 zg_binary: "<install_dir>/zerogravity-config/zg" service: running: true proxy_port: 8741 mitm_port: 8742 pid: "91195" uptime: "43:03" memory_rss_kb: 293696 config: config_dir: ~/.config/zerogravity token_file_exists: false token_env_set: false api_key_set: false ls_binary: found: true path: /Applications/Antigravity.app/Contents/Resources/app/extensions/antigravity/bin/language_server_macos_arm size_bytes: 150410704 executable: true api: health: "{\"status\":\"ok\"}" models: "{\"object\":\"list\",\"data\":[{\"id\":\"opus-4.6\",...}]}" quota: "{\"last_updated\":\"2026-02-25T13:27:40...\",\"plan\":{\"plan_name\":\"Pro\"...}}" usage: "{\"mitm\":{\"total_requests\":4...}}" logs: exists: false traces: date: "2026-02-25" total_today: 0 ``` ## Additional Context - The error suggests that when OpenCode sends `tool_result` messages, ZeroGravity doesn't have the corresponding `functionCall` history to replay - This happens with the Gemini protocol (`/v1beta`) - Service is running and healthy, models are accessible - Regular chat completions work fine, only tool calling fails ## Questions 1. Does ZeroGravity support tool/function calling through the Gemini protocol endpoint? 2. Is there a specific format required for tool results that differs from standard OpenAI/Gemini format? 3. Should I use a different endpoint (`/v1` instead of `/v1beta`) for better tool calling support? --- Thank you for this awesome project! Looking forward to getting tool calling working.
kerem closed this issue 2026-02-27 15:38:12 +03:00
Author
Owner

@NikkeTryHard commented on GitHub (Feb 26, 2026):

Closing this out: the fix is implemented in private PR #162 (zerogravity-src), which has already been rebased onto main and is now resolved.\n\nSummary of resolution:\n- Tool-result replay now resolves by call_id.\n- Unknown call_id still fails fast as intended.\n- Streaming and final Responses function_call IDs are now consistent.\n\nThanks for the report and reproduction details.

<!-- gh-comment-id:3964510712 --> @NikkeTryHard commented on GitHub (Feb 26, 2026): Closing this out: the fix is implemented in private PR #162 (zerogravity-src), which has already been rebased onto main and is now resolved.\n\nSummary of resolution:\n- Tool-result replay now resolves by call_id.\n- Unknown call_id still fails fast as intended.\n- Streaming and final Responses function_call IDs are now consistent.\n\nThanks for the report and reproduction details.
Author
Owner

@LevinFaber commented on GitHub (Feb 27, 2026):

zg-trace-2026-02-27_12-26-04_opus-4.6-28189078.tar.gz

Issue persists, attached trace

<!-- gh-comment-id:3972702338 --> @LevinFaber commented on GitHub (Feb 27, 2026): [zg-trace-2026-02-27_12-26-04_opus-4.6-28189078.tar.gz](https://github.com/user-attachments/files/25603825/zg-trace-2026-02-27_12-26-04_opus-4.6-28189078.tar.gz) Issue persists, attached trace
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/zerogravity#67
No description provided.