feat(google): add Gemini execution guidance via prompt overlay [v3 final 2/3]#67513
feat(google): add Gemini execution guidance via prompt overlay [v3 final 2/3]#67513100yenadmin wants to merge 1 commit into
Conversation
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.
|
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 SummaryAdds a Confidence Score: 5/5Safe 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 AIThis 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"]); | |||
There was a problem hiding this 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.
| 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.| export function resolveGoogleSystemPromptContribution(params: { | ||
| modelProviderId?: string; | ||
| modelId?: string; | ||
| }): { sectionOverrides: Record<string, string> } | undefined { |
There was a problem hiding this comment.
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.
| 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.There was a problem hiding this comment.
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_enforcementas a provider-overridable system-prompt section and renders it inbuildAgentSystemPrompt. - Adds a new Google prompt overlay (
GOOGLE_GEMINI_EXECUTION_GUIDANCE) and exposes it viaresolveGoogleSystemPromptContribution. - Wires
resolveSystemPromptContributioninto bothgoogleandgoogle-gemini-cliproviders.
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. |
| 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, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
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.
| resolveSystemPromptContribution: (ctx) => | ||
| resolveGoogleSystemPromptContribution({ | ||
| modelProviderId: "google", | ||
| modelId: ctx.modelId, | ||
| }), |
There was a problem hiding this comment.
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).
| ...buildOverridablePromptSection({ | ||
| override: providerSectionOverrides.tool_enforcement, | ||
| fallback: [], | ||
| }), |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
💡 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".
| if (!shouldApplyGooglePromptOverlay({ modelProviderId: params.modelProviderId })) { | ||
| return undefined; |
There was a problem hiding this comment.
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 👍 / 👎.
GPT 5.4 Enhancement v3 — Final Sprint PR 2/3
Tracking: #66345
Supersedes: #66379
Rebased on current
main(incorporates356110c5provider-hooks refactor). Ports Hermes Agent's Google model operational directives.What this PR adds
Gemini operational directives (Hermes
prompt_builder.py:258-276)system-prompt.ts:600)Provider wiring
resolveSystemPromptContributionwired to bothgoogleandgoogle-gemini-cliproviderssectionOverrides.tool_enforcement(requirestool_enforcementsection ID from PR 1/3 or includes it independently)Files changed (5)
extensions/google/prompt-overlay.ts(new)extensions/google/provider-registration.tsextensions/google/gemini-cli-provider.tssrc/agents/system-prompt-contribution.tssrc/agents/system-prompt.tsParity constraint
Hermes-verbatim text with documented tool-ID substitutions only.