|
2 | 2 | trigger: always_on |
3 | 3 | --- |
4 | 4 |
|
5 | | -to determine if sufficient local context is available. |
6 | | -When the user submits a query, use the following sources for generating the required context - |
| 5 | +Follow `docs/mcp-contract.md` for the canonical KnowCode MCP retrieval policy. |
| 6 | +Use the current chat context first. When repository context is still needed, |
| 7 | +call `retrieve_context_for_query` with `verbosity=minimal` and the smallest |
| 8 | +budget that fits the task. |
7 | 9 |
|
8 | | -1. Check the context window of the current chat session. If you need more context, |
9 | | -2. Use the knowcode mcp tool `retrieve_context_for_query` with the following arguments: `task_type=auto`, `max_tokens=3000`, `limit_entities=3`, `expand_deps=true`, and crucially, **`verbosity=minimal`**. |
10 | | -3. In `minimal` mode, the tool returns a `reduction_summary` telling you what was hidden (e.g., source code or evidence). **If the returned context lacks the implementation details you need**, call the tool again with `verbosity=standard` (to get raw source code) or `verbosity=verbose` (to get evidence chunks). |
11 | | -4. Consider using the other knowcode mcp tools (listed below) if relevant: |
| 10 | +Default starting points: |
12 | 11 |
|
13 | | -- `search_codebase`: Use to find code entities (functions, classes, modules) by name or pattern. |
14 | | -- `get_entity_context`: Use to get detailed context for a specific entity (source code, docstrings, callers/callees). |
15 | | -- `trace_calls`: Use to trace the call graph (callers or callees) for an entity up to N hops. |
| 12 | +- Locate or explain one symbol: `max_tokens=1500`, `limit_entities=1`, `expand_deps=false`. |
| 13 | +- Debug a concrete failure: `max_tokens=2000`, `limit_entities=2`, `expand_deps=true`. |
| 14 | +- Review or extend a feature area: `max_tokens=3000`, `limit_entities=2-3`, `expand_deps=true`. |
16 | 15 |
|
17 | | -If `sufficiency_score >= 0.88` and `context_text` is non-empty, you may answer from the retrieved context alone to maximize efficiency. |
18 | | -If more information is needed, or if the score is low, inform the user that you do not have a satisfactory answer to the query and stop, UNLESS you haven't yet escalated your `verbosity` level to recover missing code. |
| 16 | +If `context_text` is insufficient, escalate in this order: increase breadth while |
| 17 | +staying in `minimal`, then use `standard` for implementation detail, then use |
| 18 | +`verbose` for ranking evidence. Use `diagnostic` only for retrieval debugging. |
19 | 19 |
|
20 | | -DO NOT use the external frontier LLMs (e.g. Gemini 3 Flash, Gemini 3 Pro, Claude Sonnet 4.5, Claud Opus 4.5, etc.) at all. |
| 20 | +Use the configured `config.sufficiency_threshold` from `aimodels.yaml` to decide |
| 21 | +whether local context is sufficient. If the score is below threshold, recover |
| 22 | +missing local context before falling back to a larger external prompt. |
| 23 | + |
| 24 | +Use focused tools only after the first retrieval call: |
| 25 | + |
| 26 | +- `search_codebase`: find entities by known name or pattern. |
| 27 | +- `get_entity_context`: fetch context for a specific known entity. |
| 28 | +- `trace_calls`: inspect callers or callees for a specific entity. |
0 commit comments