---
type: email
from: Abbas Asad <notifications@github.com>
subject: [openai/openai-agents-python] Fix: Eliminate unreachable type check

 in function tool call handling (PR #1702)
received: 2026-03-06 07:26:53
date_header: Tue, 09 Sep 2025 15:14:39 -0700
priority: normal
status: awaiting_approval
uid: 29959
---

## Email Content

**From:** Abbas Asad <notifications@github.com>
**Subject:** [openai/openai-agents-python] Fix: Eliminate unreachable type check

 in function tool call handling (PR #1702)
**Date:** Tue, 09 Sep 2025 15:14:39 -0700

### Body (preview)

## Summary



Eliminate a redundant type validation in the tool call response logic. The extra check was unreachable and served no purpose, making the code misleading and harder to read.



## Problem



The code contained a redundant type check that was logically impossible to reach:



```python

elif not isinstance(output, ResponseFunctionToolCall):

    logger.warning(f&quot;Unexpected output type, ignoring: {type(output)}&quot;)

    continue



# At this point we know it&#39;s a function tool call

if not isinstance(output, ResponseFunctionToolCall):  # This check can never be reached

    continue

```



The second type check (lines 495-497) could never be executed because:

- If `output` is NOT a `ResponseFunctionToolCall`, the first check would have already caused a `continue` and skipped the rest of the loop

- If `output` is a `ResponseFunctionToolCall`, the second check would always be false



## Changes Made



Removed the redundant and unreachable type check, leaving only the necessary logic:



```python

elif not isinstance(output, ResponseFunctionToolCall):

    logger.warning(f&quot;Unexpected output type, ignoring: {type(output)}&quot;)

    continue



# At this point we know it&#39;s a function tool call

tools_used.append(output.name)

```



This improves code clarity and eliminates dead code that could confuse developers and static analysis tools.

You can view, comment on, or merge this pull request online at:



  https://github.com/openai/openai-agents-python/pull/1702



-- Commit Summary --



  * Fix: Eliminate unreachable type check in function tool call handling



-- File Changes --



    M src/agents/_run_impl.py (3)



-- Patch Links --



https://github.com/openai/openai-agents-python/pull/1702.patch

https://github.com/openai/openai-agents-python/pull/1702.diff



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/pull/1702

You are receiving this because you are subscribed

---

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