Skip to content

Commit 32c20e1

Browse files
askme765csask
authored andcommitted
Fix OpenAI ChatCompletion message content format issue (#106)
- Modified `execute_tool_call` method in OpenAIAugmentedLLM to convert content list to string - Used "\n".join() to concatenate list items into a single string - This addresses issue #25 where OpenAI API rejects list-type content - Follows OpenAI API specification requiring content to be string or null - Prevents errors with LLMs like deepseek that strictly validate input format The change ensures compatibility with OpenAI's API requirements which specify: "content can only be a string or null. It cannot be a list, object, or any other type." Co-authored-by: ask <[email protected]>
1 parent 350e1a3 commit 32c20e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mcp_agent/workflows/llm/augmented_llm_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ async def execute_tool_call(
376376
return ChatCompletionToolMessageParam(
377377
role="tool",
378378
tool_call_id=tool_call_id,
379-
content=[mcp_content_to_openai_content(c) for c in result.content],
379+
content="\n".join(str(mcp_content_to_openai_content(c)) for c in result.content),
380380
)
381381

382382
return None

0 commit comments

Comments
 (0)