(tc: ToolCall)
| 55 | } |
| 56 | |
| 57 | export function formatToolCallMd(tc: ToolCall): string { |
| 58 | const argsRaw = tc.arguments ?? '{}'; |
| 59 | const hint = extractToolCallHint(argsRaw); |
| 60 | let title = `#### Tool Call: ${tc.name}`; |
| 61 | if (hint) { |
| 62 | title += ` (\`${hint}\`)`; |
| 63 | } |
| 64 | |
| 65 | let argsFormatted: string; |
| 66 | try { |
| 67 | argsFormatted = JSON.stringify(JSON.parse(argsRaw), null, 2); |
| 68 | } catch { |
| 69 | argsFormatted = argsRaw; |
| 70 | } |
| 71 | |
| 72 | return `${title}\n<!-- call_id: ${tc.id} -->\n\`\`\`json\n${argsFormatted}\n\`\`\``; |
| 73 | } |
| 74 | |
| 75 | function formatToolResultMd(msg: ContextMessage, toolName: string, hint: string): string { |
| 76 | const callId = msg.toolCallId ?? 'unknown'; |
no test coverage detected