Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(cron): drop top-level oneOf so OpenAI Codex/Responses accept tool schema
coldxiangyu7527961b19c0
diff --git a/nanobot/agent/tools/cron.py b/nanobot/agent/tools/cron.pyindex 111bb1c85..7124a2a74 100644--- a/nanobot/agent/tools/cron.py+++ b/nanobot/agent/tools/cron.py@@ -43,30 +43,12 @@ _CRON_PARAMETERS = tool_parameters_schema(required=["action"],description=("Action-specific parameters: add requires a non-empty message plus one schedule "- "(every_seconds, cron_expr, or at); remove requires job_id; list only needs action."+ "(every_seconds, cron_expr, or at); remove requires job_id; list only needs action. "+ "Per-action requirements are enforced at runtime (see field descriptions) so the "+ "top-level schema stays compatible with providers (e.g. OpenAI Codex/Responses) that "+ "reject oneOf/anyOf/allOf/enum/not at the root of function parameters."),)-_CRON_PARAMETERS["oneOf"] = [- {- "properties": {- "action": {"enum": ["add"]},- "message": {"type": "string", "minLength": 1},- },- "required": ["action", "message"],- },- {- "properties": {- "action": {"enum": ["list"]},- },- "required": ["action"],- },- {- "properties": {- "action": {"enum": ["remove"]},- },- "required": ["action", "job_id"],- },-]@tool_parameters(_CRON_PARAMETERS)diff --git a/tests/cron/test_cron_tool_list.py b/tests/cron/test_cron_tool_list.pyindex a3ee9b1a7..5ffd46918 100644--- a/tests/cron/test_cron_tool_list.py+++ b/tests/cron/test_cron_tool_list.py@@ -348,24 +348,20 @@ def test_add_job_can_disable_delivery(tmp_path) -> None:def test_cron_schema_advertises_action_specific_requirements(tmp_path) -> None:tool = _make_tool(tmp_path)+ # Only ``action`` is required at the schema root — per-action requirements+ # are enforced at runtime via ``validate_params`` and surfaced to the LLM+ # through field descriptions. We intentionally do NOT set top-level+ # ``oneOf``/``anyOf``/``allOf``/``enum``/``not``: OpenAI Codex/Responses+ # reject those at the root of function parameters (#3265 regression).assert tool.parameters["required"] == ["action"]- assert tool.parameters["oneOf"] == [- {- "properties": {- "action": {"enum": ["add"]},- "message": {"type": "string", "minLength": 1},- },- "required": ["action", "message"],- },- {- "properties": {"action": {"enum": ["list"]}},- "required": ["action"],- },- {- "properties": {"action": {"enum": ["remove"]}},- "required": ["action", "job_id"],- },- ]+ for disallowed in ("oneOf", "anyOf", "allOf", "not"):+ assert disallowed not in tool.parameters, (+ f"Top-level '{disallowed}' is rejected by OpenAI Codex/Responses tool schemas"+ )+ message_desc = tool.parameters["properties"]["message"]["description"]+ assert "REQUIRED" in message_desc and "action='add'" in message_desc+ job_id_desc = tool.parameters["properties"]["job_id"]["description"]+ assert "REQUIRED" in job_id_desc and "action='remove'" in job_id_descdef test_validate_params_requires_message_only_for_add(tmp_path) -> None: