When the coder agent starts work on a task, inject relevant facts from the knowledge base into its context alongside AGENTS.md.
Worker.hs line 272-275 builds fullPrompt:
let fullPrompt =
prompt
<> "\n\nREPOSITORY GUIDELINES (AGENTS.md):\n"
<> agentsMd
1. Query facts relevant to the task:
-- Get facts relevant to files the task might touch
getRelevantFacts :: TaskCore.Task -> IO [TaskCore.Fact]
getRelevantFacts task = do
-- Get all facts
allFacts <- Fact.getAllFacts
-- Filter by namespace/project match
let namespace = fromMaybe "Omni" (TaskCore.taskNamespace task)
projectFacts = filter (\f -> TaskCore.factProject f == namespace) allFacts
-- Sort by confidence, take top N
let sorted = List.sortBy (comparing (Down . TaskCore.factConfidence)) projectFacts
pure (take 10 sorted) -- Limit to avoid context bloat
2. Format facts for inclusion:
formatFacts :: [TaskCore.Fact] -> Text
formatFacts [] = ""
formatFacts facts = Text.unlines
[ "\n\nKNOWLEDGE BASE FACTS:"
, "(These are learned patterns/conventions from previous work)"
, ""
] <> Text.unlines (map formatFact facts)
formatFact :: TaskCore.Fact -> Text
formatFact f =
"- " <> TaskCore.factContent f
<> (if null (TaskCore.factRelatedFiles f)
then ""
else " [" <> Text.intercalate ", " (TaskCore.factRelatedFiles f) <> "]")
3. Update fullPrompt construction:
-- In runAmp, after reading agentsMd
relevantFacts <- getRelevantFacts task
let factsSection = formatFacts relevantFacts
let fullPrompt =
prompt
<> "\n\nREPOSITORY GUIDELINES (AGENTS.md):\n"
<> agentsMd
<> factsSection
4. Add imports for Omni.Fact and Data.List
Files: Omni/Agent/Worker.hs
Testing:
1. Add a fact via CLI: jr facts add Omni "The build command is bild Omni/Jr.hs"
2. Run jr work <some-task>
3. Check _/llm/amp.log to verify facts appear in prompt
No activity yet.