Open muradsofi opened 4 days ago
I previously reported an issue where tools registered using addTool
in the server-side context (via the relay server's instance of RealtimeClient
) were not triggering their handlers when invoked. I followed up with a patch as per the approach mentioned [here](https://github.com/openai/openai-realtime-api-beta/issues/14#issuecomment-2395041263).
Installed patch-package
:
npm i patch-package --save-dev
.@openai+realtime-api-beta+0.0.0.patch
to the patches
folder.package.json
with the "postinstall": "patch-package"
script.Applied the patch:
addTool
when invoked from the client side.addTool
is used on the server side, the tool's handler is not triggered.However, if the tool description (not the function) is added client-side in the updateSession
call, the server-side handler for the tool begins to work. Example:
client.updateSession({
turn_detection: { type: 'server_vad' },
tool_choice: 'auto',
tools: [
{
type: 'function',
name: 'get_weather',
description: 'Retrieve current weather information for a given location.',
parameters: {
type: 'object',
properties: {
lat: {
type: 'number',
description: 'Latitude of the location.',
},
lng: {
type: 'number',
description: 'Longitude of the location.',
},
location: {
type: 'string',
description: 'Name of the location.',
},
},
required: ['lat', 'lng', 'location'],
},
},
],
});
Could you provide clarification on the expected behavior for server-side tool registration using addTool
? Additionally, any insights on resolving this issue without needing redundant client-side updates would be helpful.
Thank you for your support!
Description
We are trying to use the
addTool
function in the relay server's instance ofRealtimeClient
, but it seems the tool handlers are never triggered when the tool is invoked. Instead, the tool logic appears to be bypassed entirely.Here's a minimal code example demonstrating the issue:
Code Example
Expected Behavior
When the
get_weather
tool is invoked, the handler defined inaddTool
should be triggered, and its logic (e.g., logging"get_weather tool called with location: "
) should execute.Observed Behavior
The tool appears to be registered, but its handler is never triggered when the tool is called.
Questions
addTool
be supported in relay server environments, or is there a limitation in how tools are executed server-side?addTool
in the relay server?Thank you for looking into this! Let me know if additional details or test cases are needed.