From d40a5c34e54a80b028e53674e56cf621d7822a90 Mon Sep 17 00:00:00 2001 From: Charly Poly <1252066+charlypoly@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:00:12 +0100 Subject: [PATCH] fix(adapters/openai): safely parse non-string tool return value for Function calling (#50) * fix(adapters/openai): safely parse non-strong tool return value for Function calling * Create fresh-mangos-fail.md --- .changeset/fresh-mangos-fail.md | 5 +++++ src/adapters/openai.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/fresh-mangos-fail.md diff --git a/.changeset/fresh-mangos-fail.md b/.changeset/fresh-mangos-fail.md new file mode 100644 index 0000000..ef79537 --- /dev/null +++ b/.changeset/fresh-mangos-fail.md @@ -0,0 +1,5 @@ +--- +"@inngest/agent-kit": patch +--- + +fix(adapters/openai): safely parse non-strong tool return value for Function calling diff --git a/src/adapters/openai.ts b/src/adapters/openai.ts index 4e9a975..97412c6 100644 --- a/src/adapters/openai.ts +++ b/src/adapters/openai.ts @@ -51,7 +51,11 @@ export const requestParser: AgenticModel.RequestParser = ( case "tool_result": return { role: "tool", - content: m.content, + tool_call_id: m.tool.id, + content: + typeof m.content === "string" + ? m.content + : JSON.stringify(m.content), }; } }) as AiAdapter.Input["messages"],