Skip to content

Commit

Permalink
fix(adapters/openai): safely parse non-string tool return value for F…
Browse files Browse the repository at this point in the history
…unction calling (#50)

* fix(adapters/openai): safely parse non-strong tool return value for Function calling

* Create fresh-mangos-fail.md
  • Loading branch information
charlypoly authored Jan 16, 2025
1 parent 60579b6 commit d40a5c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fresh-mangos-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inngest/agent-kit": patch
---

fix(adapters/openai): safely parse non-strong tool return value for Function calling
6 changes: 5 additions & 1 deletion src/adapters/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export const requestParser: AgenticModel.RequestParser<OpenAi.AiModel> = (
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<OpenAi.AiModel>["messages"],
Expand Down

0 comments on commit d40a5c3

Please sign in to comment.