@@ -140,13 +140,37 @@ def get_magentic_prompt_kwargs(*, has_user_responses: bool = False) -> dict:
140140 ORCHESTRATOR_TASK_LEDGER_FACTS_PROMPT + facts_append
141141 )
142142
143- progress_append = """
143+ # --- COMPLETION CHECK: applies to ALL teams (not just user_responses) ---
144+ # Without this, the LLM can mark is_request_satisfied=true before all
145+ # agents have run (e.g., Content Gen skipping ComplianceAgent).
146+ progress_append = """
144147
145148EXECUTION RULES:
146149- When selecting next_speaker, prefer a work agent that has NOT yet been invoked.
147150- MagenticManager MUST NOT generate answers, ask questions, or list missing info.
148151 It only routes tasks to the appropriate agent.
149152- There is NO UserInteractionAgent. Do NOT select it as next_speaker.
153+
154+ COMPLETION CHECK (CRITICAL):
155+ Before setting is_request_satisfied to true, you MUST verify:
156+ 1. Review the conversation history and list every agent that has actually produced
157+ a substantive response (called tools and returned results).
158+ 2. Compare that list against the plan steps. If ANY plan-step agent has NOT been
159+ invoked and produced a substantive response, set is_request_satisfied to false
160+ and select the next uninvoked agent as next_speaker.
161+ 3. is_request_satisfied = true ONLY when ALL plan-step agents have completed
162+ their work successfully (called their tools, returned results).
163+ - Each agent handles a DISTINCT domain. One agent's output does NOT satisfy
164+ another agent's step.
165+ - Do NOT re-invoke an agent that already completed its step successfully.
166+ - IGNORE agent-level completion language (e.g. "all steps are complete",
167+ "onboarding is done"). An individual agent only knows about its own domain.
168+ The workflow is NOT complete until every plan-step agent has been invoked."""
169+
170+ if has_user_responses :
171+ progress_append += """
172+
173+ USER-CLARIFICATION ROUTING:
150174- Domain agents that need user info will call their request_user_clarification
151175 tool. The framework handles the pause/resume automatically via
152176 function_approval_request events. You do NOT need to route to any special agent.
@@ -165,26 +189,11 @@ def get_magentic_prompt_kwargs(*, has_user_responses: bool = False) -> dict:
165189STALL DETECTION OVERRIDE:
166190- An agent calling request_user_clarification is NOT stalling. The framework
167191 pauses automatically. Set is_progress_being_made=true and is_in_loop=false.
168- - Do NOT treat a framework pause as a stall or loop.
192+ - Do NOT treat a framework pause as a stall or loop."""
169193
170- COMPLETION CHECK (CRITICAL):
171- Before setting is_request_satisfied to true, you MUST verify:
172- 1. Review the conversation history and list every agent that has actually produced
173- a substantive response (called tools and returned results).
174- 2. Compare that list against the plan steps. If ANY plan-step agent has NOT been
175- invoked and produced a substantive response, set is_request_satisfied to false
176- and select the next uninvoked agent as next_speaker.
177- 3. is_request_satisfied = true ONLY when ALL plan-step agents have completed
178- their work successfully (called their tools, returned results).
179- - Each agent handles a DISTINCT domain. One agent's output does NOT satisfy
180- another agent's step.
181- - Do NOT re-invoke an agent that already completed its step successfully.
182- - IGNORE agent-level completion language (e.g. "all steps are complete",
183- "onboarding is done"). An individual agent only knows about its own domain.
184- The workflow is NOT complete until every plan-step agent has been invoked."""
185- kwargs ["progress_ledger_prompt" ] = (
186- ORCHESTRATOR_PROGRESS_LEDGER_PROMPT + progress_append
187- )
194+ kwargs ["progress_ledger_prompt" ] = (
195+ ORCHESTRATOR_PROGRESS_LEDGER_PROMPT + progress_append
196+ )
188197
189198 return kwargs
190199
0 commit comments