Skip to content

feat(google): add Gemini execution guidance via prompt overlay [v3 final 2/3]#67513

Closed
100yenadmin wants to merge 1 commit into
openclaw:mainfrom
electricsheephq:final-sprint/gpt5-google-gemini-guidance
Closed

feat(google): add Gemini execution guidance via prompt overlay [v3 final 2/3]#67513
100yenadmin wants to merge 1 commit into
openclaw:mainfrom
electricsheephq:final-sprint/gpt5-google-gemini-guidance

Conversation

@100yenadmin

Copy link
Copy Markdown
Contributor

GPT 5.4 Enhancement v3 — Final Sprint PR 2/3

Tracking: #66345
Supersedes: #66379

Rebased on current main (incorporates 356110c5 provider-hooks refactor). Ports Hermes Agent's Google model operational directives.

What this PR adds

Gemini operational directives (Hermes prompt_builder.py:258-276)

  • Verify first, dependency checks, conciseness, parallel tool calls, non-interactive commands, keep going
  • Em dashes and exact Hermes wording preserved
  • One documented deviation: "Absolute paths" bullet omitted (OpenClaw sandbox prefers relative paths per system-prompt.ts:600)

Provider wiring

  • resolveSystemPromptContribution wired to both google and google-gemini-cli providers
  • Uses sectionOverrides.tool_enforcement (requires tool_enforcement section ID from PR 1/3 or includes it independently)

Files changed (5)

  • extensions/google/prompt-overlay.ts (new)
  • extensions/google/provider-registration.ts
  • extensions/google/gemini-cli-provider.ts
  • src/agents/system-prompt-contribution.ts
  • src/agents/system-prompt.ts

Parity constraint

Hermes-verbatim text with documented tool-ID substitutions only.

Ported from Hermes Agent's GOOGLE_MODEL_OPERATIONAL_GUIDANCE
(prompt_builder.py lines 258-276) with Hermes-verbatim text (only
mechanical tool-ID substitutions and one documented deviation:
"Absolute paths" bullet omitted due to sandbox path conflict at
src/agents/system-prompt.ts:600).

Changes:
- New: extensions/google/prompt-overlay.ts with Gemini operational
  directives (verify first, dependency checks, parallel calls,
  non-interactive commands, keep going)
- Wire resolveSystemPromptContribution into both google and
  google-gemini-cli providers (rebased on 356110c's provider-hooks
  refactor)
- Add tool_enforcement section ID and rendering (shared with PR 1)

Part of GPT 5.4 Enhancement v3 sprint. Tracking: #66345.
Supersedes: #66379.
Copilot AI review requested due to automatic review settings April 16, 2026 05:01
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S r: too-many-prs Auto-close: author has more than twenty active PRs. labels Apr 16, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

@greptile-apps

greptile-apps Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a tool_enforcement system-prompt section with Gemini-specific operational directives (ported from Hermes prompt_builder.py), wires it through resolveSystemPromptContribution for both the google and google-gemini-cli providers, and extends the ProviderSystemPromptSectionId union accordingly. The implementation follows the extension-boundary rules correctly (no src/ imports, inline return type).

Confidence Score: 5/5

Safe to merge; all findings are P2 style suggestions with no correctness impact.

The two issues (dead set entries and unused parameter) are purely cosmetic and do not affect runtime behavior. Core wiring and prompt-cache stability are correct.

extensions/google/prompt-overlay.ts — minor dead code in GOOGLE_PROVIDER_IDS and unused modelId parameter.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/google/prompt-overlay.ts
Line: 3

Comment:
**Dead entries in `GOOGLE_PROVIDER_IDS`**

`"google-vertex"` and `"google-antigravity"` can never be matched. Both call sites hardcode specific IDs — `provider-registration.ts` always passes `"google"`, and `gemini-cli-provider.ts` always passes `"google-gemini-cli"`. Since `google-vertex` and `google-antigravity` are `hookAliases` of `"google"`, those models already receive the overlay through the `"google"` entry. The two extra entries are unreachable dead code that may mislead future maintainers into thinking these providers are independently wired.

```suggestion
const GOOGLE_PROVIDER_IDS = new Set(["google", "google-gemini-cli"]);
```

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/prompt-overlay.ts
Line: 35-38

Comment:
**Unused `modelId` parameter**

`modelId` is accepted but never read — only `modelProviderId` influences the return value. If this parameter is reserved for future per-model differentiation, a short comment explaining that intent would prevent it from appearing as an oversight. Otherwise, removing it keeps the signature honest.

```suggestion
export function resolveGoogleSystemPromptContribution(params: {
  modelProviderId?: string;
  // modelId reserved for future per-model guidance differentiation
  modelId?: string;
}): { sectionOverrides: Record<string, string> } | undefined {
```

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

@@ -0,0 +1,47 @@
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";

const GOOGLE_PROVIDER_IDS = new Set(["google", "google-vertex", "google-antigravity", "google-gemini-cli"]);

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.

P2 Dead entries in GOOGLE_PROVIDER_IDS

"google-vertex" and "google-antigravity" can never be matched. Both call sites hardcode specific IDs — provider-registration.ts always passes "google", and gemini-cli-provider.ts always passes "google-gemini-cli". Since google-vertex and google-antigravity are hookAliases of "google", those models already receive the overlay through the "google" entry. The two extra entries are unreachable dead code that may mislead future maintainers into thinking these providers are independently wired.

Suggested change
const GOOGLE_PROVIDER_IDS = new Set(["google", "google-vertex", "google-antigravity", "google-gemini-cli"]);
const GOOGLE_PROVIDER_IDS = new Set(["google", "google-gemini-cli"]);
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/google/prompt-overlay.ts
Line: 3

Comment:
**Dead entries in `GOOGLE_PROVIDER_IDS`**

`"google-vertex"` and `"google-antigravity"` can never be matched. Both call sites hardcode specific IDs — `provider-registration.ts` always passes `"google"`, and `gemini-cli-provider.ts` always passes `"google-gemini-cli"`. Since `google-vertex` and `google-antigravity` are `hookAliases` of `"google"`, those models already receive the overlay through the `"google"` entry. The two extra entries are unreachable dead code that may mislead future maintainers into thinking these providers are independently wired.

```suggestion
const GOOGLE_PROVIDER_IDS = new Set(["google", "google-gemini-cli"]);
```

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

Comment on lines +35 to +38
export function resolveGoogleSystemPromptContribution(params: {
modelProviderId?: string;
modelId?: string;
}): { sectionOverrides: Record<string, string> } | undefined {

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.

P2 Unused modelId parameter

modelId is accepted but never read — only modelProviderId influences the return value. If this parameter is reserved for future per-model differentiation, a short comment explaining that intent would prevent it from appearing as an oversight. Otherwise, removing it keeps the signature honest.

Suggested change
export function resolveGoogleSystemPromptContribution(params: {
modelProviderId?: string;
modelId?: string;
}): { sectionOverrides: Record<string, string> } | undefined {
export function resolveGoogleSystemPromptContribution(params: {
modelProviderId?: string;
// modelId reserved for future per-model guidance differentiation
modelId?: string;
}): { sectionOverrides: Record<string, string> } | undefined {
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/google/prompt-overlay.ts
Line: 35-38

Comment:
**Unused `modelId` parameter**

`modelId` is accepted but never read — only `modelProviderId` influences the return value. If this parameter is reserved for future per-model differentiation, a short comment explaining that intent would prevent it from appearing as an oversight. Otherwise, removing it keeps the signature honest.

```suggestion
export function resolveGoogleSystemPromptContribution(params: {
  modelProviderId?: string;
  // modelId reserved for future per-model guidance differentiation
  modelId?: string;
}): { sectionOverrides: Record<string, string> } | undefined {
```

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

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-specific prompt overlay that injects Hermes-parity execution directives into OpenClaw’s system prompt via a new overridable section (tool_enforcement), and wires that contribution into the Google providers.

Changes:

  • Introduces tool_enforcement as a provider-overridable system-prompt section and renders it in buildAgentSystemPrompt.
  • Adds a new Google prompt overlay (GOOGLE_GEMINI_EXECUTION_GUIDANCE) and exposes it via resolveGoogleSystemPromptContribution.
  • Wires resolveSystemPromptContribution into both google and google-gemini-cli providers.

Reviewed changes

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

Show a summary per file
File Description
extensions/google/prompt-overlay.ts New overlay module providing Gemini operational directives via sectionOverrides.tool_enforcement.
extensions/google/provider-registration.ts Registers Google provider with resolveSystemPromptContribution hook.
extensions/google/gemini-cli-provider.ts Registers Gemini CLI provider with the same system-prompt contribution hook.
src/agents/system-prompt-contribution.ts Extends overridable section id union with tool_enforcement.
src/agents/system-prompt.ts Renders the new tool_enforcement overridable section into the assembled system prompt.

Comment on lines +35 to +46
export function resolveGoogleSystemPromptContribution(params: {
modelProviderId?: string;
modelId?: string;
}): { sectionOverrides: Record<string, string> } | undefined {
if (!shouldApplyGooglePromptOverlay({ modelProviderId: params.modelProviderId })) {
return undefined;
}
return {
sectionOverrides: {
tool_enforcement: GOOGLE_GEMINI_EXECUTION_GUIDANCE,
},
};

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

resolveGoogleSystemPromptContribution returns sectionOverrides: Record<string, string>, which removes compile-time validation of section ids. Tighten this type (e.g., return { sectionOverrides: { tool_enforcement: string } } or a Partial<Record<...>>) so typos in section names don’t silently disable the overlay.

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +19
export const GOOGLE_GEMINI_EXECUTION_GUIDANCE = `# Google model operational directives
Follow these operational rules strictly:
- **Verify first:** Use read or exec to check file contents and project structure before making changes. Never guess at file contents.
- **Dependency checks:** Never assume a library is available. Check package.json, requirements.txt, Cargo.toml, etc. before importing.
- **Conciseness:** Keep explanatory text brief — a few sentences, not paragraphs. Focus on actions and results over narration.

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

The overlay text starts with a level-1 markdown header (# ...). In the system prompt, level-1 headers are already used for special top-level sections like # Project Context; using another # here can make the prompt structure harder to scan and may collide with any logic that treats # ... as a top-level delimiter. Consider switching this to a ## ... heading (or otherwise matching the surrounding ## section style) while keeping the Hermes body text unchanged.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +58
resolveSystemPromptContribution: (ctx) =>
resolveGoogleSystemPromptContribution({
modelProviderId: "google",
modelId: ctx.modelId,
}),

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

resolveSystemPromptContribution is now wired for the Google providers, but there’s no test asserting the new behavior (unlike the OpenAI prompt overlay which has dedicated tests). Please add a focused extension test that registers the Google providers and verifies resolveSystemPromptContribution returns a tool_enforcement override containing the Gemini directives for both google and google-gemini-cli (and not for unrelated providers).

Copilot uses AI. Check for mistakes.
Comment on lines +699 to +702
...buildOverridablePromptSection({
override: providerSectionOverrides.tool_enforcement,
fallback: [],
}),

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

New tool_enforcement section override is now assembled into the system prompt, but there’s no accompanying test to ensure this override is rendered (and placed) correctly. Please add/extend a unit test that provides promptContribution.sectionOverrides.tool_enforcement and asserts the resulting prompt includes that block (and that fallback behavior remains unchanged when it’s absent).

Copilot uses AI. Check for mistakes.

@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: 847a54e9e3

ℹ️ 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 on lines +39 to +40
if (!shouldApplyGooglePromptOverlay({ modelProviderId: params.modelProviderId })) {
return undefined;

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.

P2 Badge Restrict Google prompt overlay to Gemini models

resolveGoogleSystemPromptContribution only checks provider id, so it injects Gemini-specific directives for every model routed through the Google plugin, including hook-alias traffic like google-antigravity that can target non-Gemini ids (for example Claude-family ids used elsewhere in the repo). This means non-Gemini runs receive mismatched operational instructions and can regress response quality; the contribution should also gate on modelId (or another model-family check) before applying the Gemini overlay.

Useful? React with 👍 / 👎.

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

Labels

agents Agent runtime and tooling r: too-many-prs Auto-close: author has more than twenty active PRs. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants