[Schema][Server] Harden sampling tools against the spec (#420)
* harden sampling tools against the spec Report tool-flow violations as -32602 instead of dropping the request, accept resource_link in tool results, gate tools on sampling.tools, and reject empty content. * normalize keyed content arrays to lists array_filter() and friends preserve keys, and a keyed array serializes as a JSON object instead of the content-block array the schema requires.
This commit is contained in:
parent
becce29c41
commit
43815e38a8
2 changed files with 1212 additions and 167 deletions
|
|
@ -61,7 +61,7 @@ $samplingRequestHandler = new SamplingRequestHandler(new class implements Sampli
|
|||
role: Role::Assistant,
|
||||
content: new TextContent($mockResponse),
|
||||
model: 'mock-gpt-4',
|
||||
stopReason: 'end_turn',
|
||||
stopReason: 'endTurn',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ $samplingRequestHandler = new SamplingRequestHandler(new class implements Sampli
|
|||
role: Role::Assistant,
|
||||
content: new TextContent($mockResponse),
|
||||
model: 'mock-gpt-4',
|
||||
stopReason: 'end_turn',
|
||||
stopReason: 'endTurn',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue