Add default system prompt for gpt-oss models to discourage table output#151
Add default system prompt for gpt-oss models to discourage table output#151devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
Conversation
When a user communicates with gpt-oss models through the responses API and has no system prompt set (neither per-request instructions nor a default user instruction), inject a default system prompt that instructs the model to avoid formatting responses as tables unless explicitly asked. This only applies to gpt-oss models and does not overwrite any user-defined system prompts. Co-Authored-By: tony@opensecret.cloud <TonyGiorgio@protonmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: tony@opensecret.cloud <TonyGiorgio@protonmail.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdded support for gpt-oss models in the context builder by injecting a default system prompt that discourages table formatting in responses. The change includes a new constant defining the anti-table prompt, conditional logic to apply it to gpt-oss models, and debug logging for observability. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/web/responses/context_builder.rs (1)
56-63: Add a focused regression test for fallback precedence.This branch is correct, but it should be locked with tests for: (1) override wins, (2) saved default wins, (3) gpt-oss fallback applies only when both are absent, and (4) non-
gpt-ossgets no fallback.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/web/responses/context_builder.rs` around lines 56 - 63, Add a focused regression test suite that exercises the system-prompt fallback precedence in the context-building logic: write four tests that call the code path which evaluates model.starts_with("gpt-oss") and returns the optional system role/contents/token tuple (use the same function or module that uses GPT_OSS_DEFAULT_SYSTEM_PROMPT, ROLE_SYSTEM and count_tokens). Test A (override wins) provides an explicit user override and asserts that override text is returned and GPT_OSS_DEFAULT_SYSTEM_PROMPT is not used; Test B (saved default wins) sets a saved default and asserts that saved default text is returned over the gpt-oss fallback; Test C (gpt-oss fallback applies only when both are absent) ensures no override and no saved default result in ROLE_SYSTEM with GPT_OSS_DEFAULT_SYSTEM_PROMPT and that the returned token count equals count_tokens(GPT_OSS_DEFAULT_SYSTEM_PROMPT); Test D (non-gpt-oss gets no fallback) uses a non-"gpt-oss" model string and asserts the optional system tuple is None (or equivalent) so the fallback is not applied.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/web/responses/context_builder.rs`:
- Around line 56-63: Add a focused regression test suite that exercises the
system-prompt fallback precedence in the context-building logic: write four
tests that call the code path which evaluates model.starts_with("gpt-oss") and
returns the optional system role/contents/token tuple (use the same function or
module that uses GPT_OSS_DEFAULT_SYSTEM_PROMPT, ROLE_SYSTEM and count_tokens).
Test A (override wins) provides an explicit user override and asserts that
override text is returned and GPT_OSS_DEFAULT_SYSTEM_PROMPT is not used; Test B
(saved default wins) sets a saved default and asserts that saved default text is
returned over the gpt-oss fallback; Test C (gpt-oss fallback applies only when
both are absent) ensures no override and no saved default result in ROLE_SYSTEM
with GPT_OSS_DEFAULT_SYSTEM_PROMPT and that the returned token count equals
count_tokens(GPT_OSS_DEFAULT_SYSTEM_PROMPT); Test D (non-gpt-oss gets no
fallback) uses a non-"gpt-oss" model string and asserts the optional system
tuple is None (or equivalent) so the fallback is not applied.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 257cc5fe-33b9-4670-90e9-89f855385a0c
📒 Files selected for processing (1)
src/web/responses/context_builder.rs
Summary
When users interact with gpt-oss models via the Responses API without a system prompt set (neither per-request
instructionsnor a saved default user instruction), a hardcoded system prompt is now injected that discourages the model from producing tables unless explicitly asked. This addresses gpt-oss's tendency to format even simple answers as tables.The fallback only activates for models whose name starts with
gpt-ossand never overwrites any user-defined system prompt. The precedence chain is:instructionsfield → used if providedReview & Testing Checklist for Human
instructionsor a default user instruction) and confirm it is used instead of the anti-table fallback.model.starts_with("gpt-oss")is used — confirm this is the right granularity (currently onlygpt-oss-120bexists, but this would also match any futuregpt-oss-*variants).Notes
Summary by CodeRabbit