[bug] Chat completions sometimes do not follow requested template
@kelsey-wong is already working on this.
Since Dec 18, 2025.
Assessment
This issue has not been assessed yet.
Description
Sometimes, LiteLLM's response will omit the closing </answer> tag (which means that the <answer> tag will show up in the parsed response). Debug how to fix this and/or consider handling this through the parser.
Example:
Generated ObservedConsistencyQACompletionTemplate completion for messages:
[
{
"role": "user",
"content": "Explain the concept of machine learning in simple terms.\n\n\n## Additional instructions for formatting your response\n\nPlease strictly use the following template to format your response:\n\n<think>\n[think carefully step by step (no more than 375 words) before providing your answer]\n</think>\n\n<answer>\n[provide your final answer]\n</answer>"
}
]
Content:
<answer>
Machine learning is like teaching a computer to learn from examples, just like a person learns from experience. Instead of giving the computer exact instructions for every task, we show it lots of information or data. The computer looks for patterns in this data and uses what it has learned to make decisions or predictions on new information. For example, showing a computer many pictures of cats and dogs helps it learn how to tell the difference between them. Over time, the computer gets better at recognizing things or solving problems on its own without needing step-by-step instructions from a person.
Explanation:
To explain machine learning in simple terms, I first need to identify the core idea behind it without using technical jargon. Machine learning is about computers learning from data and improving over time without being explicitly programmed for every specific task.
Step-by-step:
1. Begin by comparing machine learning to something familiar, like learning for humans.
2. Explain that instead of writing instructions line-by-line, we let the computer figure out patterns by itself.
3. Mention that the computer uses data as examples to learn from.
4. Highlight the outcome, which is that after learning, the computer can make decisions or predictions.
5. Keep the explanation concise and easy to understand, avoiding complex terms like algorithms or neural networks.
This approach will help a beginner grasp the basic idea of machine learning clearly.
Response fields:
{
"answer": "<answer>\nMachine learning is like teaching a computer to learn from examples, just like a person learns from experience. Instead of giving the computer exact instructions for every task, we show it lots of information or data. The computer looks for patterns in this data and uses what it has learned to make decisions or predictions on new information. For example, showing a computer many pictures of cats and dogs helps it learn how to tell the difference between them. Over time, the computer gets better at recognizing things or solving problems on its own without needing step-by-step instructions from a person."
}
- Dominant language
- Python
- Stars
- 9
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 cleanlab/tlm
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Add deepseek supportMay be free again @katwinkl3 claimed this 324 days ago, and no pull request is open. Open
-
Set use_logprobs=False in ReferenceCompletionTemplate if model doesnt take that paramMay be free again @kelsey-wong claimed this 318 days ago, and no pull request is open. Open
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Cygnux-Labs/Tracekit#827 ·
Maintainers usually reply within 1 day
-
SPIDevice selects an active-high device as soon as it is createdPossibly taken @mikeysklar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
adafruit/circuitpython#11869 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
glossyio/traffic-monitor#312 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
narwhals-dev/narwhals#4154 ·
Maintainers usually reply within 1 day