Skip to content

ollama_code_citation

Code citations. RESEARCH. Answer a code question with PER-CLAIM CITATIONS (file + line range). Distinct from ollama_research: research cites files, code_citation cites LINES. Pass question (10-1000 chars), source_paths[], optional per_file_max_chars (default 100_000). Server numbers each line 1-based in the prompt so the Deep tier can anchor claims exactly. Returns {answer, citations:[{claim_fragment, file, start_line, end_line, excerpt}], uncited_fragments[], weak}. Citations to files outside source_paths are stripped (same rule as ollama_research). Citations with line ranges outside the loaded file bounds are also stripped — each stripping reason lands in warnings[]. Empty answer or answer-without-citations flips weak=true.

Parameter Type Required Default Description
question string yes The code question to answer. 10-1000 chars — specific enough that citations can be anchored (‘where does X get validated’, not ‘tell me about this code’).
source_paths any yes Files the answer must be grounded in. Citations to files outside this list are stripped.
per_file_max_chars integer no Chars to read per file (default 100_000). Bigger than research because citations need the lines to exist.
model string no Optional per-call model override. When provided, overrides the tool’s tier-resolved model for this call. The tier’s timeout (TIER_TIMEOUT_MS) still applies. On timeout, fallback uses the tier-resolved model, NOT the override. Use for receipt-backed orchestration that requires explicit model identity (e.g., research-os reviewer profiles).

The JSON Schema below is generated from the same zod schema the server validates against at the wire — it cannot drift from runtime behavior.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"question": {
"type": "string",
"minLength": 10,
"maxLength": 1000,
"description": "The code question to answer. 10-1000 chars — specific enough that citations can be anchored ('where does X get validated', not 'tell me about this code')."
},
"source_paths": {
"description": "Files the answer must be grounded in. Citations to files outside this list are stripped."
},
"per_file_max_chars": {
"description": "Chars to read per file (default 100_000). Bigger than research because citations need the lines to exist.",
"type": "integer",
"minimum": 1000,
"maximum": 500000
},
"model": {
"description": "Optional per-call model override. When provided, overrides the tool's tier-resolved model for this call. The tier's timeout (TIER_TIMEOUT_MS) still applies. On timeout, fallback uses the tier-resolved model, NOT the override. Use for receipt-backed orchestration that requires explicit model identity (e.g., research-os reviewer profiles).",
"type": "string",
"minLength": 1
}
},
"required": [
"question",
"source_paths"
]
}

Every tool returns the standard envelope — tier_used, model, tokens_in/tokens_out, elapsed_ms, backend provenance, warnings. See Envelope & tiers.

Schema + handler: src/tools/codeCitation.ts · registration: src/index.ts


Back to the Tool Reference.