Skip to content

feat(google): add Gemini execution guidance via prompt overlay [v3 6/6]#66379

Closed
100yenadmin wants to merge 3 commits into
openclaw:mainfrom
electricsheephq:gpt5-v3/google-gemini-execution-guidance
Closed

feat(google): add Gemini execution guidance via prompt overlay [v3 6/6]#66379
100yenadmin wants to merge 3 commits into
openclaw:mainfrom
electricsheephq:gpt5-v3/google-gemini-execution-guidance

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

GPT 5.4 Enhancement v3 — PR 6/6

Tracking: #66345 | Issue: #66352
Priority: P2 — LOW | Type: Provider Support

Problem

Hermes Agent includes Gemini/Gemma-specific operational guidance that addresses known failure modes. OpenClaw's Google extension has no prompt overlay — Gemini models get only the generic execution bias. This was filed as part of the same v3 for GPT 5.4 given the 0/10 parity scoring gap for Gemini.

Changes

New: extensions/google/prompt-overlay.ts

  • GOOGLE_GEMINI_EXECUTION_GUIDANCE — 7 operational directives:
    • Absolute paths for all file operations
    • Verify-first: check file contents before modifying
    • Dependency checks: verify package availability
    • Conciseness: brief explanations, focus on actions
    • Parallel tool calls: batch independent operations
    • Non-interactive commands: use -y/--yes flags
    • Keep going: work autonomously until done
  • resolveGoogleSystemPromptContribution() → returns guidance via sectionOverrides.tool_enforcement

Modified: extensions/google/provider-registration.ts

  • Wire resolveSystemPromptContribution into Google provider

Modified: src/agents/system-prompt-contribution.ts + src/agents/system-prompt.ts

  • Add tool_enforcement section ID (shared with PR 3)

Architecture

  ┌────────────────────────────────────────────────────┐
  │  Provider Prompt Overlay Pattern                    │
  │                                                     │
  │  extensions/openai/prompt-overlay.ts  (existing)    │
  │  ├── GPT-5 execution bias                           │
  │  ├── GPT-5 tool enforcement                         │
  │  ├── GPT-5 output contract                          │
  │  └── Friendly personality overlay                   │
  │                                                     │
  │  extensions/google/prompt-overlay.ts  (this PR)     │
  │  └── Gemini operational directives                  │
  │      (absolute paths, verify first, parallel calls) │
  │                                                     │
  │  Both use: sectionOverrides.tool_enforcement        │
  └────────────────────────────────────────────────────┘

Hermes Reference

agent/prompt_builder.py lines 256-276 — GOOGLE_MODEL_OPERATIONAL_GUIDANCE.

Verification

  • Gemini models receive operational directives in system prompt
  • Non-Google models don't receive Gemini directives
  • File-manipulation tasks use absolute paths

Add Gemini-specific operational directives that address known failure
modes: relative paths, missing dependency checks, interactive CLI
prompts hanging, and sequential-when-parallel tool calls.

Changes:
- New: extensions/google/prompt-overlay.ts with
  GOOGLE_GEMINI_EXECUTION_GUIDANCE constant and resolver
- Wire resolveSystemPromptContribution into Google provider registration
- Add tool_enforcement section ID (shared with PR 3) to support
  the sectionOverrides mechanism

Ported from Hermes Agent's GOOGLE_MODEL_OPERATIONAL_GUIDANCE
(prompt_builder.py lines 256-276).

Part of GPT 5.4 Enhancement v3 sprint. Closes #66352.
Tracking issue: #66345.
@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a Gemini-specific prompt overlay for the Google extension, wiring operational directives (absolute paths, verify-first, parallel tool calls, etc.) into the tool_enforcement section of the agent system prompt. The core changes to system-prompt-contribution.ts and system-prompt.ts are clean and minimal.

The new extensions/google/prompt-overlay.ts imports ProviderSystemPromptContribution directly from ../../src/agents/system-prompt-contribution.js, which violates the extension boundary rule — extension production code must only cross into core via openclaw/plugin-sdk/*. This will be caught by the check-additional CI gate. The fix is to either drop the explicit return-type annotation (letting it be inferred from the hook's declared signature, as the OpenAI extension does) or expose the type through the plugin SDK in the same change.

Confidence Score: 4/5

  • Not safe to merge until the src/** import in the extension is replaced with the SDK-safe pattern.
  • One P1 finding blocks merge: the direct ../../src/agents/system-prompt-contribution.js import from extension production code violates the documented and CI-enforced extension boundary, and will fail check-additional. Everything else is sound — the prompt content, the core section plumbing, and the overlay wiring are correct.
  • extensions/google/prompt-overlay.ts — fix the src/** import before landing.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/google/prompt-overlay.ts
Line: 2

Comment:
**Extension boundary violation: direct import from `src/**`**

`ProviderSystemPromptContribution` is imported directly from `../../src/agents/system-prompt-contribution.js`, which crosses into core `src/**` from extension production code. CLAUDE.md is explicit: "extensions must cross into core only through `openclaw/plugin-sdk/*`." The `check-additional` CI gate enforces this boundary.

The OpenAI extension (`extensions/openai/prompt-overlay.ts`) avoids this entirely — it returns the shape without annotating the return type, letting it be inferred from the hook's declared signature in `src/plugins/types.ts`. Either drop the explicit type annotation here and rely on inference, or expose `ProviderSystemPromptContribution` through a `openclaw/plugin-sdk/*` subpath in the same change.

```suggestion
import type { ProviderSystemPromptContribution } from "openclaw/plugin-sdk/provider-entry";
```
*(Only valid if/when the type is exported from that subpath; otherwise drop the import and remove the explicit return type annotation below.)*

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/google/provider-registration.ts
Line: 62-66

Comment:
**Hardcoded provider ID makes `shouldApplyGooglePromptOverlay` a no-op guard**

`modelProviderId` is always passed as the literal `"google"`, so the guard inside `resolveGoogleSystemPromptContribution` will unconditionally pass for every invocation of this hook. The `shouldApplyGooglePromptOverlay` logic (and the other two entries in `GOOGLE_PROVIDER_IDS`) becomes dead code from this call site. If the intent is that all aliases (`google-vertex`, `google-antigravity`) also receive the overlay, pass `ctx.provider` instead so the guard is live and the function's semantics are preserved.

```suggestion
    resolveSystemPromptContribution: (ctx) =>
      resolveGoogleSystemPromptContribution({
        modelProviderId: ctx.provider,
        modelId: ctx.modelId,
      }),
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(google): add Gemini execution guida..." | Re-trigger Greptile

Comment thread extensions/google/prompt-overlay.ts Outdated
Comment thread extensions/google/provider-registration.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a Google (Gemini) provider prompt overlay to inject model-specific operational/tooling guidance into the agent system prompt via a new tool_enforcement overridable section.

Changes:

  • Introduces extensions/google/prompt-overlay.ts defining Gemini operational directives and a resolver returning sectionOverrides.tool_enforcement.
  • Wires resolveSystemPromptContribution into the Google provider registration.
  • Extends system prompt contribution plumbing by adding the tool_enforcement section id and inserting it into the assembled system prompt.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/agents/system-prompt.ts Inserts an overridable tool_enforcement section into the built system prompt.
src/agents/system-prompt-contribution.ts Adds tool_enforcement to ProviderSystemPromptSectionId.
extensions/google/provider-registration.ts Wires Google provider resolveSystemPromptContribution to the new overlay resolver.
extensions/google/prompt-overlay.ts New Google overlay defining Gemini directives and returning them via sectionOverrides.tool_enforcement.

Comment thread extensions/google/prompt-overlay.ts
Comment thread extensions/google/prompt-overlay.ts Outdated
Comment thread extensions/google/prompt-overlay.ts
Comment thread extensions/google/provider-registration.ts
Comment thread extensions/google/provider-registration.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 199932cb75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/google/prompt-overlay.ts Outdated
Comment thread extensions/google/provider-registration.ts
- Remove direct src/ import (extension boundary violation). Use
  inline return type instead of importing ProviderSystemPromptContribution.
- Wire resolveSystemPromptContribution to Gemini CLI provider
  (google-gemini-cli) in addition to the base google provider.
- Add google-gemini-cli to GOOGLE_PROVIDER_IDS set.
- Remove "Absolute paths" directive (conflicts with sandbox guidance
  that recommends relative paths in sandboxed environments).
- Replace em dashes with commas/periods per GPT-5 output contract.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Parity audit: previous iteration rewrote the Gemini directives based
on bot suggestions (em dash ban, generic wording), diverging from
Hermes's GOOGLE_MODEL_OPERATIONAL_GUIDANCE (prompt_builder.py:258-276).

Restore Hermes text verbatim:
- "# Google model operational directives" heading (was ## Gemini ...)
- Em dashes restored in Conciseness and Keep going bullets
- "Don't stop with a plan — execute it" exact Hermes phrasing

Kept deviations, each documented in a comment above the constant:
1. "Absolute paths" bullet remains omitted — OpenClaw's sandbox
   container workdir differs from host workspace, and the core system
   prompt explicitly tells the model to prefer relative paths so exec
   and file tools work consistently (src/agents/system-prompt.ts:600).
   Injecting Hermes's absolute-path rule would directly contradict
   this and break exec. High-confidence, documented exception.
2. Tool ID substitution: read_file/search_files -> read or exec
   (mechanical rename; no grep/find/search_files tools exist in the
   OpenClaw catalog).
@100yenadmin

Copy link
Copy Markdown
Contributor Author

Superseded by consolidated final-sprint PRs. This PR's changes are incorporated into:

The v3 PRs were split across 6 separate PRs which made review harder and touched the same files redundantly. The final-sprint consolidation combines them into 3 clean, independently-mergeable PRs rebased on current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants