---
type: email
from: Wen-Tien Chang <notifications@github.com>
subject: Re: [openai/openai-agents-python] Tool Call doesn't work when using

 Structured Outputs (Issue #1778)
received: 2026-03-06 07:39:58
date_header: Sun, 21 Sep 2025 09:27:18 -0700
priority: normal
status: awaiting_approval
uid: 30920
---

## Email Content

**From:** Wen-Tien Chang <notifications@github.com>
**Subject:** Re: [openai/openai-agents-python] Tool Call doesn't work when using

 Structured Outputs (Issue #1778)
**Date:** Sun, 21 Sep 2025 09:27:18 -0700

### Body (preview)

ihower left a comment (openai/openai-agents-python#1778)



If you still want to use the OpenAI Agents SDK with Kimi K2, you can take inspiration from Google ADK’s approach:



Don’t use output_type, and instead provide an extra tool like `generate_final_answer`. In your prompt, instruct the model to call this tool for its final answer.



Also, the OpenAI Agents SDK has a key feature: tool_use_behavior with StopAtTools, you can terminate once the model calls your specified function.



Here’s a example code, it basically does the same thing as Google ADK’s method, without relying on opaque hacks:



```

from agents import Agent, function_tool, Runner

from agents.extensions.models.litellm_model import LitellmModel



from pydantic import BaseModel, Field

import os

import asyncio

from dotenv import load_dotenv

load_dotenv()



from agents.agent import StopAtTools





class WeatherOutput(BaseModel):

    is_good_weather: bool = Field(..., description='Is the weather good for travel or outdoor activitied?')

    details: str = Field(..., description='Give the detailed weather report.')



@function_tool

def get_weather(city: str) -> str:

    """

    Use this tool to get the weather for a city

    """

    print(f"------ Getting weather for {city}...")



    return f'Current weather in {city} is jublious like a rainbow.'



@function_tool

def generate_final_answer(is_good_weather:str , details: str):

    """

    Use this for final answer

    Args:

        is_good_weather: Is the weather good for travel or outdoor activitied?

        details: Give the detailed weather report.



    """

    return { "is_good_weather": is_good_weather, "details": details }



def weather_friend(prompt: str):

    model = LitellmModel(model="openrouter/moonshotai/kimi-k2")

    agent = Agent(

        name="Weather Agent",

        instructions=(

            "You are a helpful weather assistant. "

            "Always call the get_weather tool to gather weather data. "

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
