Repository navigation
Stop Gemma string args at the next argument when closed with a quote - #288
Merged
Merged
Conversation
Gemma sometimes writes a text tool call that opens a string with <|"|>
and closes it with a plain quote, as in
draw_image{caption:<|"|>Text",prompt:<|"|>...<|"|>}. The fallback inline
parser read the caption up to the next <|"|>, so the caption shown under
the image ended with `",prompt:`.
A <|"|> right after `,key:` now opens the next argument instead of closing
the current one, and a value that was not closed by <|"|> drops an
unmatched trailing quote.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Gemma sometimes writes a tool call as text and closes a
<|"|>string with a plain quote:The strict Gemma parser rejects this shape, so the fallback inline parser handles it. That parser read the caption up to the next
<|"|>, which is the opening delimiter ofprompt. The prompt came out right, but the caption under the image ended with",prompt:.Change
inline_arg_end, a<|"|>right after,key:(a known inline argument key) opens the next argument and no longer closes the current value. The value then ends at the separator, like an unclosed string.<|"|>-opened value does not end at a<|"|>, an unmatched trailing"or'is dropped. Balanced quotes inside the value stay.Tests
New test
gemma_string_closed_with_a_plain_quote_ends_before_the_next_argumentcovers the exact failing shape, a missing closing quote, a plain-quoted next argument, and a caption with quotes and a comma inside that must stay unchanged. The test failed before the change.cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test -p openplotva-dialog(109 passed)cargo test -p openplotva-llm(221 passed, 2 ignored)cargo test -p openplotva-app dialog(354 passed, 1 ignored)