feat(server): OpenAI Responses API layer, /v1/metrics, cached-token accounting - #6
feat(server): OpenAI Responses API layer, /v1/metrics, cached-token accounting#6Iwctwbh wants to merge 1 commit into
Conversation
…ccounting - POST /v1/responses: stateless compatibility layer over the existing chat dispatch path. Supports text/message input items, function tools and tool_choice, non-streaming JSON and typed SSE streaming (response.created / output_item.added / output_text.delta / function_call_arguments.* / response.completed). Hosted built-in tools and store=true are rejected with explicit 400s. - Delta::ToolCallStart: emitted once the function name is decoded, so streaming TTFT lands on the real decode boundary instead of attributing all tool-call tokens to one terminal frame. Chat wire format unchanged. - GenStats.n_cached splits KV-prefix reuse from freshly prefilled tokens; usage.prompt_tokens now reports the full prompt, with the cached share in prompt_tokens_details (chat) / input_tokens_details (responses). - GET /v1/metrics (+ /metrics, auth-gated): request totals, last-request TTFT/prefill/decode TPS, slot occupancy, pager hit/miss/eviction rates.
|
hanks for the PR. The cached-token accounting fix for Issue #5 looks correct, and all tests/checks pass. However, I don’t think the full PR is ready to merge as-is.
|
|
Thanks for the detailed review. I have extracted the cached-token accounting into a focused PR: #7. One clarification: I developed this accounting independently as part of the Responses API and metrics work in #6. I did not pick up or claim Issue #5, and the original PR was not created in response to that issue. I understand that the resulting behavior overlaps with what #5 describes, but there was no intended issue linkage. I agree with the remaining review points and will keep the follow-up changes separated by concern:
I’ll keep #6 as the original discussion context while preparing those focused replacements. |
|
Sounds good. Please continue with the focused follow-up PRs. We’ll leave #6 open as the original discussion context. |
|
The focused Responses API follow-up is ready: #32. It was rebuilt on the current main branch rather than split mechanically from the old #6 commit. The review findings from #6 are addressed: unsupported stateful fields and non-text content return 400, Metrics and |
Summary
tool_choice, non-streaming JSON, and typed SSE streaming (response.created/output_item.added/output_text.delta/function_call_arguments.*/response.completed). OpenAI-hosted built-in tools (web search, file search, computer use) andstore=trueare rejected with explicit 400 errors.Delta::ToolCallStart: emitted once the function name is decoded — dozens of tokens before the arguments finish — so streaming TTFT lands on the real decode boundary instead of attributing all tool-call tokens to one terminal frame. The Chat Completions wire format is unchanged.GenStats.n_cached: splits KV-prefix reuse from freshly prefilled tokens.usage.prompt_tokensnow reports the full prompt (OpenAI semantics), with the cached share inprompt_tokens_details.cached_tokens(chat) /input_tokens_details.cached_tokens(responses). Interval prefill-TPS accounting excludes cached tokens.Notes
dispatch_chatpath; Responses SSE sequence numbers continue across error frames.cargo check --workspace --all-targets,cargo test -p infr-server -p infr-chat(92 + 59 tests pass),cargo fmt --checkclean.