Skip to content

Extend RunBudget with shared tool and delegation limits - #6211

Open
markstuart-oai wants to merge 3 commits into
markstuart/sdk-controls-04-conversation-forksfrom
markstuart/sdk-controls-05-budgets-delegation
Open

markstuart-oai wants to merge 3 commits into
markstuart/sdk-controls-04-conversation-forksfrom
markstuart/sdk-controls-05-budgets-delegation

Conversation

@markstuart-oai

@markstuart-oai markstuart-oai commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Why

A coordinator has two tool starts available for a task. Giving every delegated agent a separate allowance lets the combined work exceed that limit.

Summary

RunBudget can share limits across Python SDK agents. For an existing coordinator named parent, delegation consumes one start and the child's lookup consumes the other.

budget = RunBudget(max_tool_starts=2, share_with_children=True)
result = await Runner.run(parent, "Check the release.", run_config={"budget": budget})

The complete example also restricts delegation and tools. Resume preserves usage. A name grant covers every matching handler sharing the budget. Handoff callbacks require separate authorization.

CodexProvider supports per-run outer requests and SDK tool starts, rejects shared child budgets and cannot cap native calls or spending.

Parent #6210.

Test plan

Tests passed for concurrent reservations, child restrictions, approval resume, failed-attempt usage and tool identity.

Issue number

None.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@markstuart-oai
markstuart-oai requested review from a team, rm-openai and seratch as code owners November 24, 2026 07:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T15:57:09.993955Z 4eccd80 Manual request
🔒 Security Review ✅ Completed 2026-11-24T15:59:06.668291Z 4eccd80 Manual request

Security findings

Advisory findings (3)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 5e13a0affd

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/agents/run_budget.py Resolved

@jbeckwith-oai jbeckwith-oai left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes after a comprehensive static review of shared budgets, tool/delegation admission, checkpoint restoration, failed-attempt usage, examples and tests. Independently confirmed the existing canonical tool identity finding: a bare dotted name and a distinct namespaced tool can share the same authorization string across parent/child scopes. Authorize canonical identities or reject cross-scope ambiguity, with a regression covering both inventories. Linking the existing finding instead of duplicating it inline.

Hosted CI at review: 17 passed, 2 skipped, 2 still running. Static review only; no candidate code or tests executed.

Hosted CI update (2026-11-24 07:37 UTC): 18 passed, 4 skipped, 1 failed. Windows 3.10 job failed test_parallel_guardrail_trip_cancels_model_task: the expected guardrail error occurred, but the cancellation event was unset (12,750 passed, 357 skipped). Static inspection suggests a timing-sensitive existing assertion: the unchanged test lets the model finish after 20 ms, while the unchanged cancellation branch cancels only an unfinished task. This is an inference, not a verified flaky rerun; no local tests were run. The existing tool-identity request-changes finding remains.

@jbeckwith-oai jbeckwith-oai left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after static re-review and an independent review of the tool-identity fix. Allowlist admission now derives its spelling from the actual FunctionTool canonical identity and rejects literal dots in name/namespace components, preventing cross-scope bare/namespaced ambiguity. Validation covers fresh runs, resumed inventories, and execution before hooks; unrestricted start-count budgets preserve dotted-name support. Reviewed both collision directions, both run modes, and nested approval/policy-change regression coverage. The prior request-changes finding is addressed.

Hosted CI on this commit at review: 12 passed, 7 still running. The earlier Windows cancellation-test failure was on the preceding commit and is not a current-head result. No candidate code or local tests were run.

Hosted CI update (2026-11-24 07:57 UTC): 19 passed, 4 skipped; no checks remain pending in the current rollup. Approval is unchanged. No local tests were run.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 7d36a30baf

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/agents/run_budget.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 4eccd80f4e

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/agents/run_budget.py Resolved

@jbeckwith-oai jbeckwith-oai left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after static re-review and an independent review. This revision clarifies that allowlist grants apply to a function name across agents sharing a budget, and adds both-mode coverage showing that a narrower child budget still denies its same-named handler while leaving the parent's grant intact. No production behavior changed.

Reviewed the handoff feedback as well: the documented tool limits cover SDK FunctionTool handlers, while child/depth limits cover Agent.as_tool descendants. A handoff stays within the current root; its callback is outside these counters, and subsequent target function calls retain the root budget checks. I did not find a violation of that stated scope.

Hosted CI at review: 16 passed, 2 skipped and 3 running. Pending checks remain under follow-up. No candidate code or local tests were executed.

Hosted CI follow-up (2026-11-24 08:12 UTC): all checks at this reviewed commit are complete: 19 passed and 4 skipped, with no failures. Approval is unchanged. No candidate code or local tests executed.

Copy link
Copy Markdown
Contributor Author

@codex security review

Please reassess the three advisory findings on 4eccd80f against the in-thread evidence. We have been checking canonical tool identities, child-specific restrictions on same-named functions, and the separate authorization needed for handoff callbacks. The zero-budget handoff case still invokes an enabled callback. Please check that boundary against the documented scope.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4eccd80f4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4eccd80f4e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants