tools: valid schemas; sse: surface in-stream errors

A judged request sends the whole tool list to the judge. Claude validates the
schemas and rejected the request with 400
"tools.22.function.parameters.type: Field required": delegate_due and
delegate_jobs declared "parameters": {} instead of an object schema. junction
wrapped that 400 in the stream as data: {"error":{...,"code":400}}, but the SSE
parser ignored anything that was not a choice - so the turn ended with
"stream ended with no answer" and the one line explaining it was lost. Three
sessions stopped that way at the same minute.

- delegate_due/delegate_jobs now carry {"type":"object","properties":{}}.
- test_engine walks every registered tool and fails when parameters.type is
  not "object"; this catches the next schema before a judge does.
- sp_sse_line recognises a top-level error object, reports its message and
  remembers its code; the transport puts the code in the reply status.
- a 4xx from the stream ends the turn with the real message and is not
  retried; an empty 2xx stream and a 5xx still are. 402/429/529 stay with the
  usage-limit path, which already handles them.
- test_sse feeds the junction 400 event and checks message and code.
- README and docs/PLUGINS say why a tool schema needs type:object.

make check: all tests passed.
This commit is contained in:
lotherk committed 2026-11-18 06:28:23 +00:00
1 parent 0f8c5c7e96
commit ddf0ec5462
9 files changed
+128 -11

No files matched your search

+6
View File
@@ -127,6 +127,12 @@ A plugin registers tools with the same authorization classes the builtins use:
struct sp_tool t = { 0 };
t.name = "clock";
t.description = "Report the local date and time.";
/*
* parameters is a JSON schema, and its root must say "type":"object".
* A bare {} is rejected by judges that validate the tool list (Claude did,
* and the whole request failed), even when the model itself would accept it.
*/
t.params = "{\"type\":\"object\",\"properties\":{}}";
t.auth = SP_AUTH_READ;
t.run = clock_tool;
sp_host_add_tool(host, &t);