Skip to content
Loom Docs
Esc
↑↓navigate↵open⌘Jpreview
Product
View as Markdown
On this page

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. 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 definitions the issue is about, and put a short block of pointers at the top of the task prompt. Loom answers this 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, the request, the block, when to send nothing, 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. The reply’s as_of block names it (commit) and says whether the index trails the branch (stale). 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).

Make the one request

sdk/python/examples/issue_code_pointers.py is the whole pattern. In a pipeline:

async with Agent("acme", "code-myrepo", "issue-pointers") as bot:
    block = await pointer_block(bot, "code-myrepo", issue_text)
prompt = with_pointers(task_prompt, block)

From a shell, with clickhouse-loom installed, it prints the issue with the block above it:

LOOM_BASE_URL=https://loom.example LOOM_API_KEY=… python sdk/python/examples/issue_code_pointers.py \
  --org acme --code-namespace code-myrepo issue.md

pointer_block sends one code.search request with this body:

Field Value Why
query the issue text The whole text. The server clips it at 20,000 characters, and the lexical leg keeps its rarest terms (LOOM_CODE_SEARCH_QUERY_MAX_TOKENS).
top_k 25 The largest page. The block lists the first definitions on it.
bodies "none" Each result is a pointer with no source.
token_budget 2500 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.

The example calls Agent.call("code.search", body): agent.code.search() has no parameter for rerank or llm_legs. The TypeScript SDK sends the same body with agent.call("code.search", body).

Loom keeps the query text in its search trace (loom.code_search_trace). Remove credentials from an issue before sending it.

Read what comes back

The example reads these fields of the code.search reply:

Field Meaning
results[].path, start_line, end_line The file, relative to the repository root, and the definition’s line span at the indexed commit.
results[].symbol The definition’s qualified name, such as uploads.retry::retry_upload; empty for a unit that is not a definition.
results[].kind function, class_skeleton or symbol for a definition. Any other kind is not one: a file’s imports, module-level code, a section of a document.
results[].signature Set when the search resolved an exact name in the symbol table. A result of the hybrid route carries none.
abstain, retrieval_risk The index’s verdict on its own answer (when to send nothing).
as_of The indexed commit and its freshness.
retrieval_work Counters of the work done, embedding_calls among them, and where the time went (stage_ms_*).

An issue text is prose, so its answer comes from the hybrid route and most entries are a path, a line span and a name. A pipeline that wants the signature on each line reads the definition’s first statement from its own checkout at the pointer’s lines.

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
- src/uploads/retry.py:18-22 uploads.retry::BackoffPolicy

The lead line and the shape of an entry (- <path>:<first line>-<last line> <name> — <signature>, the signature cut at 80 characters) are those of the coding-agent plugins’ prompt hook. The example builds the block this way:

  • An entry is a definition (function, class_skeleton or symbol) outside a test path. A file’s imports, its module-level code, a document and a test are left out.
  • Entries keep the index’s order, and a span is listed once.
  • At most 8 entries and 1,400 characters, about 350 tokens.
  • Paths are relative to the repository root. When the checkout is a subdirectory of the agent’s working directory, pass it as --checkout-prefix repo/.

with_pointers puts 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.

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 install turned them on, 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=false turns it off.
  • The repository’s instruction block stays as it is. Its text follows the install’s prompt_pack option alone (the instruction block), so turning the prompt context off changes neither the block nor what the plugin says about it. Where the install’s prompt_pack is the setting the committed block was written for, the session reads that block and the plugin does not ask for another. Where it is not, such as a pipeline install with prompt_pack at its default in a 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: set LOOM_PROMPT_PACK=on for the pipeline, which adds no lookup while the prompt context is off. The default block names loom_code_search for code the agent’s own search misses and for a task that names no file or symbol; the block of an install with prompt_pack on 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_pack as 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 and loom_context_pack is not to be called, or an entry that lists the code tools alone (toolset=coding&schema_profile=plugin&mode=code on 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

pointer_block returns an empty string, and the agent gets its task unchanged, when:

  • abstain is true;
  • retrieval_risk is not low. The risk is the band of retrieval_confidence at 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 reads medium, and a namespace nobody has calibrated can read an answerable issue medium or high;
  • the page holds no definition to list.

low says the index probably holds code about the issue. It does not say the listed definitions 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 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 example’s request keeps each one off whatever the deployment sets:

Stage Turned on by The example’s 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"

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_example_issue_code_pointers.py holds the claim: it runs the example 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.

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; retrieval_work.stage_ms_* in the reply says where. deadline_ms in the body bounds it: the op then answers with the page it has and partial: true.
  • 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 definition 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 never listed.
  • This page quotes no measurement. Published measurements are on the benchmark results page.

Last updated on

Was this page helpful?