Add KCP manifest and TL;DR summaries: 76% fewer agent navigation calls#4658
Open
totto wants to merge 6 commits intocrewAIInc:mainfrom
Open
Add KCP manifest and TL;DR summaries: 76% fewer agent navigation calls#4658totto wants to merge 6 commits intocrewAIInc:mainfrom
totto wants to merge 6 commits intocrewAIInc:mainfrom
Conversation
- knowledge.yaml: 16-unit KCP v0.3 manifest with triggers, hints, and summary cross-links - docs/en/getting-started-tldr.mdx: architecture summary + minimal crew example - docs/en/concepts/agents-tasks-tldr.mdx: agent/task quick reference - docs/en/concepts/flows-tldr.mdx: Flow decorators and state management reference - docs/en/concepts/tools-memory-tldr.mdx: tools, memory, and knowledge/RAG reference - benchmark.py: reproducible tool-call efficiency benchmark (baseline vs KCP) - BENCHMARK.md: results — 76% reduction (123 → 30 tool calls across 8 queries) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace hardcoded /src/totto/crewAI paths in benchmark.py with a REPO_ROOT variable derived from os.path.dirname(os.path.abspath(__file__)). This makes the benchmark script reproducible on any machine. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… REPO_ROOT BENCHMARK.md methodology section referenced /src/totto/crewAI — replaced with generic description. benchmark.py read_file and grep_content handlers now validate that requested paths fall within REPO_ROOT, preventing the agent from reading files outside the repository. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ob_files Previous startswith() check was vulnerable to path traversal (/repo-name-suffix/ would pass /repo-name prefix). Replace with pathlib.Path.relative_to() which correctly checks containment. Also restricts glob_files to REPO_ROOT by filtering all results through the same _within_repo() helper — the handler previously had no path restriction at all. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
glob_files was silently discarding the declared base_dir parameter. Now reads base_dir from tool_input and validates it is within REPO_ROOT before using it (falls back to REPO_ROOT if not). grep_content now uses -e flag so LLM-provided patterns starting with '-' are treated as patterns rather than grep flags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
agents-tasks-tldr and tools-memory-tldr each cover two concepts but summary_of can only reference one unit ID. The previous manifest had summary_unit on both tasks and memory pointing to the combined TL;DRs, but those TL;DRs declared summary_of for only the first topic (agents, tools). A strict KCP agent could skip the TL;DR when starting from tasks or memory, defeating the optimisation. Fix: remove summary_available/summary_unit from tasks and memory. Instead add a relationships section with context links from each combined TL;DR to its secondary topic unit, so agents can still discover the TL;DR via the relationship graph without misusing the summary_of field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
What this adds
A
knowledge.yamlmanifest at the repo root, plus four pre-built TL;DR summary files for the highest-traffic documentation sections.KCP (Knowledge Context Protocol) is a lightweight standard that tells AI agents what a repository contains and how to navigate it efficiently — a structured index with intents and trigger phrases for each documentation unit, rather than having agents explore by trial and error.
Benchmark: 76% fewer tool calls
8 queries, same Haiku model, tool counts from the Anthropic API (not agent self-reports):
76% reduction. The standout is the RAG query (33 → 3, 91% reduction) — the baseline agent traversed the entire docs tree before finding
knowledge.mdx, while KCP directed it straight totools-memory-tldr.mdxvia therag crewtrigger. The hierarchical crew query had the smallest gain (22 → 9) because answering it genuinely requires reading large reference files — KCP removes exploration overhead but cannot compress inherently dense content.How it works
Without the manifest, an agent asked "how do I build a flow that triggers a crew?" typically:
README.mddocs/en/directoryintroduction.mdxconcepts/crews.mdxconcepts/flows.mdxWith
knowledge.yaml, the agent:knowledge.yaml— seesflows-tldrunit with triggers["flow triggers crew", "start listen", "event driven workflow"]docs/en/concepts/flows-tldr.mdx— gets@start/@listen/@routeranatomy + a minimal Flow+Crew example in ~500 tokensFiles added
Static files only — zero runtime overhead, no new dependencies, nothing changes for existing users.
KCP spec
Full specification: github.com/cantara/knowledge-context-protocol (v0.3).
This is the fifth repo we have benchmarked with KCP. Results across all five:
Happy to adjust trigger phrases, add coverage for enterprise integrations or observability platforms, or restructure files to match your documentation conventions.
Note
Low Risk
Documentation-only additions plus an optional standalone benchmarking script; no changes to runtime library behavior, but the new script invokes local file/grep access when run.
Overview
Adds a repo-root
knowledge.yamlKnowledge Context Protocol (KCP) manifest that indexes key CrewAI docs by intent/triggers and points to smaller summary units to reduce agent “search” reads.Introduces several new TL;DR MDX pages (getting started, agents/tasks, flows, tools/memory/knowledge) and a
BENCHMARK.md+benchmark.pyrunner to measure the reduction in tool calls when using the manifest.Written by Cursor Bugbot for commit f532932. This will update automatically on new commits. Configure here.