Skip to content

fix(google): rename Python-keyword tool parameter names for Gemini function calling - #143178

Closed
HighervGround wants to merge 20 commits into
openclaw:mainfrom
HighervGround:fix/google-vertex-python-keyword-tool-args
Closed

HighervGround wants to merge 20 commits into
openclaw:mainfrom
HighervGround:fix/google-vertex-python-keyword-tool-args

Conversation

@HighervGround

Copy link
Copy Markdown
Contributor

Closes #143176

What Problem This Solves

Fixes an issue where users running gemini-2.5-flash on Vertex AI with the coding (or full) tool profile would experience total tool-calling failure — MALFORMED_FUNCTION_CALL: print(default_api.<tool>(...)) — whenever the built-in automations or memory_get tool was present in the declared tool list, even when calling a completely unrelated tool like read.

Why This Change Was Made

Gemini's function-calling implementation appears to render tool signatures internally as Python def name(param, ...) declarations. automations has an in parameter (for its next_check action) and memory_get has a from parameter — both Python hard keywords, both invalid as Python parameter names. When either is present anywhere in the declared tool list, the model abandons structured function calling for the entire turn rather than just failing on that one tool.

The fix reversibly renames any JSON Schema property (and matching required entry) named after a Python hard keyword to name__oc_kw before the tool declarations reach Gemini, and renames it back the moment a function-call response comes in — scoped to extensions/google/transport-stream.ts's shared convertGoogleTools (outgoing) and function-call-parsing (incoming) code, so it covers both google-generative-ai and google-vertex. The actual tool implementation never sees the rename in either direction. Non-goal: this doesn't touch Python soft keywords (e.g. match), since those are valid Python parameter names and weren't part of the confirmed failure mode.

User Impact

Tool calls to read, write, web_search, or any other tool now succeed normally even when automations or memory_get are also in the declared tool set. Previously this combination made tool-calling fail unconditionally on affected models/transports.

Evidence

Bisected a live captured Vertex AI request (system instruction, thinkingConfig, and all 35 function declarations from the coding tool profile, replayed via direct generateContent calls) down to a single in property on automations:

Request variant finishReason
Full captured request, unmodified MALFORMED_FUNCTION_CALL
Remove thinkingConfig MALFORMED_FUNCTION_CALL
Remove systemInstruction MALFORMED_FUNCTION_CALL
Only the read tool declared (drop other 34) STOP (correct functionCall)
All 35 tools, automations.in renamed to in_ STOP (correct functionCall)
All 35 tools, automations.in removed STOP (correct functionCall)

Verified the shipped fix end-to-end against the real Vertex API through the actual CLI (openclaw agent exec, fresh state dir each run):

  • Before: read tool call on a fresh session reliably failed with MALFORMED_FUNCTION_CALL: print(default_api.read(path='...')) when automations/memory_get were in the tool list.
  • After: read succeeds with a correctly structured call; automations itself, called with action=next_check, in="30m", reaches the tool implementation as {"action":"next_check","in":"30m"} (confirming the reverse-mapping restores the original key), and fails only on its own legitimate business-logic check (next_check is only available to the currently running job) rather than a malformed call.

Added two unit tests to extensions/google/transport-stream.test.ts covering the outgoing rename (renames Python-keyword tool parameter names before sending to Gemini, plus a leaves non-keyword tool parameter names untouched control) and the incoming reverse-mapping (restores the original property name when the model echoes back a renamed Python-keyword argument), following the file's existing buildGoogleGenerativeAiParams/buildSseResponse+runGeminiStreamResult test patterns.

I wasn't able to run the full pnpm build && pnpm check && pnpm test locally (sandboxed environment without pnpm/corepack and outside the repo's supported Node engine range) — relying on CI for the full suite, plus the live-API bisection and end-to-end CLI verification above for functional confidence.

  • Confirm you understand what the code does — I bisected the root cause empirically against the live Vertex API before writing the fix, and it maps directly onto the change (Python-keyword rename/unrename at the schema boundary).

roboclaw-bot and others added 20 commits August 30, 2026 07:04
Record the 31 channel schema entries introduced by the existing Buzz multiaccount support in c3ff7f9. Core and plugin config surfaces remain unchanged.
Regenerate the documentation baseline for the requested latest-main cut. Main PR openclaw#118674 accepts already-declared model compatibility fields, adding 44 core schema paths; the generated core count is now 2407. Channel and plugin counts stay unchanged. This commit adds no runtime or schema behavior.
Revalidate the admitted reply lifecycle and durable restart handoff at the session write boundary. A recovered execution may reuse the original run ID, so queued cleanup must not retire its successor delivery route.
Carry the claimed writer into final persistence even when a native harness supplies no context subscription events. Distinguish absent telemetry from explicitly unknown context, preserve stale usage honestly, and verify cancellation and fallback accounting.
Retain one admission across fallback candidates, seed canonical durable session records, and return the actual session identity from mocked attempts. Drain preparation failures before restoring shared filesystem spies.
Restore stable envelope, provider-catalog, and thinking-catalog SDK names while preserving canonical internal owners. Cover old consumer callbacks and errors, and document retained helper contracts.

Remove an unverified unshipped realtime catalog alias and align fixtures and examples with the retained stable default.
…nction calling

Gemini's function calling appears to render tool signatures internally as
Python `def name(param, ...)` declarations. A JSON Schema property named
after a Python hard keyword (e.g. "in", "from") produces an invalid
signature, and the model abandons structured function calling for the
entire turn, emitting a malformed print(default_api.tool(...)) text call
instead of a real functionCall part - for every tool in the request, not
only the one with the offending property.

Confirmed by bisecting a live Vertex AI gemini-2.5-flash request (35
declared tools, drawn from OpenClaw's own "coding" tool profile) down to a
single "in" property on the built-in `automations` tool; removing or
renaming just that property fixed the entire turn. The built-in
`memory_get` tool has the same issue with a "from" property.

Reversibly rename any Python hard-keyword property name (properties + the
required array) to `name__oc_kw` before the schema reaches Gemini, and
rename it back when the model's function-call arguments come back, so the
actual tool implementation never sees the rename. Scoped to Google's
shared convertGoogleTools/functionCall parsing, so it covers both
google-generative-ai and google-vertex.
@HighervGround
HighervGround requested review from a team as code owners September 9, 2026 14:30
Copilot AI lite review requested due to automatic review settings September 9, 2026 14:30
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts labels Sep 9, 2026

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.

🟡 Changes recommended

There are correctness issues in the new Gemini arg “unsanitization” logic and an Android approval SHA source mismatch risk that should be resolved before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR primarily addresses a Gemini/Vertex AI tool-calling failure mode by sanitizing Python-hard-keyword JSON Schema parameter names at the Google transport boundary, and then restoring original names in returned function-call arguments. It also includes several additional updates across release tooling/workflows, Plugin SDK compatibility surfaces, and session/compaction accounting.

Changes:

  • Add reversible Python-hard-keyword parameter renaming (in → in__oc_kw, etc.) for Gemini tool declarations and reverse-map incoming function-call args.
  • Update release tooling to a v2 Android approval/identity contract and adjust release publish behavior so Android publication is dispatched without blocking core publication.
  • Refactor/extend various runtime and SDK compatibility seams (skills watcher path resolution on Windows, SDK export aliases, compaction accounting snapshot shape, and related tests/docs).
File summaries
File Description
ui/src/pages/config/talk.test.ts Updates OpenAI GPT-Live model fixtures to prefer gpt-live-1-codex.
test/scripts/validate-release-publish-approval.test.ts Adds workflow-parsing and extensive Android approval/identity tests (platform-gated).
test/scripts/test-projects.test.ts Includes the new release-approval test in changed-target routing.
test/scripts/package-source-preflight.test.ts Adds a regression test for oversized contribution records passing through packaging.
test/scripts/package-changelog.test.ts Extends changelog packaging tests for compaction/linking and restore behavior.
test/scripts/package-acceptance-workflow.test.ts Validates publish workflow no longer blocks core publication on Android completion.
test/scripts/ocm-npm-workspace-deps.test.ts Ensures workspace dependency adapter includes new release-notes compaction helper.
test/e2e/qa-lab/runtime/package-openclaw-for-docker.e2e.test.ts Includes new compaction helper in Docker packaging file allowlist.
src/skills/runtime/refresh.ts Uses a resolved watch path to improve watcher correctness (notably on Windows).
src/skills/runtime/refresh.test.ts Adds Windows short-path expansion coverage while preserving existing watch-root behavior.
src/skills/runtime/refresh-watch-path.ts New helper to expand Windows 8.3 segments without following symlinks.
src/plugin-sdk/provider-catalog-runtime.ts Renames SDK export to resolvePluginProviders via alias for compatibility.
src/plugin-sdk/provider-catalog-runtime.test.ts Adds a regression test for the shipped SDK provider-resolution export.
src/plugin-sdk/agent-runtime.ts Restores/bridges a previously shipped callback parameter name at the SDK boundary.
src/plugin-sdk/agent-runtime-model-catalog-contract.test.ts Tests the retained SDK callback contract and error propagation.
src/gateway/worker-environments/node-launch-adapter.ts Adjusts deadline composition/precedence and uses throwIfAborted for cancellations.
src/gateway/worker-environments/node-launch-adapter.test.ts Expands coverage for deadline identity across timer/clock/caller-cancel scenarios.
src/channels/inbound-event/envelope.ts Renames callback parameter to resolveStorePath across inbound-envelope builders.
src/channels/inbound-event/envelope.test.ts Verifies SDK callback naming is preserved through direct/routed/runtime helpers.
src/auto-reply/reply/restart-recovery-claim.ts Tightens restart-recovery cleanup ownership checks using lifecycle generation.
src/auto-reply/reply/restart-recovery-claim.test.ts Adds queued-cleanup interruption cases and user-abort retirement coverage.
src/auto-reply/reply/get-reply-native-slash-fast-path.ts Switches to the core thinking-default resolver export.
src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts Updates compaction accounting payload shape to currentContextSnapshot.
src/auto-reply/reply/agent-runner-result-accounting.ts Reads context tokens via currentContextSnapshot when persisting compaction counts.
src/auto-reply/reply/agent-runner-result-accounting.persistence.test.ts Updates persistence test fixtures for the new snapshot shape.
src/auto-reply/reply/agent-runner-memory.ts Updates compaction accounting plumbing to use currentContextSnapshot.
src/auto-reply/reply/agent-runner-memory.test.ts Extends tests for fallback flows with/without observed context snapshots.
src/auto-reply/reply/agent-runner-execution-lifecycle.test.ts Updates compaction-fact aggregation tests for the new snapshot semantics.
src/auto-reply/reply/agent-runner-execute.ts Passes lifecycle generation into restart-recovery claim controller.
src/auto-reply/reply/agent-runner-compaction-accounting.ts Ensures invalidation/aggregation preserves snapshot intent across facts.
src/agents/tools/session-status-tool.ts Switches to the core thinking-default resolver export.
src/agents/tools/image-tool.providers.live.test.ts Avoids plugin discovery cold-start in live probe to stay within test budgets.
src/agents/subagents/announce/subagent-announce-direct-delivery.ts Tweaks visible-final delivery detection for session-only requesters.
src/agents/subagents/announce/subagent-announce-delivery.test.ts Adds coverage for yielded requesters and external vs local delivery differences.
src/agents/model-thinking-default.ts Renames the runtime-catalog thinking resolver to a *Core export.
src/agents/model-selection.ts Re-exports the renamed resolveThinkingDefaultWithRuntimeCatalogCore.
src/agents/model-fallback.run-embedded.e2e.test.ts Updates admission harness wiring and defers routing-fixture imports.
src/agents/embedded-agent-runner/run/run-settlement.ts Refactors compaction fact creation to better represent “writer-only” snapshots.
src/agents/embedded-agent-runner/run/internal-params.ts Changes compaction fact shape to currentContextSnapshot.
src/agents/embedded-agent-runner/run.recovery-cancellation.test-support.ts Extends ordering cases and covers “opaque native” usage-without-subscription.
src/agents/embedded-agent-runner.run-embedded-agent.fault-sequences.e2e.test.ts Reworks scenario setup to use prepared admissions and closes leases reliably.
src/agents/embedded-agent-runner.run-embedded-agent.auth-profile-rotation.e2e.test.ts Updates E2E wrapper to the prepared-admission harness.
src/agents/command/session-store.ts Adjusts total-token persistence logic to use snapshot (when present) and mark staleness otherwise.
src/agents/command/session-store.test.ts Updates tests for new snapshot behavior and staleness semantics (including zero).
src/agents/command/compaction-accounting.ts Preserves snapshot semantics across candidates and persists tokens via snapshot.
src/agents/agent-command.embedded-maintenance.test.ts Updates retry-context tests for snapshot-observed vs usage-derived totals.
src/agents/agent-command.compaction-rotation.test.ts Updates helpers/fixtures for the currentContextSnapshot shape.
src/agents/admitted-run-context.test-support.ts Updates prepared-admission wrapper to import the real boundary and close it.
scripts/validate-release-publish-approval.mjs Adds v2 Android receipt validation and live tooling identity / parent-run checks.
scripts/render-github-release-notes.mts Moves compaction/linking logic into a shared helper module.
scripts/package-changelog.mjs Adds compaction path for oversized contribution records while preserving editorial notes.
scripts/lib/release-notes-compaction.mjs New shared helper for “complete contribution record” compaction and link rendering.
scripts/control-ui-mock-dev.ts Removes deprecated GPT-Live model option from Control UI mock scenario.
extensions/telegram/src/bot-native-command-builtins.ts Updates call site to use retained SDK callback name (loadModelCatalog).
extensions/openai/realtime-quicksilver.ts Curates GPT-Live model list down to gpt-live-1-codex.
extensions/openai/realtime-quicksilver.test.ts Updates supported-model detection test cases accordingly.
extensions/openai/realtime-quicksilver-gateway-bridge.live.test.ts Updates live bridge test to use gpt-live-1-codex.
extensions/google/transport-stream.ts Adds schema-key sanitization for Gemini tool declarations and reverse-mapping of args.
extensions/google/transport-stream.test.ts Adds unit tests for outgoing rename, non-rename control, and incoming restore.
docs/reference/RELEASING.md Updates release process docs for changelog compaction and non-blocking Android publication.
docs/providers/openai.md Removes docs references to deprecated GPT-Live model option.
docs/plugins/sdk-migration.md Documents retained helper contracts/names at the SDK boundary.
docs/nodes/talk.md Updates Talk docs to only recommend gpt-live-1-codex.
docs/.generated/config-baseline.sha256 Updates generated baseline hashes after config/doc changes.
docs/.generated/config-baseline.counts.json Updates generated baseline counts after config/doc changes.
.github/workflows/openclaw-release-publish.yml Adds v2 Android approval fields; dispatches Android without awaiting completion; updates summaries.
.github/workflows/android-release.yml Updates Android workflow inputs/verification to v2 approval + tooling identity checks.
Review details
  • Files reviewed: 67/68 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 1189 to +1192
RELEASE_PUBLISH_BRANCH: ${{ github.ref_name }}
RELEASE_PUBLISH_FULL_REF: ${{ github.ref }}
RELEASE_PUBLISH_WORKFLOW_SHA: ${{ github.workflow_sha }}
RELEASE_PUBLISH_RUN_ATTEMPT: ${{ github.run_attempt }}
Comment on lines +848 to +854
for (const [key, value] of Object.entries(args as Record<string, unknown>)) {
const restoredKey = key.endsWith(PYTHON_KEYWORD_RENAME_SUFFIX)
? key.slice(0, -PYTHON_KEYWORD_RENAME_SUFFIX.length)
: key;
result[restoredKey] = unsanitizeGooglePythonKeywordArgs(value);
}
return result;
Comment on lines +109 to +111
RELEASE_TAG: "v2026.8.1",
RELEASE_TARGET_SHA: "a".repeat(40),
TARGET_SHA: "a".repeat(40),
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 4, 2026, 8:35 AM ET / 12:35 UTC (Revision 5).

ClawSweeper review

What this changes

The branch renames Python-keyword tool parameters for Gemini, restores returned argument names, adds regression tests, and includes earlier release, SDK, and session-accounting changes.

Merge readiness

⛔ Blocked before merge - 6 items remain

This PR still addresses an unfixed Gemini tool-calling problem and has useful live Vertex evidence. Both previously reported correctness findings remain unresolved at the unchanged head; neither related merged PR implements the keyword mapping.

Priority: P1
Reviewed head: 9d9a8b293a7429fd24fd8a93277586dfbb401ab8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful live evidence supports the repair, but two deterministic mapping defects limit implementation confidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured contributor evidence exercises the changed Google transport through real Vertex requests and openclaw agent exec, showing successful read calls and restored automations arguments after the fix. This proves the reported scenario, while collision and replay correctness remain separately blocked; no stored-data format change is introduced by the keyword mapping.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured contributor evidence exercises the changed Google transport through real Vertex requests and openclaw agent exec, showing successful read calls and restored automations arguments after the fix. This proves the reported scenario, while collision and replay correctness remain separately blocked; no stored-data format change is introduced by the keyword mapping.
Evidence reviewed 13 items Pinned introduced mapping: The introduced decoder strips the suffix from every object key recursively without consulting the declared tool or schema. The encoder maps both in and an existing in__oc_kw property to the same destination.
Replay mismatch: The request builder combines renamed declarations with conversation projection that still sends block.arguments unchanged. Response decoding therefore changes the keys subsequently replayed to Gemini.
Focused tests and coverage gap: The three added cases cover basic outbound renaming, an ordinary unchanged parameter, and mocked inbound restoration. Existing replay tests preserve function-call arguments and thought signatures, but the added cases do not cover collisions, untouched nested data, or a subsequent request containing a decoded keyword call.
Findings 2 actionable findings [P2] Make keyword encoding and decoding collision-safe and schema-aware
[P2] Apply the same wire mapping when replaying tool calls
Security None None.

How this fits together

The Google provider converts OpenClaw tool schemas and conversation history into Gemini requests, then converts returned function calls into executable tool arguments. Those calls also return to Gemini as history on subsequent turns.

flowchart LR
  A[Tool schemas] --> C[Google request conversion]
  B[Conversation history] --> C
  C --> D[Gemini API]
  D --> E[Function call decoding]
  E --> F[Tool execution]
  E --> B
Loading

Before merge

  • Make keyword encoding and decoding collision-safe and schema-aware (P2) - The prior finding remains unresolved. A declared query__oc_kw is unchanged outbound but becomes query inbound, and this recursion also rewrites arbitrary nested data. Declaring both in and in__oc_kw overwrites one schema during encoding. Checking only whether the prefix is a keyword still corrupts a legitimate in__oc_kw. Use an unambiguous mapping tied to the declared tool and schema location, preserving untouched object data.
  • Apply the same wire mapping when replaying tool calls (P2) - The prior finding remains unresolved. Declarations advertise in__oc_kw, and response decoding stores in, but convertGoogleMessages still replays those stored arguments unchanged at line 689. The next request therefore contains historical calls using names absent from its declarations and different from the original returned call. Apply the same schema-scoped mapping during replay and preserve thought signatures, with a response-to-next-request regression.
  • Resolve merge risk (P1) - Resolve the conflicts and review the resulting aggregate diff against current main, especially any retained release-approval, SDK, or session-accounting changes; no verified merge result establishes their final scope.
  • Resolve merge risk (P1) - Replace the added transport-local schema and argument walkers with a mapping integrated into the existing shared Google owners, removing redundant traversal before accepting the focused fix's +102 production lines.
  • Complete next step (P2) - Resolve the conflicts against current main, repair both mapping findings in the shared Google protocol flow, and review the resulting aggregate diff.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P2] Make keyword encoding and decoding collision-safe and schema-aware — extensions/google/transport-stream.ts:848-852
  • [P2] Apply the same wire mapping when replaying tool calls — extensions/google/transport-stream.ts:866
Agent review details

Security

None.

PR surface

Source +181, Tests +1073, Docs +102, Config 0, Generated 0, Other +62. Total +1418 across 68 files.

View PR surface stats
Area Files Added Removed Net
Source 23 277 96 +181
Tests 31 1478 405 +1073
Docs 5 17484 17382 +102
Config 2 46 46 0
Generated 2 5 5 0
Other 5 131 69 +62
Total 68 19421 18003 +1418

Review metrics

Metric Value Why it matters
Production versus test growth Pinned delta: production/tooling +243 net; tests/support +1073 net; focused Google change +102 production, +117 tests Docs, generated baselines, and workflow YAML are separate; the focused fix adds two walkers that should be absorbed into the shared protocol flow.

Stored data model

Persistent data-model change detected: unknown-data-model-change: scripts/package-changelog.mjs, unknown-data-model-change: scripts/render-github-release-notes.mts, unknown-data-model-change: scripts/validate-release-publish-approval.mjs. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #143176
Summary: This PR is the explicit candidate fix for the same author's open Vertex keyword-parameter report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair the shared Google conversion (recommended)
    Integrate a per-tool, schema-scoped reversible mapping into current main and cover collisions, untouched object data, and subsequent-turn replay before merge.
  2. Pause the current branch
    Keep the paired bug open while the contributor resolves the conflicting branch and presents a focused, reviewable Google repair.

Technical review

Best possible solution:

Reuse existing schema traversal and the shared Google projector/reducer for one collision-safe, schema-scoped mapping across declarations, returned calls, and replay, preserving internal names and untouched data.

Do we have a high-confidence way to reproduce the issue?

Yes for the patch defects: source deterministically shows suffix-key corruption, schema collisions, and mismatched replay names. The original Vertex failure has contributor live evidence, but was not independently rerun on current main.

Is this the best way to solve the issue?

No, the current patch is incomplete. A provider-boundary mapping is appropriate, but it must be collision-safe, schema-aware, replay-consistent, and integrated into current main's shared Google owners; renaming public tool parameters would unnecessarily affect other providers.

Full review comments:

  • [P2] Make keyword encoding and decoding collision-safe and schema-aware — extensions/google/transport-stream.ts:848-852
    The prior finding remains unresolved. A declared query__oc_kw is unchanged outbound but becomes query inbound, and this recursion also rewrites arbitrary nested data. Declaring both in and in__oc_kw overwrites one schema during encoding. Checking only whether the prefix is a keyword still corrupts a legitimate in__oc_kw. Use an unambiguous mapping tied to the declared tool and schema location, preserving untouched object data.
    Confidence: 0.99
  • [P2] Apply the same wire mapping when replaying tool calls — extensions/google/transport-stream.ts:866
    The prior finding remains unresolved. Declarations advertise in__oc_kw, and response decoding stores in, but convertGoogleMessages still replays those stored arguments unchanged at line 689. The next request therefore contains historical calls using names absent from its declarations and different from the original returned call. Apply the same schema-scoped mapping during replay and preserve thought signatures, with a response-to-next-request regression.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e4f89eb03acc.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported Vertex model/profile combination blocks otherwise unrelated agent tool calls.
  • merge-risk: 🚨 compatibility: The introduced mapping can overwrite declared properties and silently change legitimate tool arguments, while replay uses inconsistent parameter names.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The captured contributor evidence exercises the changed Google transport through real Vertex requests and openclaw agent exec, showing successful read calls and restored automations arguments after the fix. This proves the reported scenario, while collision and replay correctness remain separately blocked; no stored-data format change is introduced by the keyword mapping.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured contributor evidence exercises the changed Google transport through real Vertex requests and openclaw agent exec, showing successful read calls and restored automations arguments after the fix. This proves the reported scenario, while collision and replay correctness remain separately blocked; no stored-data format change is introduced by the keyword mapping.

Evidence

What I checked:

  • Pinned introduced mapping: The introduced decoder strips the suffix from every object key recursively without consulting the declared tool or schema. The encoder maps both in and an existing in__oc_kw property to the same destination. (extensions/google/transport-stream.ts:849, 9d9a8b293a74)
  • Replay mismatch: The request builder combines renamed declarations with conversation projection that still sends block.arguments unchanged. Response decoding therefore changes the keys subsequently replayed to Gemini. (extensions/google/transport-stream.ts:689, 9d9a8b293a74)
  • Focused tests and coverage gap: The three added cases cover basic outbound renaming, an ordinary unchanged parameter, and mocked inbound restoration. Existing replay tests preserve function-call arguments and thought signatures, but the added cases do not cover collisions, untouched nested data, or a subsequent request containing a decoded keyword call. (extensions/google/transport-stream.test.ts:3255, 9d9a8b293a74)
  • Current main remains unfixed: Current main's shared Google conversion still assigns tool.parameters directly to parametersJsonSchema. Its shared stream reducer returns functionCall.args unchanged; there is no corresponding keyword codec in these owners. (packages/ai/src/providers/google-messages.ts:288, e4f89eb03acc)
  • Shared caller and response owner: Managed transport and direct SDK requests now share the Google message projector, tool converter, and stream reducer. The focused repair belongs in that shared flow rather than restoring the older transport-local implementation. (packages/ai/src/providers/google-shared.ts:111, e4f89eb03acc)
  • Latest release check: The v2026.9.8 source also passes parameter schemas through unchanged. This release does not provide the requested keyword mapping. (packages/ai/src/providers/google-messages.ts:298, fc23bc864e45)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Make encoding and decoding collision-safe and schema-aware, with declared-tool round-trip coverage.
  • Cover subsequent-turn replay using consistent wire names and preserved thought signatures.
  • Integrate the focused repair with current main's shared Google protocol owner and review the resolved aggregate diff.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-09T15:19:15.708Z sha 9d9a8b2 :: blocked before merge. :: [P2] Make the keyword mapping collision-safe and schema-aware | [P2] Apply the wire mapping when replaying previous tool calls
  • reviewed 2026-09-09T16:32:30.479Z sha 9d9a8b2 :: blocked before merge. :: [P2] Make the keyword mapping collision-safe and schema-aware | [P2] Apply the wire mapping when replaying previous tool calls
  • reviewed 2026-09-09T17:28:36.030Z sha 9d9a8b2 :: blocked before merge. :: [P2] Make the keyword mapping collision-safe and schema-aware | [P2] Apply the wire mapping when replaying previous tool calls
  • reviewed 2026-09-23T10:55:11.435Z sha 9d9a8b2 :: blocked before merge. :: [P2] Make keyword encoding and decoding collision-safe and schema-aware | [P2] Apply the same wire mapping when replaying tool calls

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 9, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 9, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Sep 9, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 9, 2026
roboclaw-bot added a commit that referenced this pull request Nov 3, 2026
Supersedes #143178, thanks @HighervGround.

Related: #143176

## What Problem This Solves

Fixes Gemini tool calling when a declared parameter is a Python keyword such as `from`, `class`, or `lambda`.

## User Impact

Google and Vertex tools retain their original parameter names at execution. Existing suffix names and nested user data remain intact. This replacement includes only the Google parameter repair.

## Why This Change Was Made

A shared Google converter chooses unused underscore aliases for declared top-level keyword parameters, restores returned arguments, and reapplies the aliases during signed history replay. GenerateContent, Vertex, Interactions, and explicit prompt caches use the same mapping. Cached requests retain canonical schemas for decoding while omitting cached declarations from the outgoing request.

The duplicate prompt-cache declaration builder is removed. Necessary production growth implements collision-safe schema-based mapping across the existing transports; there is no new cache, setting, persistence format, or dependency.

## Evidence

- Current-main source check: `65a125adc598deff3ded853f155acfa616d39c0c` passes tool properties and returned arguments unchanged. The contributor's captured Vertex bisection reports `MALFORMED_FUNCTION_CALL` with `automations.in`, and a valid call after renaming that property. [Google's function-calling documentation](https://ai.google.dev/gemini-api/docs/function-calling) describes JSON Schema parameters but does not document a Python-keyword restriction. No live Gemini API calls were made.
- Red before: on the unchanged main implementation, `packages/ai/src/providers/google-shared.test.ts` had exactly the two new failures (outgoing schema and inbound restoration), with 32 existing tests passing. [Crabbox run](https://github.com/openclaw/openclaw/actions/runs/41551852373).
- Green after: 211 tests pass across the four changed behavioral suites (SDK/Interactions, prompt cache, managed Google/Vertex); the 14 prompt-prefix cases and the 28 message-conversion/lifecycle/request-config cases also pass. Touched-file type-aware lint (0 warnings/errors), format, and `git diff --check` pass. [Crabbox proof](https://github.com/openclaw/openclaw/actions/runs/41552191472). Final named-test invocation took 45.49 s plus setup; the managed transport file took 10.84 s wall time, with the cache suite dominated by existing compiled-worker setup. Exact-head [CI run 41555285820](https://github.com/openclaw/openclaw/actions/runs/41555285820) passed: 45 successful jobs, 28 skipped, 11 min 51 s wall time and 7,810 summed job-seconds.
- CI repair proof: [the first CI run](https://github.com/openclaw/openclaw/actions/runs/41553763628) found an extension test importing a core helper and a declaration-only assertion helper accepting the SDK’s broader tool-list type. Both test-only defects are fixed; production code is unchanged. The boundary guard, managed Google/Vertex transport, and SDK regression file now pass all 167 cases in 57.71 s, with touched-file lint/format green. [Crabbox repair proof](https://github.com/openclaw/openclaw/actions/runs/41554614333).
- Review: Local autoreview of the complete implementation diff against `65a125adc598deff3ded853f155acfa616d39c0c`, P0–P2, returned `scoped-clean`; no findings. A supplemental P0–P2 review of the CI fixture repairs against `6fe9bc666896375a6ae42fa5e2f925acbaae10f9` also returned `scoped-clean`. Simplification retained one schema/argument mapping owner and removed the duplicate cached declaration projection.
- LOC: production +116/−19 (net +97), tests/support +342/−11 (net +331). The dedicated test-line allocation covers only these regressions: schema projection, execution, signed replay, managed/Vertex transport, Interactions argument deltas, and cached declarations.
- The contributor branch was read through `gh` and was never checked out or run. Validation ran on our reimplementation in Blacksmith Testbox through Crabbox. Broad proof is PR CI.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: HighervGround <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @HighervGround for the report and the Vertex bisection. The focused fix is now merged in #191561, including collision-safe parameter aliases, argument restoration, and history replay. Closing this PR in favor of that credited replacement.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…law#191561)

Supersedes openclaw#143178, thanks @HighervGround.

Related: openclaw#143176

## What Problem This Solves

Fixes Gemini tool calling when a declared parameter is a Python keyword such as `from`, `class`, or `lambda`.

## User Impact

Google and Vertex tools retain their original parameter names at execution. Existing suffix names and nested user data remain intact. This replacement includes only the Google parameter repair.

## Why This Change Was Made

A shared Google converter chooses unused underscore aliases for declared top-level keyword parameters, restores returned arguments, and reapplies the aliases during signed history replay. GenerateContent, Vertex, Interactions, and explicit prompt caches use the same mapping. Cached requests retain canonical schemas for decoding while omitting cached declarations from the outgoing request.

The duplicate prompt-cache declaration builder is removed. Necessary production growth implements collision-safe schema-based mapping across the existing transports; there is no new cache, setting, persistence format, or dependency.

## Evidence

- Current-main source check: `0aaff8f10c2ca6c998b75db5c1c820bf4a83971d` passes tool properties and returned arguments unchanged. The contributor's captured Vertex bisection reports `MALFORMED_FUNCTION_CALL` with `automations.in`, and a valid call after renaming that property. [Google's function-calling documentation](https://ai.google.dev/gemini-api/docs/function-calling) describes JSON Schema parameters but does not document a Python-keyword restriction. No live Gemini API calls were made.
- Red before: on the unchanged main implementation, `packages/ai/src/providers/google-shared.test.ts` had exactly the two new failures (outgoing schema and inbound restoration), with 32 existing tests passing. [Crabbox run](https://github.com/openclaw/openclaw/actions/runs/41551852373).
- Green after: 211 tests pass across the four changed behavioral suites (SDK/Interactions, prompt cache, managed Google/Vertex); the 14 prompt-prefix cases and the 28 message-conversion/lifecycle/request-config cases also pass. Touched-file type-aware lint (0 warnings/errors), format, and `git diff --check` pass. [Crabbox proof](https://github.com/openclaw/openclaw/actions/runs/41552191472). Final named-test invocation took 45.49 s plus setup; the managed transport file took 10.84 s wall time, with the cache suite dominated by existing compiled-worker setup. Exact-head [CI run 41555285820](https://github.com/openclaw/openclaw/actions/runs/41555285820) passed: 45 successful jobs, 28 skipped, 11 min 51 s wall time and 7,810 summed job-seconds.
- CI repair proof: [the first CI run](https://github.com/openclaw/openclaw/actions/runs/41553763628) found an extension test importing a core helper and a declaration-only assertion helper accepting the SDK’s broader tool-list type. Both test-only defects are fixed; production code is unchanged. The boundary guard, managed Google/Vertex transport, and SDK regression file now pass all 167 cases in 57.71 s, with touched-file lint/format green. [Crabbox repair proof](https://github.com/openclaw/openclaw/actions/runs/41554614333).
- Review: Local autoreview of the complete implementation diff against `0aaff8f10c2ca6c998b75db5c1c820bf4a83971d`, P0–P2, returned `scoped-clean`; no findings. A supplemental P0–P2 review of the CI fixture repairs against `6fe9bc666896375a6ae42fa5e2f925acbaae10f9` also returned `scoped-clean`. Simplification retained one schema/argument mapping owner and removed the duplicate cached declaration projection.
- LOC: production +116/−19 (net +97), tests/support +342/−11 (net +331). The dedicated test-line allocation covers only these regressions: schema projection, execution, signed replay, managed/Vertex transport, Interactions argument deltas, and cached declarations.
- The contributor branch was read through `gh` and was never checked out or run. Validation ran on our reimplementation in Blacksmith Testbox through Crabbox. Broad proof is PR CI.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: HighervGround <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: telegram Channel integration: telegram docs Improvements or additions to documentation extensions: google extensions: openai gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Vertex AI gemini-2.5-flash tool-calling fails entirely when a declared tool has a Python-keyword parameter name

4 participants