Approved tool runs again if the process stops after it ran but before the run state was stored
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- ai, backend, documentation
调研方向
阅读 human-in-the-loop 文档,尤其是涵盖 needs_approval、state.approve 和 RunState.to_json / from_json 的部分。明确说明:如果进程在更新后的状态存储之前停止,已获批准并恢复的工具运行是否可能再次执行;并记录其行为,提供有关幂等性或检查外部系统的指导。完成标准是文档解释了这个故障窗口,并且读者能够判断如何让工具可以安全重试。
由索引模型根据 Issue 内容生成。
描述
Please read this first
- Have you read the docs? Yes: human-in-the-loop (
needs_approval,state.approve,RunState.to_json/from_json). - Have you searched for related issues? Yes. #5239 and #4827 are about resuming after an approval, but not this case.
Question
Is it intended that an approved tool can run twice if the process stops after the tool ran but before the new run state was stored? I'd like to check that I'm resuming the intended way.
Setup (openai-agents 0.24.0, Python 3.12.10, a fake Model, no network):
Runner.run(agent, "pay alice 10")stops with an interruption forpay(amount=10, to="alice"), a@function_tool(needs_approval=True). I storeresult.to_state().to_json().- The person approves:
RunState.from_json,state.approve(item), I store the approved state, thenRunner.run(agent, state). The tool pays, and the process dies (os._exit) before anything else is stored. - A new process loads the stored approved state and calls
Runner.run(agent, state)again, because that is all it has.
Observed: the tool runs again: 2 payments, in 3 of 3 runs.
I think this is the expected at-least-once behaviour: the stored state can't know the tool already ran. If so, would a short note in the human-in-the-loop docs help? For example: "an approved tool can run more than once if the process stops before you store the new state; make the tool idempotent (for example with an idempotency key) or check the outside system first." I'm happy to send a docs PR if a maintainer wants one.
Disclosure: I'm the author of Call4Agents, a small library for this problem. I plan to publish these numbers, with the same runs for LangGraph and Pydantic AI (pydantic/pydantic-ai#10926), on or after 2026-11-05. I can paste the script here if it helps.
- 主要语言
- Python
- 星标
- 30.2k
- 派生
- 4.9k
- 平均合并
- 11 小时 46 分钟
- 30 天内合并 PR
- 160
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openai/openai-agents-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
openai/openai-agents-python#5405 ·
维护者通常 1 天内回复
-
fix(typing): explicitly specialize ToolContext[Any] in ToolFunctionWithToolContext可能已有人在做 @AbarnaaSree 于 4 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
openai/openai-agents-python#5387 · 3 条评论 ·
维护者通常 1 天内回复
-
ShellTool: empty ShellResult(output=[]) fabricates stdout "(no output)" in the model-visible shell_call_output and persisted shell_output可能已有人在做 @AbarnaaSree 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
openai/openai-agents-python#5348 · 10 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 15/100
openai/openai-agents-python#5408 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
openai/openai-agents-python#5407 ·
维护者通常 1 天内回复
查看 openai/openai-agents-python 的全部 Issue
相似的 Issue
-
[oblt-aw][autodoc] Update workflow docs for gh-aw v0.92.5 and detector permission scope可能已有人在做 @github-actions 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
roadmap-100
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
comp/tools P2 tool/browser tool/file type/bug
难度 2/5 1-3 小时 新手友好度 75/100
NousResearch/hermes-agent#143418 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
python-hyper/uritemplate#164 ·