Skip to content

fix(session): normalize tool call blocks for cross-provider compatibility#5482

Closed
bse-ai wants to merge 1 commit intoopenclaw:mainfrom
bse-ai:fix/normalize-tool-call-blocks-v2
Closed

fix(session): normalize tool call blocks for cross-provider compatibility#5482
bse-ai wants to merge 1 commit intoopenclaw:mainfrom
bse-ai:fix/normalize-tool-call-blocks-v2

Conversation

@bse-ai
Copy link

@bse-ai bse-ai commented Jan 31, 2026

Summary

  • Fixes API validation failures when switching AI providers mid-session
  • Normalizes tool call block formats (toolUse, toolCall, functionCall) to canonical shape before sending to any provider
  • Prevents "input: Field required" errors when provider serializers encounter mismatched formats

Problem

When users switch providers mid-session (e.g., from Google Antigravity to Anthropic), the session history may contain tool call blocks in different formats:

  • Anthropic / pi-ai: { type: "toolCall", arguments: {} }
  • Google Antigravity: { type: "toolUse", input: {} }

This mismatch causes API validation failures.

Solution

Adds normalizeToolCallBlocks() to the session sanitization pipeline, converting all tool call variants to the canonical { type: "toolCall", arguments: {} } shape.

Test plan

  • Switch from Google Antigravity to Anthropic mid-session with tool calls in history
  • Verify no validation errors occur
  • Confirm tool call history is preserved and functional

🤖 Generated with Claude Code

Greptile Overview

Greptile Summary

This PR appears to normalize tool-call blocks in the Pi embedded runner's Google provider integration so that session history remains compatible when switching between AI providers mid-session. The change introduces (or wires in) a normalization step that converts provider-specific tool call variants (e.g., toolUse with input) into a canonical shape (toolCall with arguments) before sending history to downstream providers, preventing schema validation errors like input: Field required.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is scoped to session history normalization for tool call blocks and is intended to improve cross-provider compatibility without altering core control flow. No obvious security- or correctness-critical issues were identified from the provided context.
  • src/agents/pi-embedded-runner/google.ts

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

…lity

When users switch providers mid-session (e.g., from Google Antigravity to
Anthropic), the session history may contain tool call blocks in different
formats:

- Anthropic / pi-ai: `{ type: "toolCall", arguments: {} }`
- Google Antigravity: `{ type: "toolUse", input: {} }`

This mismatch causes API validation failures like "input: Field required"
when the new provider's serializer encounters the old format.

This fix adds `normalizeToolCallBlocks()` to the session sanitization
pipeline, which converts all tool call variants (toolCall, toolUse,
functionCall) to the canonical `{ type: "toolCall", arguments: {} }` shape
before sending to any provider.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Jan 31, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant