Skip to content

Python: make declarative YAML path loading UTF-8 and async-safe - #8260

Merged
Evan Mattson (moonbox3) merged 2 commits into
microsoft:mainfrom
fzfzzfzzzfzzzz:issue-8254-declarative-yaml-io
Sep 15, 2026
Merged

Evan Mattson (moonbox3) merged 2 commits into
microsoft:mainfrom
fzfzzfzzzfzzzz:issue-8254-declarative-yaml-io

Conversation

@fzfzzfzzzfzzzz

Copy link
Copy Markdown
Contributor

Motivation & Context

Declarative YAML path loaders relied on the process locale, so UTF-8 definitions containing characters outside a platform's default encoding could fail before parsing. The async agent path loader also performed filesystem reads directly on the event-loop thread.

Description & Review Guide

  • What are the major changes? Agent and workflow YAML path loaders now read files explicitly as UTF-8. The async agent loader performs the read with asyncio.to_thread() and translates a missing file back to DeclarativeLoaderError.
  • What is the impact of these changes? UTF-8 declarative definitions load consistently across platforms, and asynchronous agent construction no longer blocks the event loop during file access.
  • What do you want reviewers to focus on? Please review the missing-file exception compatibility and whether UTF-8 is the expected portable encoding for declarative definition files.

Related Issue

Fixes #8254

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after a language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings September 10, 2026 16:30
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation preserves missing-file behavior and adequately tests UTF-8 and asynchronous file access.

Pull request overview

Makes declarative YAML path loading portable and async-safe.

Changes:

  • Reads agent and workflow YAML files explicitly as UTF-8.
  • Offloads asynchronous agent file reads with asyncio.to_thread().
  • Adds regression tests for Unicode content, threading, and encoding.
File summaries
File Description
_loader.py Adds UTF-8 agent loading and non-blocking async reads.
_workflows/_factory.py Adds explicit UTF-8 workflow loading.
test_declarative_loader.py Tests agent encoding and async thread offloading.
test_workflow_factory.py Tests workflow UTF-8 loading.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@moonbox3

Copy link
Copy Markdown
Contributor

Please agree to the CLA

@fzfzzfzzzfzzzz

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@eavanvalkenburg

Copy link
Copy Markdown
Member

Thanks for the update. Before this is ready, could you please:

  • get the non-green checks passing: merge-gatekeeper (FAILURE), command_check (CANCELLED), team_check (CANCELLED), review (CANCELLED)

Once those are addressed, please re-request review. Thanks!

@fzfzzfzzzfzzzz

Copy link
Copy Markdown
Contributor Author

Thanks! I checked the failed checks. The CLA is green now.

The DevFlow PR Review run was cancelled by the workflow's concurrency handling (Canceling since a higher priority waiting request ... exists), so command_check and team_check never completed successfully. I don't have permission to rerun the upstream workflow as an external contributor.

Could you please retrigger the DevFlow PR Review for #8260? Once command_check and team_check pass, the Merge Gatekeeper can be rerun and I'll re-request review.

@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Sep 15, 2026
Merged via the queue into microsoft:main with commit c385c2d Sep 15, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Declarative YAML path loaders are locale-dependent and async loader blocks the event loop

4 participants