Resumed streamed run emits `tool_output` for the approved call without a tool name (and no `tool_called`)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
Start with the repro script: run it to see that the resumed stream yields a tool_output item whose ToolCallOutputItem has only call_id, output and type. Find where Runner.run_streamed handles a resumed RunState and where the approved call's output item is created. Choosing between adding a tool name to ToolCallOutputItem and emitting tool_called on resume is a design decision to settle with maintainers first. Done means a resumed stream lets a fresh consumer identify the tool behind each output, with a test covering the approval resume path.
由索引模型根据 Issue 内容生成。
描述
Please read this first
- Have you read the docs? Yes
- Have you searched for related issues? Yes, found none covering stream events across an approval resume.
Describe the bug
When a streamed run pauses on a needs_approval tool and is resumed from RunState, the resumed stream emits tool_output for the approved call but no tool_called. ToolCallOutputItem carries only call_id, output and type, with no tool name.
A stream consumer that starts fresh on resume, which is the usual case when the pause outlives the process (a human approves minutes later, on another worker), can't tell which tool produced the output without separately persisting a call_id → name map from the first run.
Debug information
- Agents SDK version: 0.23.1 (also 0.22.3)
- Python version: 3.12
- Model and model provider: not involved (fake model below, no network)
- Does the issue reproduce with the latest Agents SDK release? Yes
- Does the issue occur consistently or intermittently? Consistently
Repro steps
import asyncio
from collections.abc import AsyncIterator
from typing import Any
from openai.types.responses import (
Response, ResponseCompletedEvent, ResponseFunctionToolCall, ResponseOutputMessage, ResponseOutputText,
)
from agents import Agent, ModelResponse, Runner, Usage, function_tool
from agents.models.interface import Model
def _resp(output: list[Any]) -> Response:
return Response(id="r", created_at=0, model="fake", object="response", output=output,
parallel_tool_calls=False, tool_choice="auto", tools=[])
class FakeModel(Model):
def __init__(self) -> None:
self.turns = [
[ResponseFunctionToolCall(type="function_call", call_id="call_1", name="delete_file",
arguments='{"path": "a.txt"}', id="fc_1")],
[ResponseOutputMessage(id="m", type="message", role="assistant", status="completed",
content=[ResponseOutputText(type="output_text", text="done", annotations=[])])],
]
def _next(self) -> list[Any]:
return self.turns.pop(0)
async def get_response(self, *a: Any, **k: Any) -> ModelResponse:
return ModelResponse(output=self._next(), usage=Usage(), response_id="r")
async def stream_response(self, *a: Any, **k: Any) -> AsyncIterator[Any]:
yield ResponseCompletedEvent(type="response.completed", response=_resp(self._next()), sequence_number=0)
@function_tool(needs_approval=True)
def delete_file(path: str) -> str:
return f"deleted {path}"
async def main() -> None:
agent = Agent(name="a", model=FakeModel(), tools=[delete_file])
first = Runner.run_streamed(agent, "delete a.txt")
async for e in first.stream_events():
if e.type == "run_item_stream_event":
print("run 1:", e.name)
state = first.to_state()
state.approve(first.interruptions[0])
resumed = Runner.run_streamed(agent, state)
async for e in resumed.stream_events():
if e.type == "run_item_stream_event":
item = e.item
print("resume:", e.name, type(item).__name__,
"raw_item keys:", sorted(item.raw_item.keys()) if isinstance(item.raw_item, dict) else type(item.raw_item).__name__)
asyncio.run(main())
Output:
run 1: tool_called
resume: tool_output ToolCallOutputItem raw_item keys: ['call_id', 'output', 'type']
resume: message_output_created MessageOutputItem raw_item keys: ResponseOutputMessage
Expected behavior
The resumed stream identifies the tool behind each output. Either:
- add the tool name to
ToolCallOutputItem(e.g.tool_name), which also helps outside resume, since function-call output items never carry a name; or - emit
tool_calledfor the approved call when the run resumes.
- 主要语言
- Python
- 星标
- 30.4k
- 派生
- 4.9k
- 平均合并
- 19 小时 5 分钟
- 30 天内合并 PR
- 90
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openai/openai-agents-python 的其他 Issue
-
Docs: `tool_choice="required"` can select a state-changing tool when the needed one is not shown未关闭
难度 1/5 1 小时以内 新手友好度 90/100
openai/openai-agents-python#5461 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
openai/openai-agents-python#5460 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
openai/openai-agents-python#5459 · 4 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
openai/openai-agents-python#5458 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
openai/openai-agents-python#5455 ·
维护者通常 1 天内回复
查看 openai/openai-agents-python 的全部 Issue
相似的 Issue
-
question
难度 2/5 1-3 小时 新手友好度 62/100
conda-forge/vc-feedstock#132 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
limitlessprojects/Go-Hybrid#3342 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
UKGovernmentBEIS/inspect_ai#6268 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
LSSTDESC/rail_sompz#42 ·
-
难度 2/5 1-3 小时 新手友好度 66/100
pytest-dev/pytest-forked#113 ·