get_context
The workhorse tool. Compact, batched context for any set of files, modules, or symbols — docs, ownership, freshness, and optional source/callers/callees/metrics/community in one call.
If your agent only learns one tool, make it this one. get_context
absorbs what would otherwise be five or six separate calls — file
docs, symbol signatures, ownership, last-change history, source
bodies, callers and callees, centrality metrics, community membership,
and freshness — into a single call with a configurable include list.
Pass multiple targets at once.
When to call
- After
get_answerto verify or expand on cited files. - Before editing any file — check ownership, dependents, freshness, and governing decisions.
- Architectural questions — pair with
include=["metrics", "community"]to see centrality and cluster membership. - Always batch — one call with five targets is far cheaper than five calls with one target each.
Parameters
Prop
Type
Returns
The response is a targets map keyed by the target string. Each entry contains:
| Block | What it gives you |
|---|---|
docs | Wiki title, summary, and symbols list (name, kind, signature, line, docstring). Adds structure block and imported_by for files; child file pages for modules; qualified_name, used_by, candidate matches for symbols |
full_doc | Same as docs but with the full page content_md |
ownership | primary_owner, owner_pct, contributor_count, bus_factor, plus recent_owner if the active maintainer differs from the historical primary |
last_change | ISO date, author, days ago |
source | Body, start_line, end_line, language, truncated flag (capped at 400 lines) |
callers / callees | Up to 20 each, filtered to confidence ≥ 0.7. Each entry: symbol_id, name, kind, file, confidence, edge_type |
metrics | pagerank, pagerank_percentile, betweenness, betweenness_percentile, in_degree, out_degree, community_id |
community | id, label, cohesion, top_members, neighbors with cross-edge counts |
freshness | confidence_score, freshness_status, is_stale |
decisions | Governing architectural decision records (if any) |
Top-level fields:
truncated—trueif output was capped at the token budget.dropped_targets,dropped_symbols— what got evicted when the budget was exceeded.
Example
get_context(["src/auth/service.py"])
get_context(
["src/auth/service.py::verify_token"],
include=["source", "callers"],
)
get_context(
["src/auth/", "src/payments/"],
include=["ownership", "metrics", "community"],
)Things worth knowing
- Token budget enforcement — ~8000 tokens (~32k chars) global cap. Truncation happens in stages: (1) strip heavy doc fields, (2) shrink symbol lists keeping query-matched symbols first, (3) drop whole targets. Largest targets are evicted first.
- Symbol prioritisation — within a target, symbols are ranked by exact name match → substring match → kind (class > function > method) → centrality. Navigationally important symbols survive truncation.
- Target resolution order — file_page → module_page → symbol
(exact then fuzzy) → file by
target_path. If none match, returns fuzzy path suggestions. freshnessis included by default — critical for the agent to detect stale indices.ownershipandlast_changeadd 200–500 bytes each; omit them on multi-turn sessions to save the cache.- Cross-repo enrichment (workspace mode) — appends co-change partners and contract links (HTTP routes, gRPC services, topics) from other repos for files in a multi-repo workspace.
Pattern that works well: call get_answer first, then
get_context(targets=fallback_targets, include=["ownership", "last_change"])
on whatever the answer cited. Two calls, complete picture.
get_answer
One-call RAG synthesis over the wiki — retrieves, gates on confidence, and returns a cited 2–5 sentence answer with fallback file targets. The first tool to call on any code question.
search_codebase
Semantic search over the wiki — natural-language queries with vector retrieval and full-text fallback, freshness-boosted, and federated across repos in workspace mode.