Skip to content

Enhancement: Native Function Calling Support for Agentic Coding Tools (Opencode, Kilo Code, Roo, Cline) #299

@MasuRii

Description

@MasuRii

Enhancement: Native Function Calling Support for Agentic Coding Tools (Opencode, Kilo Code, Roo, Cline)

Type: Enhancement
Branch: https://github.com/MasuRii/AIstudioProxyAPI-EN/tree/feature/native-function-calling
Latest Commit: b000cd86eacdb1c8ffa7e670ccd76632039952cf (Dec 24, 2025)

Description

This branch introduces native function/tool calling support in AIstudioProxyAPI by leveraging Google AI Studio's built-in native function calling UI and response format. This provides significantly higher reliability and full compatibility with the OpenAI tools/tool_calls specification compared to the previous emulation-based approach.

The implementation is now largely complete and has been successfully tested with agentic coding tools that rely on standard OpenAI function calling:

Given the architectural similarity between Kilo, Roo, and Cline, this branch should also support Roo and Cline out of the box, though explicit testing is still pending.

Key Improvements in This Branch

  • Dual-mode support (native first, fallback to legacy emulation on failure)
  • Robust schema conversion for Gemini-compatible FunctionDeclaration
  • Native response parsing for AI Studio's ms-function-call-chunk format
  • Automatic disabling of conflicting features (Google Search grounding, URL Context)
  • Performance optimizations (digest-based caching of tool configuration to reduce UI latency)
  • Improved wire-format argument parsing with dynamic nesting depth handling
  • Comprehensive unit tests and E2E verification script
  • Detailed documentation (ADR-001, sequence diagrams, research notes)

Current Status & Known Issues

  • Core native function calling works reliably in manual and Opencode/Kilo Code testing
  • Occasional instability observed in long-running agentic workflows (e.g., multi-turn tool calls with complex/nested arguments)
  • Some edge cases in argument parsing for deeply nested or array-heavy parameters may still trigger graceful degradation
  • Cache invalidation logic works but could be more aggressive in certain model-switching scenarios

Request for Collaboration

This fork (AIstudioProxyAPI-EN) is the primary English-localized version of the project, with ~80–90% of the codebase, comments, logs, and UI strings translated into English for broader accessibility.

Due to the extensive localization changes, direct pull requests to the upstream Chinese repository would introduce massive conflicts and break existing translations. For this reason, contributions are maintained separately in this English fork.

I’m opening this issue to share the feature/native-function-calling branch with the upstream maintainers and community, with the goal of collaborating to stabilize and merge native function calling as a core feature.

Specifically, I’d appreciate help with:

  • Testing against Roo and Cline to confirm compatibility
  • Identifying and fixing any remaining instability in multi-turn agentic loops
  • Reviewing schema conversion edge cases
  • Jointly deciding on default mode (native vs. emulated) and configuration options

Once stabilized, we can work together on a strategy to integrate this feature upstream while preserving both language versions.

Thank you for considering this enhancement — native tool calling unlocks much more reliable usage with modern agentic frameworks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions