Give a coding agent code pointers before it starts
Before a coding agent starts on an issue, ask Loom once where the code is and put a short block of file and line pointers at the top of its task prompt. One SDK method or one command builds the block the coding-agent plugins build, and Loom makes no text-generation call for it.
A pipeline that hands issues to a coding agent can ask Loom once, before the agent
starts, which places in the code the issue is about, and put a short block of pointers
at the top of the task prompt. agent.code.pointer_block in the Python SDK,
agent.pointerBlock in the TypeScript SDK and the loom pointers command build that
block. It is built by the rule of the coding-agent plugins’ prompt hook: the same
query, and the same gate and text for the same answer
(what the plugins do besides). Loom answers the request from its
index: it embeds the query once with the deployment’s embedding model and makes no
text-generation call. This page covers what to index first, how to build the block,
what is sent, when nothing is sent, what the pattern costs and its limits.
The pipeline owns the agent, its tools and its prompt. Loom is called by the pipeline, not by the agent: the agent needs no Loom tool, plugin or credential. An agent that does run with a Loom plugin needs one switch (below).
Index the repository first
The request reads a code namespace, so add and index the repository before the first task. One namespace is one branch.
The index follows that branch. The code_ingest worker fetches a configured repository
every LOOM_CODE_INGEST_INTERVAL_SECONDS; a post-merge job that calls code.refresh
indexes a merge at once (pushing freshness from CI).
The pointers are those of the indexed commit; code.index_status names it and says
how far the index trails the branch. An agent that starts from another commit, or from
a branch the namespace does not track, finds the same definitions at other lines.
The pipeline’s token needs the viewer role on the code namespace
(who can read).
Build the block
Loom 1.3.0 does not include these SDK methods or the loom pointers command.
To run the examples from a source checkout, build the
Python SDK for Python and
python -m loom pointers, or the
TypeScript SDK for TypeScript.
In Python:
from loom import Agent
async with Agent("acme", "code-myrepo", "issue-pointers") as bot:
block = await bot.code.pointer_block(issue_text, namespace="code-myrepo")
prompt = f"{block}\n\n{task_prompt}" if block else task_prompt
In TypeScript:
const block = await bot.pointerBlock(issueText, { namespace: "code-myrepo" });
const prompt = block ? `${block}\n\n${taskPrompt}` : taskPrompt;
From a shell, with clickhouse-loom installed, the command reads the task on standard
input and prints the block:
block=$(LOOM_BASE_URL=https://loom.example LOOM_API_KEY=… \
python -m loom pointers --namespace code-myrepo < issue.md) || block=
To run loom pointers directly, install both the server CLI and the Python SDK in
the same Python 3.12 or later environment. From the repository root:
python -m pip install -e . ./sdk/python
| Python | TypeScript | Command | Meaning |
|---|---|---|---|
namespace |
namespace |
--namespace |
The code namespace to search. Required. |
top_k |
topK |
--top-k |
The most pointers listed, 1 to 5. Default 3. |
checkout_prefix |
checkoutPrefix |
--checkout-prefix |
Written before each path, such as repo/, when the checkout is a subdirectory of the agent’s working directory. |
org |
org |
--org |
The namespace’s org. Default: the Agent’s org, and for the command the token’s. |
The result is the block, or an empty string when there is nothing to send (below). The command prints nothing in that case and exits 0. A request that fails raises in the SDKs; the command prints nothing on standard output, says why on standard error and exits 1. Either way, start the agent with no block.
The rule that builds the block runs in the client, so only these two SDKs carry it. The generators of the Go, Rust and Ruby SDKs write one method per operation and nothing else, and the Java and .NET clients cover the memory operations. A pipeline in another language runs the command.
What is sent
One code.search request with this body:
| Field | Value | Why |
|---|---|---|
query |
the request text | At most 2,000 characters of the request inside the prompt, with credentials replaced (below). |
top_k |
3 |
The block lists the places among the first results. top_k raises it to 5 at most. |
bodies |
"none" |
Each result is a pointer with no source. |
token_budget |
600 |
The reply’s ceiling, whatever the deployment’s default budget is. |
annotate |
false |
No risk annotations: the block does not print them. |
include_lessons |
false |
No memories about the files: the block does not print them. |
rerank |
"none" |
No reranker, whatever LOOM_CODE_SEARCH_RERANK_DEFAULT names. |
llm_legs |
"none" |
No model-backed leg, whatever the deployment configures (below). |
expand |
not sent | The op’s default: no query expansion. |
loom.pointers.search_request(prompt) in Python and pointerRequest(prompt) in
TypeScript return this body without sending it.
The query is built in three steps, in the client:
- The request inside the prompt. A prompt that wraps its request in a
<question>,<task>,<issue>,<request>,<query>or<problem>block, or that opens as a card oflabel: valuelines with a request field, is searched with that request alone. Sentences that only tell the agent how to work or answer (“Do not edit the tests.”, “Reply with a JSON list.”) are left out: their words match CI scripts and tests, not the code the request is about. - Credentials are replaced with
[redacted]. Private keys, cloud, code-host and chat tokens,password=…andapi_key: …assignments, signed tokens, bearer and basic credentials and URL passwords. This covers common shapes only: remove a credential of another shape from an issue before sending it. - The text is cut at 2,000 characters.
Nothing else of the prompt leaves the process. Whether the prompt names a file or a
definition is read from the whole prompt in the client. Loom keeps the query text in its
search trace (loom.code_search_trace) for 180 days
(retention).
Put the block at the top of the prompt
Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:
- src/uploads/client.py:20-23 uploads.client::Client::put
- src/uploads/retry.py:6-15 uploads.retry::retry_upload
An entry is - <path>:<first line>-<last line> <name> — <signature>, the signature cut
at 80 characters and present only when the search resolved an exact name. The block
lists the answer’s places to edit:
- In Python, C and C++, TypeScript and JavaScript, Go, Rust and Java source a place is a
definition (
function,class_skeletonorsymbol). A file’s leading comments and imports and its module-level code are left out. - A unit of any other file is a place whatever its kind: a line window of a file the index reads as text, a schema, configuration.
- A test is a place when the request asks for tests or the prompt names its file. A
document is one when the request asks for documentation or the prompt names its file.
A numbered Python migration, a top-level
externorreleasedirectory and a packaging script are places only when the prompt names the file. - A class and its own methods send one pointer: the method the prompt names, else the class when the prompt names it, else the one the index ranked first. A range over 200 lines gives way to a definition the answer holds inside it, and is otherwise listed as its first line and its length.
- Entries keep the index’s order, and a span is listed once.
- Paths are relative to the repository root, after the checkout prefix when one is given, and the lines are those of the indexed commit.
Put the block first, then a blank line, then the task. The lead line calls the entries candidates and tells the agent to check one or search. Keep that wording: a prompt that tells the agent to edit the listed code turns a wrong pointer into a wrong change.
The same block as the plugins
One fixture of prompts, answers and the request and block expected for each holds the
rule: integrations/claude-code-plugin/tests/fixtures/pointer-block.json. The plugins’
tests (integrations/claude-code-plugin/tests/prompt-pack.test.mjs), the Python SDK’s
(tests/unit/test_sdk_pointer_block.py) and the TypeScript SDK’s
(sdk/typescript/src/pointers.test.ts) run every case against the function each one
ships. For the same prompt the three send the same query, and for the same answer they
build the same block, byte for byte.
What the plugins do and the SDKs do not:
- Send the request with its lines. Beside a query that is not the whole request
(a request of several lines, or of more than 2,000 characters) a plugin sends up to
20,000 characters of the request with its line breaks, credentials replaced
(
report). The index reads the definitions the text names from it: the frames of a pasted traceback and the names spelled as code. The SDKs send the query alone, so for such a task the two searches can answer differently. - Name themselves in the search trace. A plugin’s request carries
consumer: "claude-code-prompt-pack". An SDK’s carries the consumer its Agent was built with and none otherwise: build the Agent with one (consumer="issue-pointers") to tell its searches apart inloom.code_search_trace. - Find the code namespace. A plugin looks the checkout’s remotes up in the index and sends nothing for an unindexed checkout. The SDKs are told the namespace.
- Answer three questions about a named definition directly. “Where is
Xdefined?”, “Who callsX?” and “What would changingXaffect?” get the definition, its callers or its impact from a plugin. The SDK method returns an empty string for them: callcode.symbol,code.callersorcode.impact. - The install’s options. The test line under the pointers reads the checkout, and
the pick (
prompt_pack_pick) andLOOM_PROMPT_PACK_MIN_CONFchange the gate. The SDK method has the default gate and no test line. - Replace their own Loom token by its text. An SDK keeps no readable copy of its key. A Loom token is a signed token, which the shapes above replace.
- Cut inside a character. A plugin cuts at 2,000 UTF-16 code units even inside a character outside the Basic Multilingual Plane. The SDKs stop one character earlier.
- Wait 2.5 seconds at most. The SDK call follows the Agent’s timeout and retry policy.
With a coding-agent plugin installed
The Claude Code and Codex plugins can answer a prompt themselves: a memory recall on the first prompt of a session and, where the Loom the session talks to indexes the checkout’s own repository, the code index’s pointers on every prompt (what a prompt gets). A task prompt that already carries the block above, or records the pipeline read through the SDK, would get the same content searched for and added a second time, and the session would pay for both copies on every request.
Start that agent with one variable in its environment:
LOOM_PROMPT_CONTEXT=off claude -p "$(cat prompt.txt)"
The plugin then adds nothing to a prompt and sends its text to no lookup: no pointers and no recall, whatever the install’s other options say. Everything else the plugin does is unchanged: the agent keeps Loom’s tools, and the session is still captured.
- An install only the pipeline uses can set the option once:
claude plugin install loom@loom --config prompt_context=false. - The session primer is separate. At the start of a session the plugin adds a
primer of pinned and recent memory, which is not an answer to the prompt.
LOOM_INJECT_CONTEXT=falseturns it off. - The repository’s instruction block stays as it is. Its text follows the install’s
prompt_packoption and whether the checkout’s own repository is indexed (the instruction block), so turning the prompt context off changes neither the block nor what the plugin says about it. Where the committed block is the text for whatprompt_packgives the checkout’s prompts, the session reads that block and the plugin does not ask for another. Where it is not, such as a pipeline install withprompt_pack=offin an indexed repository that committed the pointers block, the SessionStart line and the status check call the block outdated, as they do with the prompt context on: leaveprompt_packat its default for the pipeline, which adds no lookup while the prompt context is off. The search block namesloom_code_searchfor code the agent’s own search misses and for a task that names no file or symbol; the pointers block, which a checkout whose own repository is indexed gets unlessprompt_packisoff, names it for a task whose pointers are missing or do not fit. Neither asks for a call before the agent’s own lookup or tells the agent to edit the listed code. - The server’s startup instructions are separate too. The Codex plugin’s MCP entry,
and an entry wired by hand, get the server’s general instructions. For a token with a
default memory namespace they tell the agent to call
loom_context_packas the first step of each task, unless a Loom hook already put Loom’s context in the session. With the prompt context and the primer off no hook did, so that agent is still told to fetch memory itself. Two things stop it: a line in the task prompt saying that Loom’s context for the task is already in the prompt andloom_context_packis not to be called, or an entry that lists the code tools alone (toolset=coding&schema_profile=plugin&mode=codeon its URL; MCP reference), which has no memory tool and gets no such instruction. The Claude Code plugin’s own entry gets one paragraph that asks for no first call.
Send nothing when the index does not stand behind its answer
The method returns an empty string, the command prints nothing, and the agent gets its task unchanged, when:
- the prompt is not a task to search for: under 12 characters, a slash command, thanks or a greeting, a task over supplied text only (“Use only the provided source …”), a search for a literal string, a task about uncommitted work, a question about a change in history or about saved memory, or one of the three questions about a named definition. No request is sent for these;
- replacing the credentials leaves no text to search with, as in a prompt of more than about 120,000 characters that opens with a private-key block which has no end line. No request is sent;
abstainis true;retrieval_riskis notlow. The risk is the band ofretrieval_confidenceat the deployment’s cut-offs (LOOM_CODE_SEARCH_MEDIUM_RISK_FROM,LOOM_CODE_SEARCH_LOW_RISK_FROM). A search whose vector leg did not run or failed readsmedium, and a namespace nobody has calibrated can read an answerable issuemediumorhigh;- the answer holds no place to edit.
low says the index probably holds code about the issue. It does not say the listed
places are the ones to change.
Treat a failed or timed-out request the same way: start the agent with no block.
The request makes no text-generation call
For this request Loom makes one model call, the query embedding, and no
text-generation call. retrieval_work.embedding_calls in the code.search reply is 1.
The embedding is made with the deployment’s embedding model (LOOM_EMBEDDING_MODEL,
models and keys).
The released Docker installation embeds with a local model on CPU, in the server
process. A source checkout’s default is a keyless character-overlap embedder for
development. A deployment that configures a hosted embedding provider sends it the
query text. An embedding returns a vector; it generates no text. A repeated request
inside LOOM_CODE_SEARCH_MEMO_TTL_S is replayed from the stored answer and embeds
nothing.
code.search has stages that call a text-generation model or a reranker. All are off
by default, and the request keeps each one off whatever the deployment sets:
| Stage | Turned on by | The request |
|---|---|---|
| Query expansion: a model proposes identifiers | expand: true in the request |
does not send expand |
| Hypothetical-answer leg: a model writes a passage to embed | LOOM_CODE_SEARCH_HYDE_MODEL |
llm_legs: "none" |
| Concept expansion by a model | LOOM_CODE_SEARCH_CONCEPT_EXPAND_MODEL naming a model |
llm_legs: "none" |
| Reranker over the fused results | rerank in the request, or LOOM_CODE_SEARCH_RERANK_DEFAULT |
rerank: "none" |
| Listwise pick: a model chooses among the ranked results | rerank: "builtin:pick" and LOOM_CODE_SEARCH_PICK_MODEL |
rerank: "none" |
To let a deployment’s own settings apply, pass server_defaults=True in Python or
serverDefaults: true in TypeScript. The request then names neither rerank nor
llm_legs, and every block costs what the deployment configured for code.search: a
model call for the hypothetical-answer leg and an embedding of its passage, one for
concept expansion and one for the reranker. On the test deployment below, with all
three configured, one block makes three generation calls and two embedding calls where
the default request makes none and one. The pipeline waits for them.
One model call is outside the request’s control. A deployment that exports scores to
Langfuse and sets LOOM_RETRIEVAL_JUDGE_SAMPLE_RATE above 0 has a model grade a sample
of searches after their replies are sent. The rate is 0 by default.
LOOM_READS_LLM_FREE=true turns it off, with every other text-generation step of a read
op, for the whole deployment.
tests/unit/test_sdk_pointer_block.py holds the claim: it runs the method against the
code.search op on a deployment with a hypothetical-answer model, a concept-expansion
model and a model reranker configured, and asserts no generation call and one embedding
call. The same request without llm_legs or rerank reaches the model there, and with
server_defaults it makes the three generation calls.
The coding-agent plugins’ prompt hook sends the same two fields with its search, so a
prompt it searches starts no text-generation call either. The one exception is its
pick option,
which is off by default and asks for rerank: "builtin:pick".
What it costs
- One request per task, before the agent starts. The pipeline waits for it. The time goes to the query embedding and the index reads. The Agent’s timeout bounds it.
- One embedding call. A hosted embedding provider bills it; a local model spends server CPU.
- The block’s tokens on every model request of the session. The block is part of the prompt, so the model reads its tokens again with each later request, at the price its provider charges for repeated prompt text.
Limits
- The block names a place the fix needs for only part of real issues. An issue describes a symptom, and the code to change is not always the code the symptom’s words match.
- A wrong block saves nothing. The agent searches as it would have, and the block’s tokens are paid on every request.
- A small repository gains little: an agent finds the code there in a few searches.
- Definitions come from the languages the index parses into functions and classes (language support). Source the index reads as text is listed as line windows, with no name.
- This page quotes no measurement. Published measurements are on the benchmark results page.
Related
- Code index overview: what the index holds and how to read an answer.
- Code tools for model integrations: the other way round, where the model chooses when to look code up.
- Choose AI software factory tools: what each stage of a pipeline should produce.