Skip to content

Commit 39f74dd

Browse files
committed
fix(realtime): narrow currentAgent type for getAllTools
1 parent 48ebb1c commit 39f74dd

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/agents-realtime/src/realtimeSession.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,11 @@ export class RealtimeSession<
275275
const handoffTools = handoffs.map((handoff) =>
276276
handoff.getHandoffAsFunctionTool(),
277277
);
278+
const allTools = await (
279+
this.#currentAgent as RealtimeAgent<TBaseContext>
280+
).getAllTools(this.#context);
278281
this.#currentTools = [
279-
...(await this.#currentAgent.getAllTools(this.#context)).filter(
280-
(tool) => tool.type === 'function',
281-
),
282+
...allTools.filter((tool) => tool.type === 'function'),
282283
...handoffTools,
283284
];
284285
}
@@ -445,12 +446,10 @@ export class RealtimeSession<
445446
.map((handoff) => [handoff.toolName, handoff]),
446447
);
447448

448-
const functionToolMap = new Map(
449-
(await this.#currentAgent.getAllTools(this.#context)).map((tool) => [
450-
tool.name,
451-
tool,
452-
]),
453-
);
449+
const allTools = await (
450+
this.#currentAgent as RealtimeAgent<TBaseContext>
451+
).getAllTools(this.#context);
452+
const functionToolMap = new Map(allTools.map((tool) => [tool.name, tool]));
454453

455454
const possibleHandoff = handoffMap.get(toolCall.name);
456455
if (possibleHandoff) {

0 commit comments

Comments
 (0)