Module: RubyLLM

Defined in:
lib/swarm_sdk/ruby_llm_patches/mcp_ssl_patch.rb,
lib/swarm_sdk/ruby_llm_patches/connection_patch.rb,
lib/swarm_sdk/ruby_llm_patches/configuration_patch.rb,
lib/swarm_sdk/ruby_llm_patches/responses_api_patch.rb,
lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb,
lib/swarm_sdk/ruby_llm_patches/streaming_error_patch.rb,
lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb,
lib/swarm_sdk/ruby_llm_patches/message_management_patch.rb,
lib/swarm_sdk/ruby_llm_patches/openai_thought_signature_patch.rb

Overview

Patches RubyLLM::Providers::OpenAI::Tools to preserve thought_signature through the OpenAI-compatible streaming pipeline.

Vertex AI Gemini 3 models with "thinking" enabled return a thought_signature in tool call responses via extra_content.google.thought_signature. This must be echoed back in subsequent requests or the API rejects the request with:

"function call is missing a thought_signature"

The native Gemini provider handles this correctly, but the OpenAI provider (used for OpenAI-compatible proxies) drops thought_signature in both parse_tool_calls and format_tool_calls. The rest of the pipeline (StreamAccumulator, ToolCall) already supports thought_signature.

This patch:

  • Extracts thought_signature from extra_content during tool call parsing
  • Echoes thought_signature back in extra_content during serialization

Defined Under Namespace

Modules: MCP, Providers, ToolExecutors Classes: Chat, Configuration, Connection, ResponseCancelledError, ResponseFailedError, ResponseIdNotFoundError, ResponseInProgressError, ResponseIncompleteError, ResponsesApiError, ResponsesSession

Class Method Summary collapse

Class Method Details

.get_tool_executor(name) ⇒ Object



19
20
21
# File 'lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb', line 19

def get_tool_executor(name)
  tool_executors[name] || raise(ArgumentError, "Unknown tool executor: #{name}")
end

.register_tool_executor(name, &block) ⇒ Object



15
16
17
# File 'lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb', line 15

def register_tool_executor(name, &block)
  tool_executors[name] = block
end

.tool_executorsObject



11
12
13
# File 'lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb', line 11

def tool_executors
  @tool_executors ||= {}
end