Commit 594f226
authored
fix: align custom tool SSE lifecycle with OpenAI API compatibility (vllm-project#158)
## Summary
This PR fixes custom tool support across the gateway while preserving
OpenAI’s public Responses API contract.
## What was wrong
vLLM accepts a `type: "custom"` declaration, but exposes the resulting
call as a regular `function_call`. Its streaming response emits:
- `response.function_call_arguments.delta`
- `response.function_call_arguments.done`
It does not emit OpenAI-compatible custom-tool events:
- `response.custom_tool_call_input.delta`
- `response.custom_tool_call_input.done`
Forwarding vLLM’s response directly therefore leaked the internal
normalized function shape instead of returning a public
`custom_tool_call`.
## What changed
The gateway now:
- Normalizes custom tools into model-facing function tools with a
required string `input` parameter.
- Keeps custom tools client-owned; the gateway does not execute them.
- Hides vLLM’s internal normalized function-call events.
- Restores blocking output as `custom_tool_call`.
- Emits the OpenAI-compatible streaming lifecycle:
- `response.output_item.added`
- `response.custom_tool_call_input.delta`
- `response.custom_tool_call_input.done`
- `response.output_item.done`
- Uses one stable `ctc_` item ID throughout the lifecycle.
- Converts custom call/output history into the normalized function
representation only when sending continuation context upstream.
## Testing
Added OpenAI and gateway cassettes for streaming and non-streaming
two-turn custom-tool flows. Tests verify:
- Gateway output matches OpenAI’s public custom-tool contract.
- Raw custom input is preserved.
- Internal `function_call` items do not leak.
- Streaming lifecycle IDs and sequence numbers remain consistent.
- `custom_tool_call_output` works correctly on the continuation turn.
---------
Signed-off-by: maral <maralbahari.98@gmail.com>1 parent 58908ce commit 594f226
32 files changed
Lines changed: 4359 additions & 505 deletions
File tree
- crates
- agentic-server-core
- src
- executor
- tool
- types
- io
- tools
- tests
- cassettes
- custom_tool
- agentic-server/tests
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
272 | 280 | | |
273 | 281 | | |
274 | 282 | | |
| |||
0 commit comments