Skip to content

chat completion model failed to produce multiple tool call items #989

Closed

Description

@DeoLeung

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have faced similar issues.

Describe the bug

when using chatcompletionmodel with multiple hosted tools

triage_agent = Agent(
    name='Triage Agent',
    model=OpenAIChatCompletionsModel(
      model='gpt-4.1-mini',
      openai_client=client,
    ),
    instructions=config.triage_agent_instruction,
    model_settings=model_settings,
    tools=[weather_info, query_tourist_flow_rate],
    handoffs=[rag_agent],
  )

if user ask for multiple tool calls, it generates error

agents.exceptions.ModelBehaviorError: Tool weather_infoquery_tourist_flow_rate not found in agent Triage Agent

which has tools name concatted

from code
https://github.com/openai/openai-agents-python/blob/main/src/agents/models/chatcmpl_stream_handler.py#L261

it seems items don't have index but different id

** [ChoiceDeltaToolCall(index=0, id='call_cPe57YrMaFpbXhQYRIBFTbmO', function=ChoiceDeltaToolCallFunction(arguments='', name='weather_info'), type='function')]
* ChoiceDeltaToolCall(index=0, id='call_cPe57YrMaFpbXhQYRIBFTbmO', function=ChoiceDeltaToolCallFunction(arguments='', name='weather_info'), type='function')
** [ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments='{"administrative_district":"abc"}', name=None), type='function')]
* ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments='{"administrative_district":"abc"}', name=None), type='function')
** [ChoiceDeltaToolCall(index=0, id='call_oiLhVNjG001wkgGmIthY6lxg', function=ChoiceDeltaToolCallFunction(arguments='', name='query_tourist_flow_rate'), type='function')]
* ChoiceDeltaToolCall(index=0, id='call_oiLhVNjG001wkgGmIthY6lxg', function=ChoiceDeltaToolCallFunction(arguments='', name='query_tourist_flow_rate'), type='function')
** [ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments='{"scenic_areas":["ddd"]}', name=None), type='function')]
* ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments='{"scenic_areas":["ddd"]}', name=None), type='function')

should fix the index or make use of the id?

Debug information

  • Agents SDK version: (e.g. v0.1.0)
  • Python version (e.g. Python 3.12)

Repro steps

make an agent with multiple hosted tools and ask for them

Expected behavior

should produce two tools

Activity

  1. DeoLeung commented on Jul 2, 2025

    @DeoLeung
    ContributorAuthor

    argh, i think it should be the problem of my gateway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions