Skip to content

feat(kb): add per-doc summaries to get_knowledge_base response#85

Merged
mhersson merged 1 commit into
mainfrom
ctxmax-482/add-per-doc-summaries-to-knowledge-base-envelope
May 12, 2026
Merged

feat(kb): add per-doc summaries to get_knowledge_base response#85
mhersson merged 1 commit into
mainfrom
ctxmax-482/add-per-doc-summaries-to-knowledge-base-envelope

Conversation

@contextmatrix-runner
Copy link
Copy Markdown
Contributor

Summary

  • Adds a summaries field to the get_knowledge_base MCP tool response: {doc_name → string}, populated by parsing the first ## Summary section from each KB doc (empty string when absent, never null)
  • Updates refresh-knowledge.md templates to require ## Summary as the first level-2 heading on every generated doc (150–300 tokens)
  • Adds surgical triage guidance to the KB-loading step in create-plan, run-autonomous, brainstorming, and systematic-debugging skills
  • Documents the new field in docs/agent-workflow.md

Test plan

  • go test ./internal/... — 17 packages pass, including 6 new tests: TestExtractSummary (4 table-driven cases), TestReadKnowledgeBase_PopulatesSummaries, TestReadKnowledgeBase_SummariesNonNilWhenEmpty
  • go build ./... — clean build
  • Verify get_knowledge_base MCP response includes summaries field after a refresh_knowledge_base run
  • Confirm existing KBs without ## Summary sections return empty strings (backward-compatible)

- Add extractSummary parser to service_knowledge.go: scans for first
  ## Summary heading, collects content until next ## heading or EOF,
  returns empty string when section is absent
- Add Summaries map[string]string to KnowledgeBaseRead and
  getKnowledgeBaseOutput; non-nil guaranteed in all code paths
- Populate Summaries in ReadKnowledgeBase for each loaded doc
- Nil-check Summaries alongside Docs in the MCP handler
- Add ## Summary placeholder as first level-2 heading in all four
  refresh-knowledge doc templates (5.1–5.4) with 150–300 token spec
- Add surgical 2-3 sentence triage guidance to KB-loading step in
  create-plan, run-autonomous, brainstorming, systematic-debugging skills
- Document summaries field and agent usage pattern in docs/agent-workflow.md
- 6 new unit tests: TestExtractSummary (4 cases), PopulatesSummaries,
  SummariesNonNilWhenEmpty
@mhersson mhersson force-pushed the ctxmax-482/add-per-doc-summaries-to-knowledge-base-envelope branch from 2cac0a4 to e1ec788 Compare May 12, 2026 09:49
@mhersson mhersson merged commit 89cdf08 into main May 12, 2026
2 checks passed
@mhersson mhersson deleted the ctxmax-482/add-per-doc-summaries-to-knowledge-base-envelope branch May 12, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant