Skip to content

fix(agy-acp): Windows path resolution and sender_context noise stripping#1331

Closed
SunnyYYLin wants to merge 2 commits into
openabdev:mainfrom
SunnyYYLin:fix/agy-acp-windows-clean
Closed

fix(agy-acp): Windows path resolution and sender_context noise stripping#1331
SunnyYYLin wants to merge 2 commits into
openabdev:mainfrom
SunnyYYLin:fix/agy-acp-windows-clean

Conversation

@SunnyYYLin

Copy link
Copy Markdown

Closes

Closes #1329

At a Glance

agy-acp Adapter
│
├── Adapter::new()
│   └── HOME/USERPROFILE resolution
│       Windows: USERPROFILE first (openab sets HOME to workspace)
│       Unix:    HOME first, USERPROFILE fallback
│
├── agy_bin()
│   └── Windows: "agy" (PATH lookup)
│       Unix:    "/usr/local/bin/agy"
│
├── augmented_path()
│   └── Windows: ; separator, %USERPROFILE%\bin
│       Unix:    : separator, $HOME/bin
│
├── prepare_prompt_state()
│   └── Strip <sender_context>...</sender_context> before forwarding to agy
│
└── protobuf extraction
    └── Handle nested field(1) → field(20) → field(1) payload structure

Prior Art & Industry Research

Not applicable — this is a straightforward cross-platform compatibility fix for the Windows host environment.

Proposed Solution

  1. HOME/USERPROFILE: On Windows, check USERPROFILE before HOME because the parent openab process sets HOME to the workspace directory, overriding the user's actual home. Applied in both Adapter::new() (conversation DB location) and augmented_path() (bin dir resolution).

  2. agy_bin(): On Windows, use "agy" (system PATH lookup) instead of hardcoded /usr/local/bin/agy.

  3. augmented_path(): Use ; separator on Windows, : on Unix. Query USERPROFILE for home-relative bin dirs on Windows.

  4. sender_context stripping: Strip <sender_context>...</sender_context> XML blocks from prompts before forwarding to agy. CLI agents don't understand this metadata injected by the gateway (Issue tracking: Sender Identity Injection System for Agent Broker #61).

  5. Nested protobuf extraction: Handle an additional nesting level in Gemini protobuf payloads where text is under field(20)→field(1)→field(1) instead of just field(20)→field(1).

Why This Approach

  • Minimal cfg gates: Platform-specific logic is isolated behind cfg!(target_os = "windows") with clear fallbacks
  • No breaking changes: Unix behavior is unchanged
  • Correct priority on Windows: USERPROFILE first because HOME is polluted by the gateway
  • Protobuf nesting: Non-destructive — tries the nested path first, falls through to the flat path

Alternatives Considered

  1. Don't set HOME in openab parent: Would break child processes that expect HOME. Rejected — cleaner to fix the consumer.
  2. Use a config field for home dir: Over-engineering. USERPROFILE is the standard Windows convention.

Validation

cargo check -p agy-acp --target x86_64-pc-windows-gnu  # clean
cargo check -p agy-acp                                  # clean
cargo clippy -p agy-acp -- -D warnings                  # no issues

Three fixes for running agy-acp on Windows (or any non-Linux host):

1. HOME -> USERPROFILE fallback
   Adapter::new() now tries HOME first, then USERPROFILE (Windows
   default), then /tmp. Without this the conversation database lands
   under C:\tmp instead of C:\Users\<user>\.gemini.

2. agy_bin() - cross-platform binary resolution
   On Windows, Command::new("agy") resolves via the system PATH,
   avoiding the hardcoded /usr/local/bin/agy path which does not exist
   on Windows.

3. augmented_path() - Windows PATH separator
   Uses ; on Windows instead of :, and queries USERPROFILE for
   home-relative bin dirs.

4. Strip <sender_context> XML from prompts (Issue openabdev#61)
   openab gateway injects <sender_context>...</sender_context> blocks
   into every message for multi-user identity tracking. CLI agents
   like agy do not understand this format and see it as prompt noise.
   prepare_prompt_state() now strips these blocks before forwarding
   the prompt to the agy process.
@SunnyYYLin SunnyYYLin requested a review from thepagent as a code owner July 8, 2026 12:56
@openab-app openab-app Bot added the closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours. label Jul 8, 2026
@openab-app

openab-app Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Caution

This PR is missing a Discord Discussion URL in the body.
This PR will be automatically closed in 24 hours if the link is not added.

All PRs must reference a prior Discord discussion to ensure community alignment before implementation.

Please edit the PR description to include a link like:

Discord Discussion URL: https://discord.com/channels/...

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🔒 Auto-closing: this PR has had the closing-soon label for more than 1 days without activity from the author.

If you'd like to continue working on this, please submit a new PR and link to this one if necessary.

@github-actions github-actions Bot closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(agy-acp): Windows path resolution broken — HOME override and missing USERPROFILE priority

1 participant