Python: fix(orchestrations): forward workflow run kwargs to the GroupChat orchestrator - #8314
Conversation
…Chat orchestrator workflow.run(..., function_invocation_kwargs=..., client_kwargs=...) reaches participant agents through AgentExecutor, but the GroupChat orchestrator's own agent.run never saw them. _invoke_agent now takes the WorkflowContext its callers already hold, resolves the run kwargs through the same resolution AgentExecutor uses (extracted into module-level helpers so both call sites share it), and forwards them. Magentic's manager._complete has the same gap but public signatures on MagenticManagerBase make threading the context a bigger contract change; deferred deliberately, noted on the issue.
There was a problem hiding this comment.
🟡 Changes recommended
Per-executor orchestrator routing needs direct coverage, and the helper docstring incorrectly claims Magentic support.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Forwards workflow run kwargs to GroupChat orchestrator agents and centralizes kwargs resolution.
Changes:
- Extracts shared run-kwargs resolution helpers.
- Passes resolved kwargs to the GroupChat orchestrator.
- Adds forwarding coverage.
File summaries
| File | Description |
|---|---|
_agent_executor.py |
Adds shared kwargs-resolution helpers. |
_group_chat.py |
Forwards kwargs to orchestrator runs. |
test_group_chat.py |
Tests orchestrator kwargs forwarding. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| function_invocation_kwargs={"user_id": "u-123"}, | ||
| client_kwargs={"trace_id": "t-456"}, |
| Shared by ``AgentExecutor`` and the orchestrator/manager call sites that | ||
| invoke an agent inside a workflow (GroupChat orchestrator, Magentic | ||
| manager), so run kwargs reach every agent run, not just participants. |
…e orchestrator Copilot review on microsoft#8314: the helper docstring claimed Magentic as a caller while that side is explicitly deferred, and the kwargs test only exercised the global form, so a wrong executor id at the orchestrator call site would still have passed. Narrow the docstring to the actual callers and add a per-executor case keyed by the orchestrator's own executor id, with a participant-keyed entry as the negative control.
|
Addressed both Copilot comments in 604ae57:
Verified locally: both kwargs tests plus the full |
The conflict in _resolve_executor_kwargs is resolved by keeping the helper delegation and moving upstream microsoft#7963's mixed-kwargs merge semantics (global fills, the executor entry wins per key) into resolve_executor_run_kwargs, so the shared helper matches current main behavior instead of the winner-takes-all routing it was extracted from.
|
Conflict with main resolved in the merge just pushed. The interesting bit: main landed #7963 (mixed |
Motivation & Context
workflow.run(..., function_invocation_kwargs=..., client_kwargs=...)is stored in workflow state and forwarded to participant agents viaAgentExecutor, but the GroupChat orchestrator's ownagent.run()never received them. Hosts that put per-run values there (user_id for tool ACLs, request-scoped ids for metrics) worked for participants and silently lost them on the orchestrator, which for a tool-bearing orchestrator means the manager agent runs with fewer rights than the team it manages.Description & Review Guide
_invoke_agenton the GroupChat orchestrator now takes theWorkflowContextits callers already hold, resolves the run kwargs fromWORKFLOW_RUN_KWARGS_KEYstate, and forwards them to the orchestrator'sagent.run. The resolution logic (_prepare_agent_run_args/_resolve_executor_kwargs) is extracted to module-level helpers in_agent_executor.pyso the executor and the orchestrator share one implementation; the executor's methods are now thin delegates.__global__resolution semantics. No change for runs that don't pass kwargs.Scope cut: the Magentic manager's
_completehas the same gap, butplan/replan/create_progress_ledger/prepare_final_answerare public onMagenticManagerBase, and threading a context through them breaks custom manager subclasses that override those methods (I hit exactly that in the existing test doubles). I'd rather land the GroupChat fix and do Magentic as a follow-up with a design you prefer (context var vs. signature change) than guess. Noted on the issue.Related Issue
Toward #8304 (GroupChat half; Magentic half deliberately deferred as described above)
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.