d73ff9b0fb
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled
50 lines
2.0 KiB
Python
50 lines
2.0 KiB
Python
"""Schema-shape tests for the built-in memory tool.
|
|
|
|
The memory tool previously used ``allOf: [{if: ..., then: {required: ...}}]``
|
|
at the top level of ``parameters`` to hint per-action required fields. That
|
|
form was:
|
|
|
|
1. Ignored by every provider (Chat Completions doesn't honour ``if/then``
|
|
on function schemas), so it never actually enforced anything.
|
|
2. **Rejected outright by strict backends** — OpenAI's Codex endpoint
|
|
(``chatgpt.com/backend-api/codex``, gpt-5.x) returns
|
|
``Invalid schema for function 'memory': schema must have type 'object'
|
|
and not have 'oneOf'/'anyOf'/'allOf'/'enum'/'not' at the top level``.
|
|
|
|
We now rely on the runtime handler (``memory_tool()`` in ``tools/memory_tool.py``)
|
|
to validate required fields per action and return actionable error messages.
|
|
These tests guard the schema against regressing back to a shape strict
|
|
backends reject.
|
|
"""
|
|
|
|
import json
|
|
|
|
from tools.memory_tool import MEMORY_SCHEMA
|
|
|
|
|
|
_FORBIDDEN_TOP_LEVEL_KEYS = ("allOf", "anyOf", "oneOf", "enum", "not")
|
|
|
|
|
|
def test_memory_schema_has_no_forbidden_top_level_combinators():
|
|
"""OpenAI's Codex backend rejects these at the top level of parameters."""
|
|
params = MEMORY_SCHEMA["parameters"]
|
|
for key in _FORBIDDEN_TOP_LEVEL_KEYS:
|
|
assert key not in params, (
|
|
f"top-level {key!r} in memory tool parameters will break the "
|
|
"Codex backend (chatgpt.com/backend-api/codex). Per-action "
|
|
"required-field checks belong in the runtime handler, not the schema."
|
|
)
|
|
|
|
|
|
def test_memory_schema_is_well_formed():
|
|
params = MEMORY_SCHEMA["parameters"]
|
|
assert params["type"] == "object"
|
|
assert params["required"] == ["action", "target"]
|
|
# Nested ``enum`` on property values is fine — only top-level is forbidden.
|
|
assert params["properties"]["action"]["enum"] == ["add", "replace", "remove"]
|
|
assert params["properties"]["target"]["enum"] == ["memory", "user"]
|
|
|
|
|
|
def test_memory_schema_is_json_serializable():
|
|
json.dumps(MEMORY_SCHEMA)
|