MCPcopy Index your code
hub / github.com/TanStack/ai / findToolCallPart

Function findToolCallPart

packages/ai-client/tests/chat-client-context.test.ts:8–24  ·  view source on GitHub ↗
(client: ChatClient, toolCallId: string)

Source from the content-addressed store, hash-verified

6import type { ConnectConnectionAdapter } from '../src/connection-adapters'
7
8function findToolCallPart(client: ChatClient, toolCallId: string) {
9 for (const message of client.getMessages()) {
10 if (message.role !== 'assistant') {
11 continue
12 }
13
14 const part = message.parts.find(
15 (messagePart) =>
16 messagePart.type === 'tool-call' && messagePart.id === toolCallId,
17 )
18 if (part) {
19 return part
20 }
21 }
22
23 return undefined
24}
25
26function findToolResultPart(client: ChatClient, toolCallId: string) {
27 for (const message of client.getMessages()) {

Callers 1

Calls 1

getMessagesMethod · 0.45

Tested by

no test coverage detected