Skip to content

fix(image-routing): detect Windows image paths - #61668

Open
kohoj wants to merge 1 commit into
NousResearch:mainfrom
kohoj:codex/fix-windows-image-refs-61568
Open

fix(image-routing): detect Windows image paths#61668
kohoj wants to merge 1 commit into
NousResearch:mainfrom
kohoj:codex/fix-windows-image-refs-61568

Conversation

@kohoj

@kohoj kohoj commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

extract_image_refs() only recognized POSIX-style / and ~/ image paths. On native Windows, kanban task-body image enrichment silently skipped drive-letter paths such as C:\Users\Hiro\shot.png. Fixes #61568.

Root cause

agent/image_routing.py claimed to match the gateway extract_local_files() shape, but its local-image regex was never updated after #34632 added Windows drive-letter support to the gateway path. It also deduped before path normalization.

Fix

  • Extend the local-image regex to accept absolute Windows drive-letter paths with / or \ separators.
  • Normalize expanded local paths before file checks and dedupe with normcase() so native Windows separator/case normalization is respected.
  • Set USERPROFILE in the tilde expansion test so the same test matches Python's Windows expanduser() behavior.
  • Add platform-independent regression tests for Windows drive-letter paths, lowercase drives, relative-drive non-matches, and URL lookbehind behavior.

Tests

  • scripts/run_tests.sh tests/agent/test_image_routing.py -q
  • scripts/run_tests.sh tests/hermes_cli/test_kanban_worker_image_extraction.py -q

Repro

On current main, _LOCAL_IMAGE_PATH_RE returns no match for C:\Users\Hiro\shot.png, C:/Users/Hiro/shot.png, or c:/shot.PNG. After the fix, all three match and still pass the existing file-existence gate.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows duplicate This issue or pull request already exists labels Jul 9, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #34374 (earliest open PR) — both extend agent/image_routing.py's _LOCAL_IMAGE_PATH_RE with the same [A-Za-z]:[/\\] Windows drive-letter alternation. This PR additionally adds normcase() deduping (a minor extra), but the core fix is the same. Related to the bug spec #61568.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Windows fix. The premise is confirmed on current main: agent/image_routing.py:69 accepts only ~/ and /, while the kanban worker calls extract_image_refs() on the task body at cli.py:16073. The proposed drive-letter and mixed-separator pattern matches the established gateway implementation at gateway/platforms/base.py:3730 (commit 51d165a8e).

The PR’s regression cases cover backslash and slash drive paths, lowercase drives, relative-drive rejection, and URL lookbehind. The implementation is narrow and does not alter tool schemas, session state, or prompt caching.

Automated hermes-sweeper review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract_image_refs misses Windows drive-letter paths (missed by #34632) — kanban image enrichment silently broken on native Windows, 12 tests fail

3 participants