Skip to content

ValueError: tool_choice and tool_config.tool_choice must match #175

@kumardevendra

Description

@kumardevendra

Not able to set tool_choice to "required"

Below is my code...

self.agent_config = AgentConfig(
            model=MODEL_NAME,
            instructions=WEB_SEARCH_INSTRUNCTION_PROMPT,
            sampling_params={
                "strategy": {
                    "type": "greedy",
                },
            },
            toolgroups=["builtin::websearch"],
            tool_choice="required", # This is throwing error when changed to required from auto.
            input_shields=[],
            output_shields=[],
            enable_session_persistence=False,
        )

Error Logs ....

Traceback (most recent call last):
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/distribution/server/server.py", line 208, in sse_generator
2025-03-01 15:56:53     async for item in event_gen:
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/providers/inline/agents/meta_reference/agents.py", line 169, in _create_agent_turn_streaming
2025-03-01 15:56:53     async for event in agent.create_and_execute_turn(request):
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 189, in create_and_execute_turn
2025-03-01 15:56:53     async for chunk in self.run(
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 258, in run
2025-03-01 15:56:53     async for res in self._run(
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 493, in _run
2025-03-01 15:56:53     async for chunk in await self.inference_api.chat_completion(
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/providers/utils/telemetry/trace_protocol.py", line 89, in async_wrapper
2025-03-01 15:56:53     result = await method(self, *args, **kwargs)
2025-03-01 15:56:53   File "/usr/local/lib/python3.10/site-packages/llama_stack/distribution/routers/routers.py", line 144, in chat_completion
2025-03-01 15:56:53     raise ValueError("tool_choice and tool_config.tool_choice must match")
2025-03-01 15:56:53 ValueError: tool_choice and tool_config.tool_choice must match

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions