Skip to content

Stop Gemma string args at the next argument when closed with a quote - #288

Merged
iamwavecut merged 1 commit into
mainfrom
fix/gemma-misclosed-string-args
Nov 6, 2026
Merged

iamwavecut merged 1 commit into
mainfrom
fix/gemma-misclosed-string-args

Conversation

@iamwavecut

Copy link
Copy Markdown
Owner

Problem

Gemma sometimes writes a tool call as text and closes a <|"|> string with a plain quote:

draw_image{caption:<|"|>Text",prompt:<|"|>A detailed prompt<|"|>}

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 of prompt. The prompt came out right, but the caption under the image ended with ",prompt:.

Change

  • In 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.
  • When a <|"|>-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_argument covers 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 -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo 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)

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.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Messages
📖 Danger checked 1 changed file(s).

Generated by 🚫 dangerJS against 3fcd19a

Comment thread crates/openplotva-dialog/src/lib.rs Resolved
@iamwavecut
iamwavecut merged commit ea60e16 into main Nov 6, 2026
12 checks passed
@iamwavecut
iamwavecut deleted the fix/gemma-misclosed-string-args branch November 6, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant