Building and customizing solutions using Microsoft 365 Copilot APIs and tools
Copilot Studio: BotDefinitionOverride YAML exceeds the 20-million-character limit – How can we reduce its size?
Background
We are developing an agent in Microsoft Copilot Studio that uses multiple Skills. Each Skill contains a SKILL.md instruction file and may also include supporting reference documents, Python scripts, and other resources.
When validating or publishing the agent, we encounter the following error:
BotDefinitionOverride YAML is 22151031 characters, which exceeds the maximum allowed length (20000000).
Error code: InvalidContent.
The generated YAML is approximately 2.15 million characters above the permitted limit.
What we have investigated so far
We reviewed the Skill package and found:
The package contains approximately 729 files, including reference documents, Markdown files, Python scripts, and configuration files.
The extracted text from the reference documents and other text-based files is approximately 9.3 million characters.
The SKILL.md instruction files are already relatively small and have been reviewed for unnecessary content.
We optimized the DOCX reference files by removing unnecessary document metadata and redundant internal content.
We also investigated duplicate file registrations and other potential sources of unnecessary content. Some duplicates were identified in a local package snapshot, but these have not yet been confirmed in the live agent configuration.
Despite these investigations, we do not yet understand exactly how Copilot Studio constructs the BotDefinitionOverride YAML or which components contribute most to its size.
Proposed approach
One option we are considering is moving some supporting reference documents out of the Skills and adding them as agent-level Knowledge Sources instead.
The intention is to keep the Skills focused on instructions, workflows, scripts, and task execution, while making supporting reference material available through Knowledge Sources.
However, before proceeding, we would like to understand whether this approach would actually reduce the generated YAML size and whether it could affect how the agent retrieves and uses reference content.
Questions for Microsoft experts
What contributes to the BotDefinitionOverride YAML size? Are files included in full, converted into text, Base64-encoded, or represented only through metadata?
Would moving reference documents from Skills to agent-level Knowledge Sources reduce the generated YAML size? Are those documents excluded from the Skill definition after migration?
Can multiple Skills use the same agent-level Knowledge Source without including duplicate copies of the reference content in the generated definition?
Do duplicate file registrations or references contribute separately to the YAML size? Is there a recommended way to identify and remove unnecessary registrations?
Is the 20-million-character limit fixed? Is there a way to inspect the generated definition or identify which components are contributing most to its size?
What architecture does Microsoft recommend for agents that require multiple Skills, supporting documents, and Python scripts, while keeping the overall agent definition within platform limits?
Expected outcome
We would appreciate guidance on the recommended approach to reduce the generated BotDefinitionOverride YAML size without removing important reference material or affecting the agent's existing functionality.
In particular, we would like to confirm whether separating Skill instructions and scripts from supporting documents through Knowledge Sources is a recommended solution for this scenario.
Background
We are developing an agent in Microsoft Copilot Studio that uses multiple Skills. Each Skill contains a SKILL.md instruction file and may also include supporting reference documents, Python scripts, and other resources.
When validating or publishing the agent, we encounter the following error:
BotDefinitionOverride YAML is 22151031 characters, which exceeds the maximum allowed length (20000000).
Error code: InvalidContent.
The generated YAML is approximately 2.15 million characters above the permitted limit.
What we have investigated so far
We reviewed the Skill package and found:
The package contains approximately 729 files, including reference documents, Markdown files, Python scripts, and configuration files.
The extracted text from the reference documents and other text-based files is approximately 9.3 million characters.
The SKILL.md instruction files are already relatively small and have been reviewed for unnecessary content.
We optimized the DOCX reference files by removing unnecessary document metadata and redundant internal content.
We also investigated duplicate file registrations and other potential sources of unnecessary content. Some duplicates were identified in a local package snapshot, but these have not yet been confirmed in the live agent configuration.
Despite these investigations, we do not yet understand exactly how Copilot Studio constructs the BotDefinitionOverride YAML or which components contribute most to its size.
Proposed approach
One option we are considering is moving some supporting reference documents out of the Skills and adding them as agent-level Knowledge Sources instead.
The intention is to keep the Skills focused on instructions, workflows, scripts, and task execution, while making supporting reference material available through Knowledge Sources.
However, before proceeding, we would like to understand whether this approach would actually reduce the generated YAML size and whether it could affect how the agent retrieves and uses reference content.
Questions for Microsoft experts
What contributes to the BotDefinitionOverride YAML size? Are files included in full, converted into text, Base64-encoded, or represented only through metadata?
Would moving reference documents from Skills to agent-level Knowledge Sources reduce the generated YAML size? Are those documents excluded from the Skill definition after migration?
Can multiple Skills use the same agent-level Knowledge Source without including duplicate copies of the reference content in the generated definition?
Do duplicate file registrations or references contribute separately to the YAML size? Is there a recommended way to identify and remove unnecessary registrations?
Is the 20-million-character limit fixed? Is there a way to inspect the generated definition or identify which components are contributing most to its size?
What architecture does Microsoft recommend for agents that require multiple Skills, supporting documents, and Python scripts, while keeping the overall agent definition within platform limits?
Expected outcome
We would appreciate guidance on the recommended approach to reduce the generated BotDefinitionOverride YAML size without removing important reference material or affecting the agent's existing functionality.
In particular, we would like to confirm whether separating Skill instructions and scripts from supporting documents through Knowledge Sources is a recommended solution for this scenario.