knowledgeAgentBlock renders the knowledge digests for the agent/coder system prompt: the index cards plus the pull instruction. Empty when no knowledge context is attached — the block then costs nothing. Deterministic for a given attachment set, so it can live in a cacheable prompt block.
()
| 122 | // knowledge context is attached — the block then costs nothing. Deterministic |
| 123 | // for a given attachment set, so it can live in a cacheable prompt block. |
| 124 | func (cli *ChatCLI) knowledgeAgentBlock() string { |
| 125 | if cli.contextHandler == nil { |
| 126 | return "" |
| 127 | } |
| 128 | sessionID := cli.currentSessionName |
| 129 | if sessionID == "" { |
| 130 | sessionID = "default" |
| 131 | } |
| 132 | mgr := cli.contextHandler.GetManager() |
| 133 | kbs := mgr.AttachedKnowledge(sessionID) |
| 134 | if len(kbs) == 0 { |
| 135 | return "" |
| 136 | } |
| 137 | var b strings.Builder |
| 138 | for _, fc := range kbs { |
| 139 | b.WriteString(mgr.KnowledgeDigest(fc)) |
| 140 | b.WriteString("\n") |
| 141 | } |
| 142 | b.WriteString("Use the @knowledge tool to work with these bases: search passages, read full documents with get (paged), inspect coverage with toc. Ground answers in retrieved content and cite source paths.") |
| 143 | return b.String() |
| 144 | } |