Default tool error text tells the model to "try again" after a call that may already have taken effect

オープン 初心者向け
#5,573 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Anurag07-crypto がすでに取り組んでいます。

2026年11月7日 から。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai

調査の方向性

デフォルトの failure_error_function と、ツールのエラー処理を説明するドキュメントを探してください。まずデフォルトのメッセージを見つけ、例外がどのようにツールの出力に変換されるかを確認してください。デフォルトの文言を変更し、操作がすでに反映されている可能性を警告して、再試行する前に確認するよう促してください。関連するテストまたはドキュメントで期待される動作を確認してください。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

An agent built on this SDK can send a write twice when a tool's reply is lost. The default failure_error_function tells the model "An error occurred while running the tool. Please try again." after every tool exception, including one raised after the effect happened. In the repro the first POST commits and the reply is lost; the model follows the text, calls again, and the service holds two orders. The SDK has no tool-retry setting, so for a tool that writes and keeps the default, this text is its retry path.

Debug information
Agents SDK version: 0.24.0 (`default_tool_error_function` is unchanged on main at 27c75c5)
Related library versions: openai 3.46.0, requests 2.34.2, pydantic 2.14.3
Python version: 3.12.14
Operating system: Linux (Ubuntu 24.04)
Model and model provider: `agents.testing.ScriptedModel`, standing in for a live model that follows the tool output
Does the issue reproduce with the latest Agents SDK release? Yes
Does the issue occur consistently or intermittently? Consistently
tool outputs the model saw: ['An error occurred while running the tool. Please try again.', 'created']
orders committed: 2
Repro steps
import http.server
import json
import os
import threading

import requests
from agents import Agent, Runner, function_tool
from agents.testing import ScriptedModel, assistant_message, function_call

os.environ.setdefault("OPENAI_AGENTS_DISABLE_TRACING", "1")
ORDERS = []  # what the order service has committed


class OrderService(http.server.BaseHTTPRequestHandler):
    def do_POST(self):
        body = self.rfile.read(int(self.headers["Content-Length"]))
        ORDERS.append(json.loads(body))  # the order is committed here
        if len(ORDERS) == 1:
            self.close_connection = True  # the reply is lost: close without answering
            return
        self.send_response(200)
        self.send_header("Content-Length", "2")
        self.end_headers()
        self.wfile.write(b"ok")

    def log_message(self, *args):
        pass


server = http.server.HTTPServer(("127.0.0.1", 0), OrderService)
threading.Thread(target=server.serve_forever, daemon=True).start()
URL = f"http://127.0.0.1:{server.server_port}/orders"


@function_tool
def create_order(sku: str, quantity: int) -> str:
    """Create an order."""
    requests.post(URL, json={"sku": sku, "quantity": quantity}).raise_for_status()
    return "created"


seen = []


def respond(call):
    # Stands in for a live model: it follows the tool output's instruction to try again.
    last = call.input[-1] if isinstance(call.input, list) else {}
    if isinstance(last, dict) and last.get("type") == "function_call_output":
        seen.append(last["output"])
        if "try again" not in last["output"]:
            return [assistant_message("done")]
    return [function_call("create_order", {"sku": "A1", "quantity": 1}, call_id=f"c{len(seen)}")]


agent = Agent(name="orders", tools=[create_order], model=ScriptedModel([{"responder": respond}] * 4))
Runner.run_sync(agent, "Order one A1.")
print("tool outputs the model saw:", seen)
print("orders committed:", len(ORDERS))
Expected behavior

A default that doesn't ask for a resend, such as "The tool call failed and may or may not have taken effect. Check before calling it again." Or keep it and document that a tool with side effects needs its own failure_error_function; either change is one string or one doc paragraph, and your users' tools that write stop resending by default.

In agent-evidence-vectors 0.35.0, a public corpus of eight lost-reply scenarios, a @function_tool with the default text and a model that follows it fails four. I can send a test that pins it, kept current by Dependabot, and checks each run with agent-evidence-verify 0.5.0, a checker that gives each run a verdict. Which option would you take?

主要言語
Python
スター
30.5k
フォーク
5k
平均マージ
16時間 15分
マージ済み PR(30日)
154

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openai/openai-agents-python のほかの issue

openai/openai-agents-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。