agentsclimarketplace

Forcing tool use

Skill kjuhwa/skills-hub/skills/agents/forcing-tool-use

Force the model to call a specific tool or any tool on the first turn using tool_choice in ModelSettings.From its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill forcing-tool-use

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.2 KB, 377 tokens by cl100k_base, as published. Nobody here has run it

forcing-tool-use

Set model_settings=ModelSettings(tool_choice="required") to force the model to call at least one tool. Use tool_choice={"type": "function", "name": "my_tool"} to force a specific tool.

When to apply

When you need the agent to always use a tool on its first turn (e.g., always search before answering, always validate input). Prevents the model from skipping the tool and answering directly.

Core snippet

from agents import Agent, ModelSettings, function_tool

@function_tool
def search_knowledge_base(query: str) -> str:
    """Search the knowledge base for relevant information."""
    return f"Results for: {query}"

# Force any tool call
agent = Agent(
    name="Research assistant",
    instructions="Always search before answering.",
    tools=[search_knowledge_base],
    model_settings=ModelSettings(tool_choice="required"),
    reset_tool_choice=True,  # Default: reset after first tool call to avoid loops
)

# Force a specific tool
agent_specific = Agent(
    name="Search assistant",
    tools=[search_knowledge_base],
    model_settings=ModelSettings(
        tool_choice={"type": "function", "name": "search_knowledge_base"}
    ),
    reset_tool_choice=True,
)

Key notes

  • tool_choice="required": model must call at least one tool
  • tool_choice="auto": model decides whether to call a tool (default)
  • tool_choice="none": model cannot call any tool
  • reset_tool_choice=True (default): resets tool_choice to "auto" after the first tool call to avoid infinite tool loops
  • Set reset_tool_choice=False if you want every turn to require a tool call

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,764. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.