Feature proposal: inherited recursion-depth budget for Agent.as_tool delegation
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with Agent.as_tool() in src/agents/agent.py, then trace how nested calls create Runner.run() and Runner.run_streamed() executions and how their turn limits are resolved. Review the existing runtime governance discussion #2775 and per-agent max_turns request #551 before deciding whether the proposed inherited depth limit fits the SDK. Done means maintainers settle the scope and semantics, including concurrent task inheritance and resumed workflows.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
I would like to propose an opt-in, inherited delegation-depth limit for Agent.as_tool() to help applications bound recursive or multi-agent delegation trees.
This is not a claim of a security vulnerability or a defect in max_turns. I understand that max_turns limits an individual Runner.run(), and a nested agent tool starts another run. The motivation is to offer an explicit SDK-side safety primitive when applications require a depth limit over a delegation chain, rather than just each run.
Reproduced behavior (no API access)
I ran a fully offline agents.testing.ScriptedModel test against public main commit cd26bbbc52847845fde73b9952b51e62e2bcbdc0 (v0.24.0 source) using distinct call IDs and a deliberately finite, four-delegation script.
- Outer
Runner.run(..., max_turns=1) - Recursive
Agent.as_tool(..., max_turns=1) - Unmodified SDK: 5 model calls occur before the outer run raises
MaxTurnsExceeded. This is consistent with per-run limits. - Candidate guard with
max_agent_tool_depth=1: 2 model calls occur; the next nested agent tool fails before starting another child run, including through streaming.
The source boundary is Agent.as_tool() in src/agents/agent.py, where each nested invocation creates its own Runner.run() / Runner.run_streamed() with a separately resolved turn limit.
Proposed narrow, compatible implementation
- Append optional
max_agent_tool_depth: int | None = NonetoAgent.as_tool().Nonepreserves current behavior. - Track active agent-tool depth in an async context using
ContextVar, withfinallyreset. - Propagate a configured limit through other agents'
as_tool()wrappers, even if those descendants do not configure a limit. Children may tighten but cannot relax an inherited bound. - Reject excessive delegation before another child run is started.
- No dependencies, persisted-state changes or wire-protocol changes.
Reproducible public research repository: https://github.com/BlackRonin-coder/openai-agents-recursive-budget-research
It contains the unmodified SDK reproducer, opt-in two-file patch, synthetic tests, and local verification log. The published candidate passed 1,188 relevant tests, 63 skipped, on macOS with Python 3.12.15; Ruff checks and a pristine-source patch-application check passed. I am not claiming comprehensive CI, independent validation or OpenAI endorsement.
Limitations and maintainer questions
This is a nesting-depth limit, not a root-owned cumulative model-turn, token, cost, wall-clock or cross-process execution budget. Application-initiated independent Runner.run() calls are outside this implementation. Further review is needed around concurrent task inheritance and resumed/persisted workflows.
- Would an opt-in inherited agent-tool depth limit be useful as a first-class SDK control?
- Or would you prefer a root-owned, cumulative execution budget with explicit checkpoint/cancellation semantics?
- If there is an existing supported mechanism addressing this exact delegation-depth use case, I would welcome a pointer and will revise or close the proposal.
Related but broader prior art: runtime governance discussions (e.g. #2775), and the existing per-agent max_turns feature request (#551). I did not find a directly equivalent recursive delegation-depth control in the currently indexed issues/PRs. This is offered as independently reproducible engineering research, not a claim of being the first person to explore recursive agent budgets.
Thank you for considering it.
- Ngôn ngữ chính
- Python
- Star
- 30.4k
- Fork
- 4.9k
- Merge trung bình
- 15 giờ 42 phút
- Pull request đã merge (30 ngày)
- 124
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 77/100
openai/openai-agents-python#5451 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(typing): explicitly specialize ToolContext[Any] in ToolFunctionWithToolContextCó thể làm lại được @AbarnaaSree đã nhận 11 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
openai/openai-agents-python#5387 · 4 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 53/100
openai/openai-agents-python#5450 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
function_tool rejects valid arguments when a parameter uses Pydantic strict mode (Enum, date, UUID)Có thể đã có người làm @Lahari25 đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
openai/openai-agents-python#5448 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
openai/openai-agents-python#5447 · 3 bình luận ·
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ự
-
Support .aac audio uploadsCó thể đã có người làm @julien731 đã nhận hôm nay. Đang mởfeature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nimblehq/audio-transcriber#153 ·
-
help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
antonyrag/ragleap-core#1062 ·
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
gke-labs/kube-agents#4321 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Git-Hospital/githealthcheck#61 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
changelog investigate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ramnes/notion-sdk-py#433 ·