[Bug]: LLM proxy reports finish_reason "stop" for native Ollama responses truncated by max_tokens
Maintainers usually reply within 2 days
@saisriram-dev is already working on this.
Since Dec 4, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- ollama, python
- Domain
- backend-api-design
Research direction
Read _transform_ollama_response and _transform_ollama_stream_chunk in mcpgateway/services/llm_proxy_service.py, then find the unit tests for both response paths. Check how native Ollama's done_reason is represented, especially length, and add tests for the mapping described in the issue. Done when both paths return length for token limit truncation and preserve stop for other completion reasons.
Written by the indexing model from the issue text.
Description
When the LLM proxy talks to a native Ollama endpoint (/api/chat), _transform_ollama_response and _transform_ollama_stream_chunk in mcpgateway/services/llm_proxy_service.py always emit finish_reason: "stop" once done is true, ignoring Ollama's done_reason. So a reply cut off by the token limit (options.num_predict, which the proxy sets from max_tokens) comes back as done_reason: "length" from Ollama but as finish_reason: "stop" to OpenAI clients, and they can't detect the truncation. Minimal check against Ollama: POST /api/chat with "options": {"num_predict": 8} returns "done": true, "done_reason": "length". Proposed fix: map done_reason == "length" to "length" (anything else stays "stop") in both functions, with unit tests for both paths. Happy to open a PR once this is triaged.
- Dominant language
- Python
- Stars
- 4.9k
- Forks
- 1k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 91
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IBM/mcp-context-forge
-
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
IBM/mcp-context-forge#7762 ·
Maintainers usually reply within 2 days
-
chore kaizen ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
IBM/mcp-context-forge#7681 ·
Maintainers usually reply within 2 days
-
bug triage ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
IBM/mcp-context-forge#7671 ·
Maintainers usually reply within 2 days
-
[API][UI-REWRITE]: Expose whether query parameter authentication is enabled on FeatureFlagsPossibly taken @ningyixi claimed this 7 days ago. Open1.1-Phase-1 a2a api enhancement SHOULD ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
IBM/mcp-context-forge#7670 ·
Maintainers usually reply within 2 days
-
[BUG]: Derived A2A tool lookup is unscoped, so an agent can bind to another team's tool and credentialsMay be free again @VfourTwenty claimed this 9 days ago, and no pull request is open. Open1.1-Phase-1 a2a bug security SHOULD triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
IBM/mcp-context-forge#7668 · 1 comment ·
Maintainers usually reply within 2 days
All issues in IBM/mcp-context-forge
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choicePossibly taken @beartester34 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelscope/evalscope#2330 ·
Maintainers usually reply within 1 day
-
Distribution plot crashes when a numeric feature is constant in the train or test setPossibly taken @adembilge claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
MAIF/shapash#847 · 1 comment ·
Maintainers usually reply within 10 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
namespace team:operations
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
EclipseFdn/open-vsx.org#16738 ·
Maintainers usually reply within 1 day