magpie icon indicating copy to clipboard operation
magpie copied to clipboard

[Bug] gateway: memoryTag misclassifies Windows user instruction paths (\.claude\, \.codex\, \.config\, \.pi\) as `project` (fix branch)

Open wthsama opened this issue 4 days ago • 0 comments

magpie version

v0.1.5312

Where

GUI

OS

Windows 11

Agent, provider and model

OpenCode → magpie (local gateway)

Steps to reproduce

  1. On Windows, have a user-level instruction file at C:\Users\<user>\.claude\CLAUDE.md loaded by an agent that emits its path without a parenthetical description (e.g. OpenCode's Instructions from: C:\Users\<user>\.claude\CLAUDE.md).
  2. Open the Context window card in magpie GUI and inspect the item's tag in the Memory breakdown.

What happened, and what you expected

What happened: The global C:\Users\<user>\.claude\CLAUDE.md file is tagged project.

Expected: User-level instruction files under \.claude\, \.codex\, \.config\, and \.pi\ on Windows are tagged user, matching their Unix ~/.claude/ counterparts.

Root cause

In internal/gateway/prompt.go, memoryTag falls back to substring checks with forward slashes only:

if strings.Contains(path, "/.claude/") || strings.Contains(path, "/.codex/") || strings.Contains(path, "/.config/") ||
    strings.Contains(path, "/.pi/") {
    return "user"
}
return "project"

Windows paths containing backslashes (e.g. C:\Users\<user>\.claude\CLAUDE.md) never match and fall through to "project".

Fix branch & verification

Since external PRs are restricted to collaborators, a fix with regression tests is available on my fork branch:

  • Branch: https://github.com/wthsama/magpie/tree/fix/memory-tag-windows
  • Commit: 3128404db (base ebac9bbc5)
  • Summary: normalize \ to / in memoryTag before checking /.claude/, /.codex/, /.config/, and /.pi/, so Windows paths are classified consistently regardless of the OS running the gateway.

Verification (Windows 11, go1.27.3, sandboxed temp HOME):

  • Red on main (without normalization): TestMemoryTagWindowsPaths failed with memoryTag("C:\\Users\\alice\\.claude\\CLAUDE.md", "") = "project", want "user" (and likewise for .codex, .config, .pi).
  • Green with fix: go test -v -tags nogui ./internal/gateway -run "TestPrompt|TestMemoryTag|TestSplitSkills|TestFilesOfCommand" passed (2.931s).
  • gofmt -l internal/gateway/prompt.go internal/gateway/prompt_test.go: clean.
  • go vet -tags nogui ./..., GOOS=linux go vet -tags nogui ./..., and GOOS=windows go vet -tags nogui ./...: all passed.
  • Not run: full go test -tags nogui ./... suite and Playwright GUI suite.

wthsama avatar Dec 01 '26 18:12 wthsama