Skip to content

Gemini tool-calls fail after first step because thought_signature is dropped #727

@pruales

Description

@pruales

Disclaimer: this was found and patched locally by codex while i was working on a personal project. Apologies if this is off base.

When using DurableAgent with Gemini thinking models and tools, follow‑up steps fail with:
“Function call is missing a thought_signature in functionCall parts…”
This happens because the workflow reconstructs tool‑call history without providerOptions, so the Gemini adapter can’t read thoughtSignature.

Environment

  • @workflow/ai: 4.0.1-beta.40
  • ai: 6.0.5
  • @ai-sdk/google: 3.0.2
  • Model: gemini-3-flash-preview (thinking enabled)

Repro

  1. Use DurableAgent with Gemini model + tools.
  2. A tool call is generated and executed.
  3. Next step errors:
    “Function call is missing a thought_signature in functionCall parts…”

Root cause
In packages/ai/src/agent/stream-text-iterator.ts, when finishReason === 'tool-calls', the tool call is appended without providerOptions:

conversationPrompt.push({
  role: 'assistant',
  content: toolCalls.map((toolCall) => ({
    type: 'tool-call',
    toolCallId: toolCall.toolCallId,
    toolName: toolCall.toolName,
    input: JSON.parse(toolCall.input),
    // providerOptions missing
  })),
});

The Gemini adapter reads thoughtSignature from part.providerOptions.google.thoughtSignature, not providerMetadata, so the next request fails.

Proposed fix
Pass provider metadata through providerOptions when reconstructing tool‑calls:

  ...(toolCall.providerMetadata
    ? { providerOptions: toolCall.providerMetadata }
    : {}),

Additional context
We patched node_modules/@workflow/ai/dist/agent/stream-text-iterator.js locally and the error disappears.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions