Conversation
Implements a capability that discovers and injects repository convention files (AGENTS.md, CLAUDE.md, .cursorrules, etc.) into the agent's system prompt via get_instructions(). Walks from root_dir upward, deduplicates symlinks, caches after first scan, and respects a configurable character limit. Closes #64 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
| except OSError: | ||
| continue |
There was a problem hiding this comment.
🔴 UnicodeDecodeError not caught when reading non-UTF-8 context files
The except OSError at src/pydantic_harness/repo_context_injection.py:77 does not catch UnicodeDecodeError, which inherits from ValueError, not OSError. If a file matching file_patterns (e.g., a binary .cursorrules file or a file in a non-UTF-8 encoding) is encountered, candidate.read_text(encoding='utf-8') at line 76 raises UnicodeDecodeError, which propagates uncaught through _get_context() and get_instructions(), potentially crashing agent construction. The intent of the try/except is to gracefully skip unreadable files, but this encoding error path is missed.
| except OSError: | |
| continue | |
| except (OSError, UnicodeDecodeError): | |
| continue |
Was this helpful? React with 👍 or 👎 to provide feedback.
Audit vs prior art: RepoContextInjectionWorth adding now:
Follow-up opportunities:
|
Audit vs prior art: RepoContextInjectionWorth adding now:
Follow-up opportunities:
|
Summary
RepoContextInjection, anAbstractCapabilitythat discovers and injects repository convention files (AGENTS.md, CLAUDE.md, .cursorrules, .github/copilot-instructions.md, CONVENTIONS.md, CODING_GUIDELINES.md) into the agent's system promptroot_dirupward to filesystem root, deduplicates symlinks, caches after first scan, and respects a configurablemax_total_charslimitfrom pydantic_harness import RepoContextInjectionCloses #64
Test plan
🤖 Generated with Claude Code