Repository navigation
Fix Llama32 tool-call parser truncating text after final call - #28845
codewithfourtix wants to merge 3 commits into
Conversation
`Llama32Detector.detect_and_parse` advanced the cursor by
`end + len(self.tool_call_separator)` after decoding each JSON tool call,
unconditionally skipping a separator-width character. When free-form text
follows the final call without a separator (e.g. `{...}}Some text`), this
ate the first character of that text, returning `ome text` instead of
`Some text`.
Only consume a separator when one is actually present. Add a regression
test; the existing `test_json_with_trailing_text` masked the bug by using
a leading space (stripped anyway) plus a substring-only assertion.
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the Llama 3.2 function call detector where free-form text immediately following a tool call without a separator would have its first character truncated. It updates the parser to only consume the separator when present and adds a regression test. The reviewer suggests optimizing the separator-skipping logic to avoid string slicing and points out that the same truncation bug still exists in the Python dict fallback path, recommending a fix and an additional test case for it.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
Motivation
Llama32Detector.detect_and_parseadvanced the cursor byend + len(self.tool_call_separator)after decoding each JSON tool call,unconditionally skipping a separator-width character. When free-form text
follows the final call without a separator (e.g.
{...}}Some text), this atethe first character of that text, returning
ome textinstead ofSome text: