Skip to content

fix(schema): honour additionalProperties: true at schema compilation#774

Merged
Muizzkolapo merged 2 commits into
mainfrom
fix/additionalproperties-honoured
Jul 10, 2026
Merged

fix(schema): honour additionalProperties: true at schema compilation#774
Muizzkolapo merged 2 commits into
mainfrom
fix/additionalproperties-honoured

Conversation

@Muizzkolapo

Copy link
Copy Markdown
Owner

Summary

compile_unified_schema (agent_actions/output/response/vendor_compilation.py) hardcoded "additionalProperties": False for the OpenAI-compatible, Anthropic, and Ollama targets, ignoring a schema file's declared additionalProperties: true. A UDF (kind: tool) or LLM output carrying an extra key then passed preflight but crashed mid-run with Additional properties are not allowed — after upstream LLM tokens were already spent, with downstream cascade-skips.

The fix reads the declared value at each of the three compile sites:

"additionalProperties": unified.get("additionalProperties", False),
  • One fix, both validators. The compiled schema feeds both UDF-output validation (_validate_against_schema) and LLM-output validation, so fixing the compiler fixes both paths.
  • Default stays strict. When the schema file omits the key, the compiled schema still emits False — no behaviour change for existing schemas (7897 existing tests unchanged).
  • Nested-items sibling verified, not edited. expander_schema.py:83 uses setdefault("additionalProperties", False) on the source item dict, which already preserves a declared true. Left unchanged; pinned with a regression test so a future refactor can't silently regress it.
  • Provider caveat (documented, not blocked): OpenAI structured-outputs strict mode requires additionalProperties: false. A user who declares true and targets strict OpenAI opts into the provider's behaviour — that is the author's explicit choice; the framework honours the file.

Scope: only the three hardcoded False sites changed. The gemini/cohere branches (already omit the key) and the jsonschema validator (correctly enforces whatever it's handed) are untouched.

Verification

  • RED→GREEN: tests/unit/output/response/test_additional_properties_honoured.py (new). The five vendor honour-true cases + extra-key-validates were RED against the hardcode; GREEN after the fix. Default-strict guards and the nested-items pinning guards are green throughout.
  • End-to-end: test_udf_output_extra_key_accepted_when_true compiles a additionalProperties: true schema and runs an extra-key payload through the real _validate_against_schema UDF path — no crash; the default schema still raises SchemaValidationError.
  • pytest tests/unit/output tests/validation tests/core/test_udf_schema_validation.py -q → 542 passed.
  • Full suite: pytest -q → 7897 passed.
  • ruff check agent_actions tests and ruff format --check agent_actions tests → clean.

@Muizzkolapo Muizzkolapo merged commit 1b32f5d into main Jul 10, 2026
8 of 9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 10, 2026
@Muizzkolapo Muizzkolapo deleted the fix/additionalproperties-honoured branch July 10, 2026 16:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant