Building and customizing solutions using Microsoft 365 Copilot APIs and tools
The described behavior matches a workflow/handler stability issue rather than a configuration feature that can be fully fixed from the workflow designer alone. The available guidance focuses on making the workflow more robust and easier to troubleshoot, not on a specific “handler issue” fix in Teams.
Within the workflow itself, the following hardening steps are supported:
- Use explicit branching and guards around the orchestrator
- Model the orchestrator and its downstream agents as a deterministic workflow with clear preconditions and post-conditions for each step.
- Use if/else branches to handle error or empty responses from the orchestrator, similar to what is already done for the child agents. In the Condition box of an if/else node, use Power Fx with
System.andLocal.variables to check for:- Empty or null output
- Unexpected types (for example, text where JSON is expected)
- For example, build conditions with
System.variables and route failures to a “fallback” branch that returns a safe message like “Can you please ask the question again?” instead of letting the handler fail.
- Validate agent assignments and outputs
- Ensure every agent node under the orchestrator has an agent assigned; missing agents can cause unexpected workflow output.
- If the orchestrator or agents return structured data, configure them to output JSON Schema and save that output into variables. Then validate:
- The JSON schema is valid.
- The variable types match what downstream steps expect. If Power Fx reports type mismatches, use conversion functions like
Text()orValue().
- Use Power Fx error troubleshooting patterns
- If Power Fx formulas in conditions reference variables incorrectly, errors such as “Name isn’t valid” or “Type mismatch” can break the run and lead to repeated failures until the session is reset.
- Ensure:
- System variables use the
System.prefix. - Local variables use the
Local.prefix. - Types are converted explicitly where needed.
- System variables use the
- Break complex orchestrations into smaller workflows
- If the orchestrator coordinates multiple agents with complex logic, timeouts or long-running calls can cause workflow failures that then surface as handler issues in Teams.
- Recommended mitigation:
- Break the overall process into smaller workflows.
- Keep each workflow’s sequence and branching simpler and more deterministic.
- General workflow health checks
- When reproducing the issue in Foundry (before Teams):
- Verify each node completes in the visualizer.
- Confirm the chat window shows the expected response or the fallback message instead of an unhandled error.
- Inspect saved variables (especially JSON outputs) to ensure they contain the expected values.
- If a run times out or produces unexpected output, adjust the workflow as above before re-testing in Teams.
- When reproducing the issue in Foundry (before Teams):
For Teams integration specifically, there is no separate configuration in the provided guidance that eliminates handler errors. The recommended approach is to:
- Make the orchestrator workflow deterministic and guarded (if/else, validation, and fallback branches) so that every path returns a valid response.
- Ensure agents and tools used by the orchestrator are resilient and idempotent, with clear error handling, so that repeated calls from Teams do not leave the workflow in a bad state.
If, after applying these patterns (guards, correct variable usage, JSON validation, and breaking down complexity), handler errors still persist in Teams, the next step is to capture a failing run in the Foundry visualizer and escalate through support, as the remaining issue is likely platform-side rather than something that can be fixed purely in the workflow definition.
References: