Skip to content

Conversation

@robotdad
Copy link
Member

@robotdad robotdad commented Jan 6, 2026

Summary

This PR improves Windows compatibility by:

  1. Adding test coverage for colon sanitization in agent names
  2. Adding comprehensive documentation of Windows compatibility practices

Background

Windows does not allow colons in file/directory names (except for drive letters like C:, D:). When agent names like "foundation:explorer" are used in session IDs that become directory paths, they must be sanitized.

The existing code already handles this correctly via regex → (line 76 in tracing.py), but we're adding a test to document this critical behavior.

Changes

Test Coverage (tests/test_tracing.py)

  • Added test_sanitize_agent_name_with_colon
  • Verifies that agent names like "foundation:explorer" become "foundation-explorer" in session IDs

Documentation (context/IMPLEMENTATION_PHILOSOPHY.md)

Added comprehensive "Cross-Platform Development (Windows Compatibility)" section covering:

  1. File I/O Encoding: Always specify encoding="utf-8" explicitly

    • Windows defaults to cp1252/charmap instead of UTF-8
    • Prevents "'charmap' codec can't decode" errors
  2. Path Sanitization: Remove Windows-prohibited characters

    • Colons, pipes, asterisks, etc. cause [WinError 267]
    • Documents the existing sanitization pattern
  3. Development Checklist: Pre-commit verification steps for cross-platform code

This guidance is automatically loaded by all agents via common-agent-base.md.

Issue Fixed

Prevents the error Windows users see when sub-sessions use agent names containing colons:

[WinError 267] The directory name is invalid

Related Work

  • amplifier-app-cli#36 (encoding fixes) - Merged
  • This PR documents patterns discovered while fixing those production issues

Test Plan

  • New test passes
  • Existing tests still pass
  • Behavior is already correct, now documented and tested

🤖 Generated with Amplifier

Co-Authored-By: Amplifier 240397093+microsoft-amplifier@users.noreply.github.com

robotdad and others added 2 commits January 5, 2026 19:38
Windows does not allow colons in file/directory names (except for
drive letters like C:, D:). Agent names like "foundation:explorer"
need to be sanitized when used in session IDs that become directory
paths on the filesystem.

The existing sanitization code (line 76 in tracing.py) already
handles this correctly by replacing all non-alphanumeric characters
with hyphens via regex: [^a-z0-9]+ → -

This test documents and verifies this critical behavior for Windows
compatibility, ensuring that agent names like "foundation:explorer"
become "foundation-explorer" in session IDs.

Fixes issue where Windows users see:
"[WinError 267] The directory name is invalid" when sub-sessions
use agent names containing colons.

Type: test

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Add comprehensive guidance for cross-platform development with focus
on Windows compatibility. This documents critical patterns discovered
from fixing production issues:

1. **File I/O Encoding**: Always specify encoding="utf-8" explicitly
   - Windows defaults to cp1252/charmap instead of UTF-8
   - Prevents "'charmap' codec can't decode" errors
   - Applies to open(), Path.read_text(), Path.write_text()

2. **Path Sanitization**: Remove Windows-prohibited characters
   - Colons, pipes, asterisks, etc. cause [WinError 267]
   - Agent names like "foundation:explorer" must be sanitized
   - Applies to any user input used in filenames

3. **Development Checklist**: Pre-commit verification steps

This guidance is loaded by all agents via common-agent-base.md,
ensuring consistent Windows-safe code across the codebase.

Related PRs:
- amplifier-app-cli#36 (encoding fixes) - Merged
- amplifier-foundation#11 (test coverage) - Open

Type: docs

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant