Repository navigation
fix(openai): folded system messages keep their JSON blocks - #138
Conversation
`single_system_message` and `merge_system_into_user` gathered system content with a text-only helper that dropped JSON blocks and joined blocks with a newline. The pass-through path (`translate_text_content`) serializes JSON blocks and joins blocks with nothing between them, so a prompt sent to a hoisting or merging endpoint differed from the same prompt sent as-is, and lost any structured block. Render folded system content the same way.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): fix(openai): folded system messages keep their JSON blocks. Tiny Sweeper completed its review; deterministic results follow. Review snapshot
Completeness: Complete What changed`content_text` in the OpenAI transport previously filtered to text-only blocks and joined with `"\n"`, so a system JSON block was lost and multi-block system content was sent with different bytes than on pass-through routes. It now clones text, serializes JSON blocks via `to_string()`, still drops reasoning, and collects blocks with no separator, aligning with `translate_text_content`. The doc comment was rewritten to state the rule. Separate system messages are still joined with `"\n\n"` by the callers, and the merged-text shape is unchanged. No public API change. Features
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
Summary
single_system_message(strict local templates that need one leading system turn) andmerge_system_into_user(endpoints that reject the system role) gathered system content with a text-only helper. It droppedContentBlock::Jsonblocks and joined a message's blocks with"\n". The pass-through path (translate_text_content) serializes JSON blocks and joins blocks with nothing between them.So a system message with a JSON block lost that block on a hoisting or merging endpoint, and a multi-block system message was sent with different bytes than on every other route. The fix renders folded system content the way the pass-through path does: text verbatim, JSON serialized, reasoning dropped, no separator inside a message. Separate system messages are still joined with
"\n\n", and the merged-text shape is unchanged: one text block in front of the user's content, so text-only user turns stay a plain string and image turns keep one text part.Related issue
None. Found in an edge-case audit of the OpenHuman host (consumed via tinyagents). Not tracked as an issue.
API or behavior changes
No public API change. Behaviour: on hoisting/merging endpoints, a system JSON block is now sent (it was dropped), and multi-block system messages join their blocks without a newline, matching the pass-through path. Single-text-block system messages, the common case, are byte-identical.
Validation
cargo fmton the touched files (rustfmt --edition 2021)cargo clippy --all-targets --all-features -- -D warnings: left to CI.cargo build --all-targets --all-features: left to CI.cargo test -p tinyinference-llm --lib -- folded_system_messages single_system merge_system: with the fix, 10 passed. With the originalcontent_textrestored, the new test failed and the 9 existing folding tests passed.Tests
folded_system_messages_keep_their_json_blocks_as_sent_unfolded(providers/openai/mod_tests.rs): a system message[Text("Context: "), Json({"tenant":"acme"})]hoists toContext: {"tenant":"acme"}and merges into the user turn asContext: {"tenant":"acme"}\n\nhi. The existing folding tests (ordering, empty system messages, image preservation, promotion) are unchanged and pass.Documentation
The helper's doc comment states the rule. No user docs affected.
Checklist
#[allow(...)],#[ignore], or relaxed lints.envcontents in the diff or the description