Skip to content

ADFA-5410 | Implement native tool calling for Gemini and OpenAI agents - #86

Open
jatezzz wants to merge 1 commit into
mainfrom
fix/ADFA-5410-gemini-native-tool-calls
Open

ADFA-5410 | Implement native tool calling for Gemini and OpenAI agents#86
jatezzz wants to merge 1 commit into
mainfrom
fix/ADFA-5410-gemini-native-tool-calls

Conversation

@jatezzz

@jatezzz jatezzz commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR migrates the Gemini and OpenAI agent backends to use their native function-calling APIs instead of relying on plain text tool call envelopes. This addresses the issue where LLMs produced malformed text payloads (such as unescaped quotes or newlines) which caused valid tool calls to be skipped or silently fail. By correctly declaring tool schemas and updating the system prompts to stop teaching the <tool_call> syntax when native calling is available, the agents can now execute actions reliably.

Details

  • Added ToolCallingBackend capabilities to both GeminiBackend and OpenAiBackend.
  • Introduced GeminiToolProtocol and OpenAiToolProtocol to manage provider-specific JSON schemas, declarations, and chunk parsing.
  • Updated ToolCallExtractor to diagnose and report malformed or truncated tool replies, preventing the agent loop from incorrectly reporting success.
  • Added ToolCodeParser to intercept and extract tool calls from Gemini's undocumented default_api.<tool>(...) fallback syntax.
  • Implemented ToolSchema to standardise and provide structured parameter schemas for all tool handlers (e.g., AddDependencyHandler, CreateFileHandler).
  • Added ProjectLayout context to the system prompt to explicitly inform the agent of the module structure, significantly reducing wasted list_files steps.

OpenAI

Screen_Recording_20260904_104112_Code.on.the.Go.mp4

Gemini API

Screen_Recording_20260904_105334_Code.on.the.Go.mp4

Ticket

ADFA-5410

Observation

The AgentLoop has also been updated to halt accurately when tool calls are unparsable or abandoned, providing specific diagnostic messages to the user rather than failing silently.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

Declare tools natively on both backends so calls arrive as structured data instead of unparseable prose, and read the dialects models still emit — Gemini's print(default_api.x()) and OpenAI's tool_calls deltas that carried no content — with a fallback to undeclared requests where a server refuses them. Report unreadable calls and abandoned runs honestly rather than COMPLETED, and name the source, layout and manifest paths up front.
@jatezzz
jatezzz force-pushed the fix/ADFA-5410-gemini-native-tool-calls branch from e10b9e2 to 6fa029a Compare September 4, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant