Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Approved tool runs again if the process stops after it ran but before the run state was stored

未关闭 适合新手
#5,409 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

阅读 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):

  1. Runner.run(agent, "pay alice 10") stops with an interruption for pay(amount=10, to="alice"), a @function_tool(needs_approval=True). I store result.to_state().to_json().
  2. The person approves: RunState.from_json, state.approve(item), I store the approved state, then Runner.run(agent, state). The tool pays, and the process dies (os._exit) before anything else is stored.
  3. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openai/openai-agents-python 的其他 Issue

查看 openai/openai-agents-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。