Skip to main content
Glama

prepare_context

Generates a token-budgeted context for coding tasks by analyzing the task description to extract key files, symbols, and hotspots in one call.

Instructions

The recommended tool for coding tasks. Give it your task and get back a token-budgeted context with the right files, symbols, and hotspots — all in one call. Proven +18.6% file prediction improvement (p=0.049*, n=45). 95% helpful rate. Use this instead of calling index_repo → focus → blast_radius manually.

task: describe what you're working on. Two modes are auto-selected:
  - PR/commit titles ("Merge pull request #123 from org/fix-auth-bug",
    "fix: prevent null pointer in handler", "Fix teardown callbacks (#5928)")
    → keyword extraction from branch name → per-keyword symbol focus → KEY FILES list
    → proven +7% file prediction improvement on real PRs (canonical n=159, p=0.035*)
  - General coding tasks ("add pagination to user list", "refactor database layer")
    → fuzzy symbol search → overview fallback if no match
task_type: optional hint — "changelocal" forces keyword-extraction path regardless
           of task format; also accepts "debug", "feature", "refactor", "review"
max_tokens: total token budget for the response (default 6000)
exclude_dirs: comma-separated directory prefixes to skip
baseline_predicted_files: optional list of files already predicted by the model
  (for adaptive injection). Two skip conditions:
  1. If len(baseline) ≥ 3 → returns "" (model is highly confident with 3+ predictions;
     any context disagrees more than it helps). Evidence: falcon bl=1.000, 3 correct preds
     → av2 without this guard injected anyway → F1 1.0→0.5 (commit 988960b/d4eb3c8).
  2. If overlap(baseline ∩ KEY FILES) ≥ 50% → returns "" (model already knows the files).
  Otherwise: returns full context (model needs the structural graph bridge).
  Bench (canonical): python3 -m bench.changelocal.analyze --canonical --conditions baseline,tempograph_adaptive
  Canonical result (n=159 Python+JS): +6.9% F1 (p=0.035*). Cost: 2× inference for ~37% of tasks.
precision_filter: if True, skip context when >4 key files are found (topic too broad).
  Canonical bench: python3 -m bench.changelocal.analyze --canonical --conditions baseline,tempograph_precision
  Canonical result (n=159 Python+JS): +3.7% F1 (p=0.21, ns). Default False (plain tempograph = +6.0%
  outperforms precision_filter on canonical corpus). Enable only for high-baseline repos.
definition_first: if True, when a keyword produces too-broad focus (>10 files) and no path match,
  fall back to the *defining file* of the top-ranked symbol (requires score≥10 and ≤2 defining files).
  Handles "redirect" → flask/helpers.py instead of injecting nothing.
  Default True (enabled).
output_format: "text" (default) or "json" for structured response

Returns: overview summary + focused context + KEY FILES + hotspot warnings,
all within the token budget. JSON format adds `key_files` (parsed list) and `injected` (bool).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathNo/demo
taskNo
task_typeNo
max_tokensNo
exclude_dirsNo
baseline_predicted_filesNo
precision_filterNo
definition_firstNo
output_formatNotext

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, but the description exhaustively covers behavior: token budgeting, mode selection, skip conditions for baseline predictions, precision filter effects, and fallback logic for definition_first.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is thorough but somewhat lengthy, though well-structured with clear sections and bullet points. It front-loads the main purpose, but benchmark details could be more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (9 params, no annotations), the description covers all relevant aspects: usage, parameter details, behavioral nuances, and return format (text vs JSON). The output schema exists, so return values are not missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description elaborates on every parameter except repo_path (which has a default). It explains task types, max_tokens, exclude_dirs, baseline_predicted_files with skip logic, precision_filter with benchmark data, definition_first behavior, and output_format options.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool is for coding tasks, specifying it provides token-budgeted context with files, symbols, and hotspots. It distinguishes itself from manually calling multiple tools like index_repo, focus, and blast_radius.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this instead of calling index_repo → focus → blast_radius manually.' It also details two modes for different task types and conditions for baseline_predicted_files, precision_filter, etc.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Elmoaid/TempoGraph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server