docs: make user guidance easier to follow

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-19 10:11:45 +08:00
1 parent b702ac633f
commit 1832255995
18 files changed
+45 -76

No files matched your search

+3 -3
View File
@@ -1,6 +1,6 @@
# How to Improve Ollama Tool-Calling Prompt Cache Reuse in nanobot
# Reuse Ollama Prompt Cache to Reduce Repeated Processing
Some Ollama model templates move or remove tool definitions as a conversation switches between user, assistant, and tool messages. nanobot can send a correct append-only chat request while the model template still renders a different token prefix. On slower local hardware, re-evaluating that prefix can add tens of seconds to an otherwise simple tool-using turn.
Ollama can reuse work from an earlier prompt when the beginning of the prompt stays the same. Some model templates move or remove tool instructions as a conversation switches between user, assistant, and tool messages, so Ollama must process much of the prompt again. On slower local hardware, this can add tens of seconds to a tool-using turn.
This guide shows how to diagnose that specific pattern and create a derived `llama3.1:8b` tag with a prefix-stable tool template. It does not modify nanobot or overwrite the original Ollama model.
@@ -66,7 +66,7 @@ The cache is working, but the next main request can reuse only the shorter promp
To inspect the API request bodies as well, add `OLLAMA_DEBUG_LOG_REQUESTS=1` before starting Ollama. These logs can contain system prompts, workspace context, and user messages. Keep them local and disable request logging after diagnosis.
## Why this happens with the stock template
## Why the default template can limit cache reuse
The tested `llama3.1:8b` template conditionally expands the tool definitions inside a user message: