---
type: email
from: Wen-Tien Chang <notifications@github.com>
subject: [openai/openai-agents-python] Prevent preamble messages from being

 treated as final output when tool calls are pending (PR #1689)
received: 2026-03-06 07:25:07
date_header: Mon, 08 Sep 2025 06:51:17 -0700
priority: normal
status: awaiting_approval
uid: 29792
---

## Email Content

**From:** Wen-Tien Chang <notifications@github.com>
**Subject:** [openai/openai-agents-python] Prevent preamble messages from being

 treated as final output when tool calls are pending (PR #1689)
**Date:** Mon, 08 Sep 2025 06:51:17 -0700

### Body (preview)

# Issue



When using structured outputs, if the model produces both a message and a function call in the same turn,

the agent would terminate prematurely.



This behavior has become much easier to reproduce with GPT-5 tool calling + preambles.

Earlier models could also occasionally produce such outputs. For example, in GPT-4.1, if the prompt instructed the model to think before calling a tool—making it possible to encounter random failures whenever output_type was specified.



I think this fix should also resolve [openai/openai-agents-python#1061](https://github.com/openai/openai-agents-python/issues/1061).



# Reproducible Example



```

from dataclasses import dataclass

from agents import Agent, Runner, function_tool



@dataclass

class QueryResult:

    content: str    



@function_tool

def get_weather(city: str) -&gt; str:

    return &quot;hot&quot;



agent = Agent(

    name=&quot;Test preamble issue&quot;,

    instructions=&quot;&quot;&quot;You are a helpful agent. &lt;tool_preambles&gt;

- Always begin by rephrasing the user&#39;s goal in a friendly, clear, and concise manner, before calling any tools.

- Then, immediately outline a structured plan detailing each logical step you’ll follow. 

- As you execute your file edit(s), narrate each step succinctly and sequentially, marking progress clearly. 

- Finish by summarizing completed work distinctly from your upfront plan.

&lt;/tool_preambles&gt;

For the final answer, no plan is needed - just return the result.

&quot;&quot;&quot;,

    model=&quot;gpt-5&quot;,

    tools=[get_weather],

    output_type=QueryResult,

)



result = Runner.run_sync(agent, input=&quot;What&#39;s the weather in Hsinchu?&quot;)



print(result.to_input_list())

print(&quot;--------------------------------&quot;)

print(result.final_output)

```



## Example Output (before this fix)



The to_input_list() looks like:

```

[

  {&quot;content&quot;: &quot;What&#39;s the weather in Hsinchu?&quot;, &quot;role&quot

---

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