Skip to content

Commit 5f6777d

Browse files
Merge pull request #844 from MervinPraison/claude/issue-840-20250712_172354
docs: add OLLAMA_HANDLING.md to explain ollama_handled flag usage
2 parents b4d4c39 + 896ce54 commit 5f6777d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Ollama Handling in LLM.py
2+
3+
The `ollama_handled` flag is used in `llm.py` (not in `agent.py`) to track whether special Ollama model handling has been applied for tool results. Here's what I found:
4+
5+
## Where it's used in llm.py:
6+
- **Line 863**: `ollama_handled = False` - initialized at the beginning of the tool execution loop
7+
- **Line 864**: Special handling logic via `_handle_ollama_model()` method
8+
- **Line 907**: `ollama_handled = True` - set when Ollama special handling is applied
9+
- **Line 928 & 959**: Checks `if not ollama_handled` to avoid duplicate processing
10+
11+
## Why it's needed:
12+
The flag prevents duplicate processing when Ollama models require special handling. Some Ollama models return only the tool call JSON without processing the results, requiring a follow-up prompt to get the final answer. The `ollama_handled` flag ensures this special handling happens only once.
13+
14+
## Does this contradict the requirement?
15+
**No, it doesn't.** The issue states:
16+
17+
> "ollama/xxxx model is already handled via llm.py via litellm, so no special condition or handling required for ollama inside agent.py"
18+
19+
**Current implementation is correct:**
20+
21+
- `agent.py` has NO ollama-specific conditions (only one documentation mention as an example)
22+
- All ollama handling is contained within `llm.py` as intended
23+
- The `ollama_handled` flag is an internal implementation detail within `llm.py`
24+
25+
The codebase already follows the desired pattern where ollama models are handled through the generic LLM interface via litellm without special conditions in agent.py.

0 commit comments

Comments
 (0)