feat: inject project .dag as ground truth before markdown context#90
Closed
logohere wants to merge 2 commits into
Closed
feat: inject project .dag as ground truth before markdown context#90logohere wants to merge 2 commits into
logohere wants to merge 2 commits into
Conversation
- prompt_builder.py: _load_project_dag() scans projects/ and specs/ directories for .dag files, compacts JSON to DAG-path notation, injects as first-turn context (before AGENTS.md/CLAUDE.md) - subdirectory_hints.py: add *.dag glob to HINT_FILENAMES, _read_hint_file() + _compact_dag() convert .dag JSON on discovery - 6435-char .dag → 1046-char compact format (16% of original) - Fixes DAG-bypass: LLM now has entity graph in context from turn 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agent reads .ts implementation files before .dag spec files — bypasses DAG-first engine entirely. Observed in magic-cabinet-mvp session where agent read 8+ .ts files before any .dag, requiring 4 user interventions.
Root cause
Project .dag files are not pre-injected into context. Agent must explicitly read_file them — same cost as .ts files, but less obviously useful. The .dag has no code pointers, so it doesn't serve as a natural first stop.
Fix
_load_project_dag()scansprojects/andspecs/for .dag files, compacts JSON to DAG-path notation (6435→1046 chars, 16%), injects as turn-1 context BEFORE any markdown. Priority: .dag → .dag.md → AGENTS.md → CLAUDE.md → .cursorrules.*.dagglob added to hint discovery. When agent navigates to directories with .dag files, they're compacted and injected as[Subdirectory DAG context]blocks.Before/After
Before: Agent starts session, sees AGENTS.md markdown, then reads .ts files, never touches .dag unless told.
After: Agent wakes up seeing:
Gap detection is immediate: DAG says
pricedstate exists, implementation hasmatchedSku: null.