Description
The Python declarative path loaders read YAML using the process locale instead of UTF-8:
AgentFactory.create_agent_from_yaml_path() uses open(yaml_path).
AgentFactory.create_agent_from_yaml_path_async() uses Path.read_text().
WorkflowFactory.create_workflow_from_yaml_path() uses open(yaml_path).
On Windows with a non-UTF-8 locale, a UTF-8 YAML file containing characters outside that locale can fail before YAML parsing. The async agent loader also performs Path.exists() and Path.read_text() directly on the event-loop thread even though it is presented as an async counterpart.
Expected behavior:
- Path-based declarative YAML loading should consistently read UTF-8 files across platforms.
- The async path loader should offload filesystem access rather than blocking the event loop.
I intend to submit a focused fix with regression tests covering Unicode YAML and event-loop responsiveness.
Code Sample
from pathlib import Path
from agent_framework_declarative import WorkflowFactory
path = Path("unicode-workflow.yaml")
path.write_text(
"""kind: Workflow
trigger:
kind: OnConversationStart
id: start
actions:
- kind: SendActivity
id: reply
activity: "政务助手 🏛️"
""",
encoding="utf-8",
)
WorkflowFactory().create_workflow_from_yaml_path(path)
Error Messages / Stack Traces
On Windows with locale.getencoding() == "cp936" and UTF-8 mode disabled:
UnicodeDecodeError: 'gbk' codec can't decode byte ...
Package Versions
agent-framework-declarative: source checkout of main at d7823b2
Python Version
Python 3.11.9
Additional Context
The synchronous and asynchronous agent loaders and the workflow loader should use the same explicit encoding. For the async method, reading through asyncio.to_thread() would also avoid blocking on local, network, or otherwise slow filesystems.
AI assistance was used to audit the code paths and prepare the reproduction; the behavior was verified against the referenced source checkout.
Description
The Python declarative path loaders read YAML using the process locale instead of UTF-8:
AgentFactory.create_agent_from_yaml_path()usesopen(yaml_path).AgentFactory.create_agent_from_yaml_path_async()usesPath.read_text().WorkflowFactory.create_workflow_from_yaml_path()usesopen(yaml_path).On Windows with a non-UTF-8 locale, a UTF-8 YAML file containing characters outside that locale can fail before YAML parsing. The async agent loader also performs
Path.exists()andPath.read_text()directly on the event-loop thread even though it is presented as an async counterpart.Expected behavior:
I intend to submit a focused fix with regression tests covering Unicode YAML and event-loop responsiveness.
Code Sample
Error Messages / Stack Traces
On Windows with
locale.getencoding() == "cp936"and UTF-8 mode disabled:Package Versions
agent-framework-declarative: source checkout ofmainatd7823b2Python Version
Python 3.11.9
Additional Context
The synchronous and asynchronous agent loaders and the workflow loader should use the same explicit encoding. For the async method, reading through
asyncio.to_thread()would also avoid blocking on local, network, or otherwise slow filesystems.AI assistance was used to audit the code paths and prepare the reproduction; the behavior was verified against the referenced source checkout.