feat(google): add Gemini execution guidance via prompt overlay [v3 6/6]#66379
feat(google): add Gemini execution guidance via prompt overlay [v3 6/6]#66379100yenadmin wants to merge 3 commits into
Conversation
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 SummaryThis PR adds a Gemini-specific prompt overlay for the Google extension, wiring operational directives (absolute paths, verify-first, parallel tool calls, etc.) into the The new Confidence Score: 4/5
Prompt To Fix All With AIThis 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 |
There was a problem hiding this comment.
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.tsdefining Gemini operational directives and a resolver returningsectionOverrides.tool_enforcement. - Wires
resolveSystemPromptContributioninto the Google provider registration. - Extends system prompt contribution plumbing by adding the
tool_enforcementsection 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. |
There was a problem hiding this comment.
💡 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".
- 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.
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).
|
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 |
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.tsGOOGLE_GEMINI_EXECUTION_GUIDANCE— 7 operational directives:-y/--yesflagsresolveGoogleSystemPromptContribution()→ returns guidance viasectionOverrides.tool_enforcementModified:
extensions/google/provider-registration.tsresolveSystemPromptContributioninto Google providerModified:
src/agents/system-prompt-contribution.ts+src/agents/system-prompt.tstool_enforcementsection ID (shared with PR 3)Architecture
Hermes Reference
agent/prompt_builder.pylines 256-276 —GOOGLE_MODEL_OPERATIONAL_GUIDANCE.Verification