Skip to content

Python: Bug: ValueError: Unknown field for Schema: anyOf #12442

Closed

Description

Describe the bug
When using ChatCompletionAgent instances as plugins with GoogleAIChatCompletion service, the application crashes with ValueError: Unknown field for Schema: anyOf during schema conversion from Semantic Kernel to Google AI's protobuf format.
To Reproduce
Steps to reproduce the behavior:

Create multiple ChatCompletionAgent instances using GoogleAIChatCompletion service
Add these agents as plugins to another ChatCompletionAgent using the plugins parameter
Call get_response() method on the parent agent with any message
See error: ValueError: Unknown field for Schema: anyOf

Minimal reproduction code:
pythonimport asyncio
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.google.google_ai import GoogleAIChatCompletion

Initialize Google AI chat completion service

chat_completion = GoogleAIChatCompletion(
gemini_model_id="gemini-2.0-flash",
api_key="YOUR_API_KEY"
)

Create child agents

billing_agent = ChatCompletionAgent(
service=chat_completion,
name="BillingAgent",
instructions="You handle billing issues."
)

refund_agent = ChatCompletionAgent(
service=chat_completion,
name="RefundAgent",
instructions="Assist users with refund inquiries.",
)

Create parent agent with child agents as plugins

triage_agent = ChatCompletionAgent(
service=chat_completion,
name="TriageAgent",
instructions="Evaluate user requests and forward them to other agents.",
plugins=[billing_agent, refund_agent], # This causes the error
)

async def main():
# This call triggers the error
response = await triage_agent.get_response(
messages="test message",
thread=None,
)

asyncio.run(main())
Expected behavior
The triage agent should successfully process the user input and coordinate with the plugin agents to provide a response without any schema-related errors.
Screenshots
Full error traceback:
Traceback (most recent call last):
File "C:\gen-ai\agents_poc\semantic_kernel\venv\Lib\site-packages\proto\marshal\rules\message.py", line 36, in to_proto
return self._descriptor(**value)
~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: Parameter to CopyFrom() must be instance of same class: expected <class 'Schema'> got <class 'dict'>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\gen-ai\agents_poc\semantic_kernel\venv\Lib\site-packages\proto\marshal\rules\message.py", line 36, in to_proto
return self._descriptor(**value)
~~~~~~~~~~~~~~~~^^^^^^^^^
ValueError: Protocol message Schema has no "anyOf" field.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "google_check3.py", line 69, in
asyncio.run(main())
ValueError: Unknown field for Schema: anyOf
Platform

Language: Python 3.13
Source: pip package (please run pip show semantic-kernel to get exact version)
AI model: Google AI Gemini 2.0 Flash
IDE: VS Code
OS: Windows

Additional context
This error occurs specifically when using the Google AI connector with agent plugins. The issue appears to be that Semantic Kernel generates JSON schemas containing "anyOf" fields, but Google AI's protobuf Schema definition doesn't support these fields.
The error occurs in the schema conversion process at:

File: google\generativeai\types\content_types.py
Function: FunctionDeclaration.init()
During: _rename_schema_fields() processing

This issue prevents using the agent plugin architecture with Google AI services, while other providers (OpenAI, Azure) may work correctly. A schema transformation layer or validation step may be needed to make Semantic Kernel compatible with Google AI's function declaration requirements.

Activity

  1. changed the title [-]Bug: ValueError: Unknown field for Schema: anyOf[/-] [+]Python: Bug: ValueError: Unknown field for Schema: anyOf[/+] on Jun 10, 2025
  2. OrbitAVI commented on Jul 15, 2025

    @OrbitAVI

    Following, having the same issue.

  3. github-actions commented on Oct 17, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no activity.

  4. added
    staleIssue is stale because it has been open for a while and has no activity
    on Oct 17, 2025
  5. added a commit that references this issue on Mar 2, 2026
    43ccc3c
  6. weiguangli-io commented on Mar 2, 2026

    @weiguangli-io
    Contributor

    I've submitted a fix in PR #13624 that adds schema sanitization for Google AI/Vertex AI connectors. The anyOf/oneOf and type-as-array constructs are now rewritten to the subset that Google AI's protobuf Schema supports (nullable + single type). Includes 12 regression tests.

  7. added 2 commits that reference this issue on Mar 5, 2026
    50c8c3a
    0ceaf60
  8. added a commit that references this issue on Mar 16, 2026
    3557298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agentsbugSomething isn't workingpythonPull requests for the Python Semantic KernelstaleIssue is stale because it has been open for a while and has no activity

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions