Skip to content

agy-cli: open object schemas with empty properties: {} and omitted additionalProperties fail agy tool validation #1332

Open

Description

@jimlee2048

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

  1. Under JSON Schema, omitting additionalProperties defaults to true (arbitrary keys allowed).
  2. Clients and adapters frequently normalize open object schemas by inserting an empty "properties": {} while leaving additionalProperties omitted — for example:
    • Codex CLI (codex-rs/tools/src/json_schema.rs, ensure_default_children_for_schema_types) inserts "properties": {} onto {"type": "object"} schemas that lack properties.
    • packages/agy-cli/index.mjs (normalizeTools) also falls back to { type: "object", properties: {} } when tool.input_schema is missing.
  3. normalizeTools / sanitizeInputSchema passes {"type": "object", "properties": {}} through unchanged to agy.
  4. agy treats an object schema with "properties": {} and omitted additionalProperties as closed (additionalProperties: false) during local tool-call argument validation, rejecting every dynamic key.

Minimal Reproduction

  1. Route a client (such as Codex CLI) through Magpie using the agy-cli provider (@magpie-community/opencode-agy-cli-auth).
  2. 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"]
  }
}
  1. Ask the model to call run_tool with any key inside arguments (e.g., {"tool": "list_items", "arguments": {"pageSize": 10}}).
  2. Calling with "arguments": {} succeeds; any non-empty arguments triggers additional 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 properties or empty properties: {}, 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-auth 0.1.95
  • agy: 1.5.10
  • Client: Codex CLI (codex-cli 0.170.0) via Magpie gateway
  • OS: macOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions