MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / serializeToolUse

Function serializeToolUse

src/utils/tiktoken.ts:13–23  ·  view source on GitHub ↗

* Serializes a tool_use block to text for token counting. * Approximates how the API sees the tool call.

(block: Anthropic.Messages.ToolUseBlockParam)

Source from the content-addressed store, hash-verified

11 * Approximates how the API sees the tool call.
12 */
13function serializeToolUse(block: Anthropic.Messages.ToolUseBlockParam): string {
14 const parts = [`Tool: ${block.name}`]
15 if (block.input !== undefined) {
16 try {
17 parts.push(`Arguments: ${JSON.stringify(block.input)}`)
18 } catch {
19 parts.push(`Arguments: [serialization error]`)
20 }
21 }
22 return parts.join("\n")
23}
24
25/**
26 * Serializes a tool_result block to text for token counting.

Callers 1

tiktokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected