RunState.from_string()/from_json() replace approval-checkpoint validation errors with RuntimeError('Error details are redacted.')
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
- 82/100
- Loại issue
- Lỗi
- Độ 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
- backend-api-design
Hướng nghiên cứu
Bắt đầu với _build_run_state_from_json và _TRUSTED_RUN_STATE_ERROR_MESSAGES trong src/agents/run_state.py, sau đó đọc cách RunState.from_json và from_string xử lý lỗi xác thực. Dùng ví dụ được cung cấp để tái hiện các trường hợp function_tool_approvals sai định dạng và kiểm tra xem đã có bài kiểm tra nào về khôi phục checkpoint chưa. Các trường hợp này phải phát sinh UserError kèm thông báo xác thực, tương tự như hành vi của tool_invocations.
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? Agents SDK docs Yes
- Have you searched for related issues? Yes. #4297 maintains the trusted-message list; I found no report about these messages.
Describe the bug
Restoring a checkpoint whose context.function_tool_approvals is malformed raises RuntimeError: Error details are redacted. instead of the UserError the validation code raises. Sibling checks keep their type and message: a malformed context.tool_invocations raises UserError: RunState tool_invocations must be a mapping. Applications that handle invalid checkpoints by catching UserError therefore miss this case, and the diagnostic is lost.
Cause: _build_run_state_from_json (src/agents/run_state.py) raises UserError with messages such as "RunState function_tool_approvals must be a list.", but those messages are not in _TRUSTED_RUN_STATE_ERROR_MESSAGES, so the redaction in RunState.from_json/from_string treats them as untrusted and replaces both the type and the message.
Debug information
- Agents SDK version: v0.24.0 (also reproduced on
mainat 27c75c5) - Related library versions (optional, e.g.
any-llm,litellm, orpydantic): openai 3.29.0, pydantic 2.12.3 - Python version: 3.12.13
- Operating system: Linux (aarch64)
- Model and model provider: None (no model call)
- Does the issue reproduce with the latest Agents SDK release? Yes (v0.24.0, and
mainat 27c75c5) - Does the issue occur consistently or intermittently? Consistently
tool_invocations = []: UserError: RunState tool_invocations must be a mapping.
function_tool_approvals = {}: RuntimeError: Error details are redacted.
invalid approval record: RuntimeError: Error details are redacted.
Repro steps
import asyncio
import json
from agents import Agent, RunContextWrapper, RunState
agent = Agent(name="Assistant")
checkpoint = json.loads(RunState(context=RunContextWrapper(context={}), original_input="Hi", starting_agent=agent).to_string())
async def restore(field, value):
damaged = json.loads(json.dumps(checkpoint))
damaged["context"][field] = value
try:
await RunState.from_string(agent, json.dumps(damaged))
except Exception as error:
return f"{type(error).__name__}: {error}"
async def main():
print("tool_invocations = []: ", await restore("tool_invocations", []))
print("function_tool_approvals = {}: ", await restore("function_tool_approvals", {"unexpected": "mapping"}))
print("invalid approval record: ", await restore("function_tool_approvals",
[{"tool_key": "save", "decision": ["invalid"]}]))
asyncio.run(main())
Expected behavior
All three lines report a UserError with the validation message, e.g. UserError: RunState function_tool_approvals must be a list.
- Ngôn ngữ chính
- Python
- Star
- 30.5k
- Fork
- 5k
- Merge trung bình
- 16 giờ 15 phút
- Pull request đã merge (30 ngày)
- 154
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openai/openai-agents-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
openai/openai-agents-python#5595 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Default tool error text tells the model to "try again" after a call that may already have taken effectCó thể đã có người làm @Anurag07-crypto đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
openai/openai-agents-python#5573 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
openai/openai-agents-python#5550 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
openai/openai-agents-python#5529 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
openai/openai-agents-python#5498 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của openai/openai-agents-python
Issue tương tự
-
integration: logger
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
home-assistant/core#191147 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation p4
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
MillenniumDawn/focus-tree-creation-tool#417 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CharlesP44/Beem_Energy#96 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
rheeloaded/paperpull#153 ·
Maintainer thường phản hồi trong vòng 1 ngày