tool: an anyOf/oneOf parameter schema is forwarded to Vertex with its sibling keywords, so every request from the agent is rejected
Summary
adk-go forwards a tool's parameter JSON Schema to the model verbatim. When a parameter schema carries an anyOf (or oneOf) next to sibling keywords such as description or title — the shape pydantic emits for an optional or union field, and therefore the shape most MCP servers produce — Vertex rejects the whole request:
400 INVALID_ARGUMENT: Unable to submit request because 'create_payee' functionDeclaration
'parameters.person.age' schema specified other fields alongside any_of. When using any_of,
it must be the only field set.Any agent configured with such a tool fails on Vertex on every turn, because the declaration is rejected before the model is reached. The same constraint has been reported against adk-python (google/adk-python#3281) and the Python GenAI SDK (googleapis/python-genai#625).
Schemas that adk-go infers from a Go type are not affected — inference emits a JSON-Schema type array, {"type": ["null", "integer"]}, which Vertex accepts. The gap is confined to schemas that arrive from outside that inference: an explicit functiontool.Config.InputSchema, and every MCP tool schema.
Versions
Reproduced on google.golang.org/adk/v2 v2.4.0 and on main at 619e6d9.
Reproduction
No model and no network: the test packs the tool into an LLMRequest exactly as the flow does and prints the parameter schema that would go on the wire.
go test -run TestUserSuppliedAnyOfReachesTheModel -count=1 -vActual output — anyOf is still sitting beside title and description:
main_test.go:74: parameter schema sent to the model:
{
"type": "object",
"properties": {
"age": {
"title": "Age",
"description": "the person's age, if known",
"anyOf": [
{ "type": "integer" },
{ "type": "null" }
]
}
}
}
main_test.go:76: anyOf is forwarded alongside sibling keywords; Vertex rejects this shapemain_test.go — self-contained, only adk/v2, genai and jsonschema-gopackage repro
import (
"encoding/json"
"strings"
"testing"
"github.com/google/jsonschema-go/jsonschema"
"google.golang.org/adk/v2/agent"
"google.golang.org/adk/v2/model"
"google.golang.org/adk/v2/tool"
"google.golang.org/adk/v2/tool/functiontool"
)
type args struct {
Age *int `json:"age"`
}
type results struct {
OK bool `json:"ok"`
}
// packed returns the parameter schema adk-go puts on the wire for tl,
// as JSON.
func packed(t *testing.T, tl tool.Tool) string {
t.Helper()
req := &model.LLMRequest{}
pr, ok := tl.(interface {
ProcessRequest(agent.Context, *model.LLMRequest) error
})
if !ok {
t.Fatalf("tool %T does not implement ProcessRequest", tl)
}
if err := pr.ProcessRequest(nil, req); err != nil {
t.Fatal(err)
}
schema := req.Config.Tools[0].FunctionDeclarations[0].ParametersJsonSchema
b, err := json.MarshalIndent(schema, "", " ")
if err != nil {
t.Fatal(err)
}
return string(b)
}
// TestUserSuppliedAnyOfReachesTheModel covers the schema a pydantic
// model or an MCP server produces for an optional union such as
// `age: int | None`: anyOf sitting next to description and title.
func TestUserSuppliedAnyOfReachesTheModel(t *testing.T) {
const raw = `{
"type": "object",
"properties": {
"age": {
"title": "Age",
"description": "the person's age, if known",
"anyOf": [{"type": "integer"}, {"type": "null"}]
}
}
}`
in := &jsonschema.Schema{}
if err := json.Unmarshal([]byte(raw), in); err != nil {
t.Fatal(err)
}
tl, err := functiontool.New[args, results](
functiontool.Config{Name: "create_payee", Description: "create a payee", InputSchema: in},
func(agent.Context, args) (results, error) { return results{OK: true}, nil },
)
if err != nil {
t.Fatal(err)
}
got := packed(t, tl)
t.Logf("parameter schema sent to the model:\n%s", got)
if strings.Contains(got, `"anyOf"`) && (strings.Contains(got, `"description"`) || strings.Contains(got, `"title"`)) {
t.Errorf("anyOf is forwarded alongside sibling keywords; Vertex rejects this shape")
}
}
// TestInferredOptionalField covers the schema adk-go infers on its own
// from a Go struct with a pointer field. This one is already accepted:
// it prints {"type": ["null", "integer"]}.
func TestInferredOptionalField(t *testing.T) {
tl, err := functiontool.New[args, results](
functiontool.Config{Name: "infer", Description: "inferred"},
func(agent.Context, args) (results, error) { return results{OK: true}, nil },
)
if err != nil {
t.Fatal(err)
}
t.Logf("inferred parameter schema:\n%s", packed(t, tl))
}Where the schema passes through untouched
Both line references are pinned to 619e6d9.
functiontool assigns the resolved schema straight onto the declaration at function.go:167, so a caller-supplied InputSchema reaches the model exactly as written.
mcptoolset does the same with the schema the server advertised, at tool.go:52-54. This is the path that matters most in practice: a pydantic-backed MCP server emits anyOf for every X | None field, so connecting one such server is enough to break every Vertex request the agent makes.
Parity with adk-python
adk-python normalises the schema before it is sent. Passing the same input through google.adk.tools._gemini_schema_util._to_gemini_schema on adk-python 2.10.0 gives {"type": "INTEGER", "nullable": true} for the scalar union above, and for a union with a structured member it produces the object schema with nullable: true rather than an anyOf beside siblings. Either way nothing is emitted that trips the Vertex constraint.
Expected behaviour
- A tool whose parameter schema contains
anyOforoneOfalongsidedescription,titleor any other keyword can be used on Vertex. - This holds for all three sources of a tool schema: inferred from a Go type, supplied through
functiontool.Config.InputSchema, and advertised by an MCP server. - Whatever normalisation is applied preserves the accepted values of the original schema, so a union of structured members is not silently narrowed to one branch.
Source: google/adk-go