---
title: Give a coding agent code pointers before it starts
description: 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.
lastModified: '2026-11-29T04:56:39.000Z'
seo:
  title: Code pointers for a coding agent's task prompt
sidebar:
  label: Code pointers for a coding agent's task prompt
---

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.

## Index the repository first

The request reads a code namespace, so [add and index the repository](/docs/features/code-index/repositories)
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](/docs/features/code-index/freshness#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](/docs/features/code-index/repositories#who-can-read)).

## Make the one request

[`sdk/python/examples/issue_code_pointers.py`](https://github.com/ClickHouse/loom/blob/main/sdk/python/examples/issue_code_pointers.py)
is the whole pattern. In a pipeline:

```python
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:

```bash
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](#the-request-makes-no-text-generation-call)).                              |
| `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](/docs/reference/operations/code#codesearch):

| 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](#send-nothing-when-the-index-does-not-stand-behind-its-answer)).                      |
| `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

```text
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](/docs/features/integrations/claude-code#what-the-hooks-do).
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.

## 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](/docs/guides/repository-questions#calibrate-the-embedding-model) 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](/docs/getting-started/models-and-keys#what-works-without-provider-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"`       |

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](/docs/features/code-index/overview#language-support)). Source the
  index reads as text is never listed.
- This page quotes no measurement. Published measurements are on the
  [benchmark results](/docs/benchmarks/results) page.

## Related

- [Code index overview](/docs/features/code-index/overview): what the index holds and
  how to read an answer.
- [Code tools for model integrations](/docs/guides/code-tools): the other way round, where the
  model chooses when to look code up.
- [Choose AI software factory tools](/docs/guides/software-factory-tools): what each stage of a
  pipeline should produce.
