Skip to content

Add default system prompt for gpt-oss models to discourage table output#151

Open
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1772685259-gpt-oss-default-system-prompt
Open

Add default system prompt for gpt-oss models to discourage table output#151
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1772685259-gpt-oss-default-system-prompt

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Mar 5, 2026

Summary

When users interact with gpt-oss models via the Responses API without a system prompt set (neither per-request instructions nor 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-oss and never overwrites any user-defined system prompt. The precedence chain is:

  1. Per-request instructions field → used if provided
  2. User's saved default instruction → used if exists
  3. New: gpt-oss default anti-table prompt → used only for gpt-oss models
  4. No system prompt → all other models

Review & Testing Checklist for Human

  • Verify prompt effectiveness: Send a few simple questions to gpt-oss through the Responses API without setting a system prompt and confirm tables are no longer produced by default. Then try explicitly asking for a table to confirm that still works.
  • Verify user prompts aren't overwritten: Set a custom system prompt (via instructions or a default user instruction) and confirm it is used instead of the anti-table fallback.
  • Review the model matching pattern: model.starts_with("gpt-oss") is used — confirm this is the right granularity (currently only gpt-oss-120b exists, but this would also match any future gpt-oss-* variants).

Notes


Open with Devin

Summary by CodeRabbit

  • New Features
    • Improved response formatting for gpt-oss models to prioritize prose-based answers over tables by default, with tables appearing only when explicitly requested.

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-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: tony@opensecret.cloud <TonyGiorgio@protonmail.com>
Copy link
Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@AnthonyRonning
Copy link
Contributor

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 660853a5-60a5-482a-9e5c-5ab48d93d520

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Added 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

Cohort / File(s) Summary
GPT-OSS Model System Prompt
src/web/responses/context_builder.rs
Introduced GPT_OSS_DEFAULT_SYSTEM_PROMPT constant and added conditional branch to inject this default system prompt for gpt-oss models when no user instructions are provided. Includes token counting and debug logging. Also added debug to tracing imports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A whisker-tweaked prompt for models gpt-oss,
No tables allowed, just prose—no moss,
When tokens are counted and logged with care,
The rabbit hops forward without a scare! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add default system prompt for gpt-oss models to discourage table output' directly and accurately describes the main change: adding a default system prompt specific to gpt-oss models with anti-table behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1772685259-gpt-oss-default-system-prompt

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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-oss gets 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

📥 Commits

Reviewing files that changed from the base of the PR and between bdf789f and 65ee608.

📒 Files selected for processing (1)
  • src/web/responses/context_builder.rs

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