Repository navigation
Description
Describe the problem before proposing implementation. Filing an issue does not reserve the work or approve a pull request.
Problem
The current session-backed function-approval contract defers an entire model-produced function-call batch when any call requires approval. This can cause two successive user-input round trips: first for function approval, then for OAuth consent discovered only when another, already-allowed call finally executes.
Explore whether the loop should attempt every currently allowed call before returning a pause, so it can surface known approval and OAuth requirements together while retaining completed results.
Use Case and Evidence
A model returns four function-call contents (FCCs):
- A requires function approval; B, C, and D are already allowed.
- Today, the loop pauses for A and defers B/C/D too.
- After the user approves A, execution discovers that C needs OAuth consent. The loop must return to the user again.
An alternative would leave A unexecuted, attempt B/C/D, retain B/D's completed results, and surface A's approval request alongside C's OAuth consent request in the same pause.
This arose while discussing invocation-time Foundry Toolbox OAuth consent in #10020 and #9903. The goal here is to reduce user-input round trips, not to conflate them with provider requests needed to reconcile service-owned history.
Desired Outcome
Determine whether eager execution of allowed calls should become supported behavior. If so, define a contract that collects all known input requirements after eligible calls settle, stores successful sibling results, and resumes only unresolved work without replaying completed calls.
An OAuth requirement from one concurrent call should not, by itself, prevent other already-allowed calls from being attempted.
Alternatives Considered
- Keep the existing batch-wide approval pause. This preserves current behavior but may require separate approval and OAuth interactions.
- Stop later dispatch after the first OAuth requirement. This may leave other allowed calls unattempted and additional consent requirements undiscovered.
Proposed Direction
Investigate reusing the existing approval and user-input pause paths while allowing eligible calls to settle before the pause is returned. Do not prescribe a new pause manager or state store.
Resolve these questions:
- Which calls may execute before all approval decisions are available, and should this be the default or an opt-in policy?
- How should approval requests and multiple OAuth consent requests be presented and answered together, including partial answers?
- How are completed results and pending calls retained with framework-owned and service-owned history, in streaming and non-streaming modes?
- What are the retry and approval rules for a consent-blocked call, and how do we prevent replay of successful siblings or reuse of stale approval authority?
- What are the consequences of executing allowed siblings before the user approves or rejects another call, especially for side effects, cancellation, failures, and execution limits?
- Should sequential execution retain its existing behavior, or follow a different rule?
If A itself needs OAuth consent, that may not be discoverable before A is approved. Never execute an unapproved call merely to discover its consent requirements; identify where a combined interaction is and is not possible.
The investigation should end with an agreed behavior contract and a focused regression scenario set, or a documented decision to retain the current behavior.
Scope and Non-Goals
Team-owned vNext investigation into Python function-call execution and pause semantics. This is not approval to implement the proposal or change the current approval contract as part of #10020 or #9903.
Do not bypass approval, assume rollback of sibling side effects, automatically replay completed calls, or introduce a broader workflow/checkpoint redesign.
Language
Python
Contribution Intent
I am only requesting the feature. This investigation is reserved for the Agent Framework team; implementation remains subject to maintainer agreement.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
eavanvalkenburg commentedon Nov 13, 2026
/plan the goal here is to reduce the odds of having two rounds of user access for one tool call loop, but this might need configurable behavior as it might depend on the specifics of the environment and setup, for instance when approval takes long, reducing it by waiting to see if one tool comes back with oauth and then being able to handle both approval and oauth in the same approval flow is very helpful
github-actions commentedon Nov 13, 2026
Summary
When a model returns several tool calls and one needs approval, the loop pauses and holds back the other (already-allowed) calls. After the user approves, one of those held calls may need OAuth consent. That causes a second user round trip. You want to lower the odds of that, and you expect the behavior may need to be configurable. Example: when approval is slow, it helps to run the allowed calls first so approval and OAuth can be handled in one prompt.
What the code does today (read, not run)
_try_execute_function_call_groupsin_tools.py, when any call needs approval (requires_approval), the function returns approval pauses immediately and runs nothing._store_already_approved_approval_requests. They stay hidden until the visible approval is answered.has_declaration_only_callbranch). So the framework already has both "defer" and "run now" behaviors, chosen by context.FunctionInvocationConfigurationalready has per-run switches such asallow_concurrent_invocation, so an opt-in policy has a natural home.Recommendation
An investigation is warranted, and code changes are plausible but should not be assumed yet. The issue itself says this ends in either an agreed contract or a documented decision to keep the current behavior. I would recommend an opt-in policy, keeping today's batch-wide deferral as the default. The default is a documented, spec-tested safety contract. Running allowed siblings early changes when side effects happen. It also changes cancellation,
max_function_callsaccounting and hidden-state replay, and every one of those has a spec row and tests.Trade-off: opt-in covers your slow-approval case without surprising existing users. The cost is two code paths to test, in streaming and non-streaming modes and in sequential and concurrent modes. A documentation-only outcome (keep current behavior, document the extra consent round trip) stays valid if the contract turns out too costly.
Proposed plan (investigation first; nothing has been changed)
Write the behavior contract as a short design note (an ADR in
docs/decisions/) before any code. Answer the issue's open questions:never_requiretools only).Define the policy knob, for example a
FunctionInvocationConfigurationoption with values like"defer_all"(current default) and"run_allowed_first". Maybe add a bounded wait for slow consent. Never execute an approval-required call to discover its consent needs.Prototype the loop change in the
requires_approvalbranch. Run eligible siblings with the existingexecute_local_calls, keep theirfunction_resultgroups, and return approval and consent pauses together. Store the finished results in the existing pending-batch state so resume runs only the unresolved calls and never replays finished ones. Reuse existing pause storage rather than adding a new store.Handle resume rules: a consent-blocked call must not reuse stale approval authority. A partial answer must leave the rest pending. Rejection or cancellation of A must still keep B/D's completed results.
max_function_callsis counted per executed group, which the spec already defines.Tests, mapped into spec 004's scenario table:
Docs: update spec 004 only for the changed rows, and add a short note on when to opt in (slow approvals, OAuth-heavy toolsets) and the side-effect caveat.
Success means: the agreed contract is recorded, the opt-in setting yields one user round trip for the example, and the default behavior and its existing tests are unchanged.
Questions for the team (non-blocking)
This is a proposal only. No changes have been made.