← Back to Pull requests

fix(prompt): restore the upstream no-chitchat constraint for Google models #136507

Open
liuhao1024 opened this pull request with 58 lines diff across 2 files
View on GitHub
liuhao1024 liuhao1024 commented on Oct 11, 2026 08:11 UTC
Author

What does this PR do?

GOOGLE_MODEL_OPERATIONAL_GUIDANCE was adapted from OpenCode's gemini.txt, but the adaptation dropped the upstream negative constraint against conversational filler and preambles. With only the Conciseness bullet surviving, Gemini models read it as a mandate to open every action with an unsolicited English preamble or step header (e.g. Confirming Understanding

I am currently...) emitted directly in message content — even in non-English conversations and on turns with no tool calls. Because these preambles are content (not reasoning_content/thought fields), gateways cannot suppress them via display.show_reasoning: false or tool_progress: off.

This restores the upstream OpenCode No Chitchat bullet verbatim, placed directly after the Conciseness bullet it bounds, so the negative constraint travels with the instruction that triggers the behavior. The Conciseness bullet itself is kept: it is a useful upstream instruction, and the missing piece was the negative constraint, not an excess one.

Related Issue

Fixes #136497

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • Changes Made

  • agent/prompt_builder.py — added the upstream - No chitchat: Avoid conversational filler, preambles (...), or postambles (...). Get straight to the action or answer. bullet to GOOGLE_MODEL_OPERATIONAL_GUIDANCE, next to the Conciseness bullet, with a comment noting why the negative constraint must stay.

  • tests/agent/test_google_model_operational_guidance.py — new regression tests pinning the restored bullet and its Gemini/Gemma-only injection (a grok model passes the enforcement gate but must not receive the Google guidance).
  • How to Test

    1. .venv/bin/python -m pytest tests/agent/test_google_model_operational_guidance.py -q — 3 passed.
    2. .venv/bin/python -m pytest tests/agent/test_system_prompt.py -q — 72 passed; 4 pre-existing failures reproduce identically on a clean upstream/main checkout (home_io_guard environment, unrelated to this diff).
    3. python scripts/check --staged — the only FAILED lane is health with 40 blocking findings, the same count as the main baseline; none reference the changed files.

    Observed result: the guidance injected for google/gemini-3.8-flash now contains the upstream no-chitchat/preamble/postamble negative constraint; non-Google models that pass the enforcement gate (e.g. x-ai/grok-4) still do not receive the Google block.

    Checklist

    Code

  • I've read the Contributing Guide

  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)

  • I searched for existing PRs to make sure this isn't a duplicate

  • My PR contains only changes related to this fix/feature (no unrelated commits)

  • I've run pytest tests/ -q and all tests pass

  • python scripts/check passes (the blocking lint and code-health checks CI runs)

  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)

  • I've tested on my platform: macOS 15 (arm64)
  • Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A

  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A

  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A

  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A

  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A
  • Diff: 58 lines (+58 / -0) across 2 files Reviewer: PRATHAMESH75 Review duration: 78978m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.41) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 58 lines diff across 2 files
    0.41
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.94 · 2 substantive comment(s)
    0.94
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    88%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.244
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    4 items
    PRATHAMESH75 PRATHAMESH75 commented on Oct 11, 2026 08:42 UTC
    Reviewer

    <!-- hermes-autotriage -->
    <!-- action=reviewed pr=136507 head=d429b6c at=2026-10-11T08:42Z -->

    The change is safe. It only applies to Gemini/Gemma, and the OpenCode no-chitchat bullet it restores is reasonable. Tests pass locally (test_google_model_operational_guidance.py + test_system_prompt.py, 76 passed). I'm not sure it fixes the symptom in #136497, though, and it's worth confirming before this closes the issue:

    1. The samples in #136497 read like Gemini thought summaries, not preambles. Gemini emits its thought summaries as a bold title followed by first-person narration, which is exactly the shape of Confirming Understanding\n\nI am currently... and Assessing Model Tier\n\nMy focus is.... Normal conversational preambles ("Okay, I will now...") don't look like that. If those are thought parts reaching content, no system-prompt wording will suppress them. The fix would then be in the transport: the native adapter already separates part.thought is True (agent/gemini_native_adapter.py:616), and the OpenAI-compat path sends include_thoughts: True (agent/transports/chat_completions.py:189). The issue is labeled needs-repro, so knowing which transport the reporter is on (native gemini, Vertex, the OpenAI-compat endpoint, or OpenRouter) and whether reasoning.effort: none makes the headers go away would tell us which fix is right.
    2. If it really is preamble text, Fixes #136497 is fine. Even then, a prompt nudge is probabilistic, so "Refs" may be more accurate until the reporter confirms.
    3. Test shape: test_guidance_carries_upstream_no_chitchat_bullet asserts literal prompt wording ("- No chitchat:", "postambles"). That's close to the change-detector pattern AGENTS.md asks us to avoid, because any rewording breaks it without a behavior change. The two injection tests (Gemini gets it, grok doesn't) are the real contract, and they could check for the Google model operational directives header instead of the bullet text.

    Since these strings go into the stable system prompt, they only change on a new session, so prompt caching is fine.

    hanxuesheng hanxuesheng commented on Oct 11, 2026 09:11 UTC
    Contributor

    Thanks for looking into this @PRATHAMESH75! Here are the environment and reproduction details from our setup:

    1. Transport & Provider:
    - We are running on provider: vertex (Google Cloud Vertex AI using Application Default Credentials / OAuth2 token).
    - Under the hood, this uses Hermes's standard chat_completions transport pointing to Vertex's OpenAI-compatible endpoint (https://{region}-aiplatform.googleapis.com/v1beta1/projects/{project}/locations/{region}/endpoints/openapi).
    - Model: google/gemini-3.8-flash.

    2. Preamble vs. Thought Summary:
    - In agent/transports/chat_completions.py (line 547), thinking_config (and include_thoughts) is currently only attached when provider_name == "gemini", but not for provider: vertex.
    - The emitted text (Confirming Understanding, Assessing Model Tier, etc.) is received as standard streaming content deltas. It directly reflects Gemini's behavioral tendency when instructed to "Keep explanatory text brief — a few sentences, not paragraphs. Focus on actions and results over narration" without the upstream negative constraints (No chitchat / preambles).

    3. Regarding PR #136507:
    - Restoring the upstream OpenCode No chitchat negative constraint directly bounds the Conciseness bullet and is definitely necessary for Google models regardless of transport.
    - If Vertex also exposes thoughts in content, extending chat_completions.py to forward thinking_config to provider: vertex as well would be a great complementary fix!

    liuhao1024 liuhao1024 commented on Oct 11, 2026 09:21 UTC
    Author

    Thanks for the detailed environment info — very helpful.

    One clarification on point 2: for provider: vertex, requests don't go through the legacy provider_name == "gemini" branch in chat_completions.py. Vertex has its own provider profile (plugins/model-providers/vertex/__init__.py, in place since July) whose build_extra_body() already forwards exactly what you're suggesting: extra_body.google.thinking_config in the snake_case form the Vertex OpenAI-compatible endpoint documents (and its google-vertex / vertex-ai / gcp-vertex / vertexai aliases resolve to the same profile). So a Vertex route does emit thinking_config — e.g. {"include_thoughts": true, "thinking_level": "medium"} for gemini-3.8-flash at medium effort, or thinking_budget: 0 when reasoning is set to none. No second chat_completions.py change is needed for this.

    That leaves the two symptoms usefully separated, matching @PRATHAMESH75's question:

    1. If the bold-title blocks disappear when reasoning is set to none (thinkingBudget 0), they were thought summaries — a transport/thinking-level concern, not something a prompt change can address.
    2. If they persist with thinking off, they're genuine preambles the model narrates as regular content — which is what the restored no-chitchat constraint in this PR bounds (and as you note, that fix applies to Google models regardless of transport).

    Either way the prompt-side fix here stays valid on its own.

    Reviewers
    Assignees
    liuhao1024 liuhao1024
    Labels
    risk: low confidence: 88.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.8% (MEDIUM) · Higher = larger blast radius
    40.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88.9% · Lower = rushed or shallow review
    88.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.5% · Safe to merge
    4.5%