Skip to main content
Glama

Pack Context for a Task

pack_for_task
Read-onlyIdempotent

Packs a token-budgeted AI-Builder-Markdown bundle for a natural-language C# task: seeds on named types and methods, expands their neighborhood, and trims to task-relevant symbols.

Instructions

Goal-driven context packing: given a natural-language task, seed on every symbol the goal names (type or method), expand the neighborhood, and return a token-budgeted AI-Builder-Markdown bundle - with goal-aware trimming that keeps the most task-relevant methods when the budget is tight. Name the symbols you care about in the goal (e.g. 'refactor OrderService.Cancel and Validate'). budget caps the bundle in tokens (floored at 8000); a facet's trailer comes on top. Multi-TFM solutions are deduplicated to one declaration per type (the NEWEST TFM's where it has one), as find_symbol lists them. For an EDIT-ready bundle that also pulls in the covering tests + naming/file siblings (and, on a profile-aware server, renders through the facet's template), use prepare_task instead.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sessionId": "<sessionId>",
      "goal": "<goal>"
    },
    "name": "pack_for_task"
  }
}

Input Schema

NameRequiredDescriptionDefault
goalYesThe task description (name the relevant types/methods in it). Once the goal names a symbol exactly, its other words only steer the trimming and seed nothing of their own; a goal naming no symbol is matched by name segments instead ('cancel order' -> CancelOrder).
leanNoLean slice (default TRUE): drop the repeated <AI_CONTEXT_SPEC>/<AI_CONTEXT_META> preamble and omit enabled-but-empty graph sections ('- none'). Keeps PATH_LEGEND / COMPRESSION_LEGEND and all non-empty sections. Set false for the full AI-Builder-MD document.
facetNoOptional facet - the task axis of this call: General, Exploration, Refactoring, Debugging, Review, Testing, Documentation, Architecture, or Performance. pack_for_task always renders the lean bundle (its render deliberately stays template-free - use prepare_task for a template-shaped bundle); the facet appends a short work-style trailer with suggested next tools. (The name 'slot' is accepted too.)
budgetNoOptional token budget (floored at 8000). Caps the slice TWO ways: it compacts/drops method bodies AND - when the expanded neighborhood still overflows - drops the least-relevant non-seed types entirely. Exact type names and exact method names with one owner are pinned; broad subword/ambiguous same-name families may be capped by closeness and in-slice fan-in. A leading comment discloses how many types were dropped. Omitted, the bundle still renders against a ceiling (the active MCP profile's token budget, else a ~10000-token default budget) that bounds the neighborhood; pass a value for a tighter bundle.
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeQualityMetricsNoWhen true, also emit the <QUALITY_HOTSPOTS> section plus complexity=""/ce="" tag attributes (cyclomatic complexity, efferent coupling) for the packed symbols. Default false. Set true when the task is a refactor/quality pass.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.46513
    • changedInput schema / properties / sessionId / description
      Previous value: -"The session_id returned by analyze_solution."New value: +"The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use."
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare a safe read-only, idempotent, closed-world operation, and the description goes well beyond by disclosing the seeded-then-expanded neighborhood algorithm, the 8000-token floor, two-way budget capping (body compaction plus dropping least-relevant non-seed types), pinning of exact names, a leading comment reporting dropped types, multi-TFM dedup to the newest declaration, and the default ceiling when budget is omitted.

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 core purpose is front-loaded and every sentence carries operational content, but the single dense paragraph packs many clauses with heavy jargon (AI-Builder-Markdown, trailer, facet) and could be broken into shorter units for faster scanning.

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?

There is no output schema, yet the description fully characterizes the return value: a lean token-budgeted Markdown bundle with goal-aware trimming, an appended facet trailer, and a leading comment disclosing dropped types. Nothing an agent needs to call this correctly is missing.

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

Parameters3/5

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

Schema description coverage is 100% and the description's parameter statements (goal seeding, lean, facet trailer, budget floor/capping) largely restate what the schema already documents. The only real addition is cross-parameter framing, such as the facet's trailer being on top of the budget cap, so the baseline 3 applies.

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?

States a specific verb and resource ('Goal-driven context packing: given a natural-language task, seed on every symbol... return a token-budgeted AI-Builder-Markdown bundle') and explicitly separates itself from the sibling prepare_task, which the agent can act on without opening either schema.

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?

Gives an explicit routing rule: for an EDIT-ready bundle that also pulls covering tests and file/naming siblings, use prepare_task instead. It also explains when to pass budget (tighter bundle) and when to set includeQualityMetrics (refactor/quality pass), so alternatives and conditions are both named.

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