Repository navigation
Description
Symptom
When a client declares an MCP or custom tool whose parameter (or nested property) is an open dictionary object represented as {"type": "object", "properties": {}} without an explicit additionalProperties, calls with empty {} succeed, while passing any key inside that object is rejected locally by agy before reaching the client:
Encountered error in tool validation: invalid arguments: - at '/arguments': additional properties '<key>' not allowed
Root Cause
- Under JSON Schema, omitting
additionalPropertiesdefaults totrue(arbitrary keys allowed). - Clients and adapters frequently normalize open object schemas by inserting an empty
"properties": {}while leavingadditionalPropertiesomitted — for example:- Codex CLI (
codex-rs/tools/src/json_schema.rs,ensure_default_children_for_schema_types) inserts"properties": {}onto{"type": "object"}schemas that lackproperties. packages/agy-cli/index.mjs(normalizeTools) also falls back to{ type: "object", properties: {} }whentool.input_schemais missing.
- Codex CLI (
normalizeTools/sanitizeInputSchemapasses{"type": "object", "properties": {}}through unchanged toagy.agytreats an object schema with"properties": {}and omittedadditionalPropertiesas closed (additionalProperties: false) during local tool-call argument validation, rejecting every dynamic key.
Minimal Reproduction
- Route a client (such as Codex CLI) through Magpie using the
agy-cliprovider (@magpie-community/opencode-agy-cli-auth). - Expose a tool whose schema has an open object parameter (either originally
{"type": "object"}normalized by the client into{"type": "object", "properties": {}}, or declared directly as{"type": "object", "properties": {}}):
{
"name": "run_tool",
"description": "Execute a dynamic tool call",
"input_schema": {
"type": "object",
"properties": {
"tool": { "type": "string" },
"arguments": {
"type": "object",
"description": "Arguments matching the target tool schema",
"properties": {}
}
},
"required": ["tool", "arguments"]
}
}- Ask the model to call
run_toolwith any key insidearguments(e.g.,{"tool": "list_items", "arguments": {"pageSize": 10}}). - Calling with
"arguments": {}succeeds; any non-emptyargumentstriggersadditional properties 'pageSize' not allowed.
Expected Behavior & Suggested Fix
{"type": "object", "properties": {}} with omitted additionalProperties should allow arbitrary key-value pairs as required by JSON Schema.
In sanitizeInputSchema (packages/agy-cli/index.mjs), when a schema node resolves to "object" with:
- no
patternProperties(or empty), - missing
propertiesor emptyproperties: {}, and additionalProperties === undefined,
explicitly setting out.additionalProperties = true preserves standard JSON Schema semantics without affecting schemas that declare additionalProperties: false or explicit properties.
(Note: if agy also rejects undeclared keys on objects that have non-empty properties and omitted additionalProperties, you may also consider whether additionalProperties: true should be normalized more broadly or scoped strictly to empty/missing-properties open objects to avoid loosening stricter tool contracts.)
Environment
- Plugin:
@magpie-community/opencode-agy-cli-auth0.1.95 agy:1.5.10- Client: Codex CLI (
codex-cli 0.170.0) via Magpie gateway - OS: macOS
Activity