-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Description
Python -VV
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]Pip Freeze
annotated-types==0.7.0
anyio==4.9.0
certifi==2025.4.26
eval_type_backport==0.2.2
exceptiongroup==1.3.0
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.10
mistralai==1.8.1
pydantic==2.11.5
pydantic_core==2.33.2
python-dateutil==2.9.0.post0
six==1.17.0
sniffio==1.3.1
typing-inspection==0.4.1
typing_extensions==4.14.0Reproduction Steps
i am having issues with function calling from within agents. My workflow is as follows:
- user starts conversation with agent
- response is added to history then analysed
- if function call, execute function and add result to history and start conversation again
- now i get this error:
[ERROR] API error occurred: Status 400 {"object":"Error","message":"Not the same number of function calls and responses","type":"invalid_request_error","code":3230}
example code:
api_history = [
{
"role": "user",
"content": "i found a stray dog. the dog is white with a blue collar. it was found at 55 flower avenue. my email is [email protected]"
},
{
"role": "assistant",
"content": "",
"tool_call_id": "eKp7ETcvQ",
"name": "submit_animal_found_report",
"result": ""
},
{
"role": "tool",
"content": {
"status": "success",
"report_id": "03075",
"message": "Animal control has been notified. They may contact you for details."
},
"tool_call_id": "eKp7ETcvQ",
"name": "submit_animal_found_report",
"result": {
"status": "success",
"report_id": "FOUND-03075d",
"message": "Animal control has been notified. They may contact you for details."
}
}
]
response = client.beta.conversations.start(
agent_id=self.current_agent_id,
inputs=api_history,
store=False,
handoff_execution="client"
)
not sure how number of function calls and responses are calculated. In ts client, I add toolcalls to assistant message and it works
{
id: string;
function: {
name: string;
arguments: string;
};
}[]
but python sdk doesn't accept additional fields like tool_calls.
Everytime I run client.beta.conversations.start(...) because I am not saving converstation on the cloud so can't use conversations.update(...). It works except for when I add function call.
Thank you!
Expected Behavior
agent continues conversation normally
Additional Context
No response
Suggested Solutions
No response
Metadata
Metadata
Assignees
Labels
No labels