Skip to content

Commit c352690

Browse files
committed
fix: conditionally include tools field in session config only when tools are present
- Modified #getSessionConfig to only include tools field when #currentTools.length > 0 - Fixes failing test 'does not include tools field when no tools are provided' - Preserves existing behavior for agents with actual tools
1 parent 7ac51d4 commit c352690

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/agents-realtime/src/realtimeSession.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,14 @@ export class RealtimeSession<
340340
// Use session config voice if provided, otherwise fall back to agent voice
341341
voice: base.voice ?? this.#currentAgent.voice,
342342
model: this.options.model,
343-
tools: this.#currentTools,
344343
tracing: tracingConfig,
345344
};
346345

346+
// Only include tools field if there are actually tools
347+
if (this.#currentTools.length > 0) {
348+
fullConfig.tools = this.#currentTools;
349+
}
350+
347351
// Update our cache so subsequent updates inherit the full set including any
348352
// dynamic fields we just overwrote.
349353
this.#lastSessionConfig = fullConfig;

0 commit comments

Comments
 (0)