Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#5,409 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
ai, backend, documentation

Hướng nghiên cứu

Đọc tài liệu về human-in-the-loop, đặc biệt là các phần đề cập đến needs_approval, state.approve và RunState.to_json / from_json. Làm rõ liệu một lần chạy công cụ đã được phê duyệt và tiếp tục có thể chạy lại nếu tiến trình dừng trước khi trạng thái đã cập nhật được lưu hay không, đồng thời ghi lại hành vi này cùng hướng dẫn về tính idempotent hoặc cách kiểm tra hệ thống bên ngoài. Công việc được xem là hoàn thành khi tài liệu giải thích khoảng thời gian xảy ra lỗi này và người đọc có thể xác định cách làm cho công cụ an toàn khi thử lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
30.2k
Fork
4.9k
Merge trung bình
11 giờ 46 phút
Pull request đã merge (30 ngày)
160

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/openai-agents-python

Tất cả issue của openai/openai-agents-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.