Skip to content

fromResponseParts drops metadata when converting tool-call/tool-result parts #5954

@izakfilmalter

Description

@izakfilmalter

What version of Effect is running?

3.19.13

What steps can reproduce the bug?

Prompt.fromResponseParts doesn't copy metadata to options when converting Response.ToolCallPart and Response.ToolResultPart to prompt parts. This breaks Google's Gemini API which requires thoughtSignature (stored in metadata.google.thoughtSignature) to be present in follow-up requests for multi-turn tool calls.

To reproduce this, set up a multi-tool flow with Google as the provider, you will get back the following error:

{
  \"module\": \"GoogleClient\",
  \"method\": \"streamRequest\",
  \"request\": {
    \"method\": \"POST\",
    \"url\": \"https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:streamGenerateContent\",
    \"urlParams\": [
      [
        \"alt\",
        \"sse\"
      ]
    ],
    \"hash\": {
      \"_id\": \"Option\",
      \"_tag\": \"None\"
    },
    \"headers\": {
      \"content-type\": \"application/json\",
      \"content-length\": \"22010\",
      \"x-goog-api-key\": \"AIzaSyDUyvTLlvd6mo8UwiYRUa-ApXHSkidRwLY\",
      \"accept\": \"application/json\",
      \"b3\": \"7ce22b39ac3e31687aa623f0ed43f558-09babdb4c653ccec-1-eb23f7e393f687bd\",
      \"traceparent\": \"00-7ce22b39ac3e31687aa623f0ed43f558-09babdb4c653ccec-01\"
    }
  },
  \"response\": {
    \"status\": 400,
    \"headers\": {
      \"alt-svc\": \"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000\",
      \"content-length\": \"435\",
      \"content-type\": \"text/event-stream\",
      \"date\": \"Tue, 06 Jan 2026 18:32:33 GMT\",
      \"server\": \"scaffolding on HTTPServer2\",
      \"server-timing\": \"gfet4t7; dur=153\",
      \"vary\": \"Origin, X-Origin, Referer\",
      \"x-content-type-options\": \"nosniff\",
      \"x-frame-options\": \"SAMEORIGIN\",
      \"x-xss-protection\": \"0\"
    }
  },
  \"body\": \"\"{\\n  \\\"error\\\": {\\n    \\\"code\\\": 400,\\n    \\\"message\\\": \\\"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call `default_api:vectorQuery` , position 2. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.\\\",\\n    \\\"status\\\": \\\"INVALID_ARGUMENT\\\"\\n  }\\n}\\n\"\",
  \"reason\": \"StatusCode\",
  \"description\": \"non 2xx status code\",
  \"_tag\": \"HttpResponseError\",
  \"~@effect/ai/AiError\": \"~@effect/ai/AiError\"
}```

### What is the expected behavior?

_No response_

### What do you see instead?

_No response_

### Additional information

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions