Skip to content

[BUG] Function tool schemas not sent to LLM via OpenAI/Anthropic model adapters #1683

@renato0307

Description

@renato0307

📋 Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software
  • I can consistently reproduce this issue

🎯 Affected Service(s)

App Service

🚦 Impact/Severity

Blocker

🐛 Bug Description

When tools are registered using functiontool.New with typed Go structs (e.g., the remote A2A tool, ask_user, save_memory), the Google ADK sets FunctionDeclaration.ParametersJsonSchema to a *jsonschema.Schema value (from github.com/google/jsonschema-go). Both model adapters attempt to read this with a map[string]any type assertion that silently fails:

// openai_adk.go:342, anthropic_adk.go:239
if m, ok := fd.ParametersJsonSchema.(map[string]any); ok {

The actual type is *jsonschema.Schema, not map[string]any. The assertion returns ok=false, so the tool schema sent to the LLM has empty properties and no required fields. The LLM calls every function tool with {}, which then fails ADK input validation.

Tools registered with genai.Schema directly (via fd.Parameters) are unaffected — they use a separate code path that already works.

🔄 Steps To Reproduce

  1. Create a declarative agent with a type: Agent tool referencing another agent
  2. Send a message to the orchestrator agent
  3. The LLM calls the A2A tool with empty args {}
  4. ADK validation fails: validating root: required: missing properties: ["request"]

🤔 Expected Behavior

The tool schema (including properties and required fields) should be sent to the LLM so it can provide the correct arguments.

📱 Actual Behavior

All function tools created via functiontool.New with typed structs receive empty schemas. Affects remote_a2a_tool (request), ask_user (questions), save_memory (content), and any custom typed tools.

💻 Environment

  • kagent v0.9.0-beta4
  • Go ADK with google.golang.org/adk v1.0.0
  • Bedrock via OpenAI-compatible adapter
  • EKS 1.32

🔍 Additional Context

The fix is to JSON-roundtrip the ParametersJsonSchema value when it's not already map[string]any:

func parametersJsonSchemaToMap(v any) map[string]any {
    if v == nil {
        return nil
    }
    if m, ok := v.(map[string]any); ok {
        return m
    }
    b, err := json.Marshal(v)
    if err != nil {
        return nil
    }
    var m map[string]any
    if err := json.Unmarshal(b, &m); err != nil {
        return nil
    }
    return m
}

Files: go/adk/pkg/models/openai_adk.go (line 342), go/adk/pkg/models/anthropic_adk.go (line 239), new helper in go/adk/pkg/models/base.go.

🙋 Are you willing to contribute?

  • I am willing to submit a PR to fix this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions