Skip to content

Add Responses translation semantics#703

Open
franciscojavierarceo wants to merge 1 commit into
codex/issue-213-chat-translation-corefrom
codex/issue-213-chat-translation-semantics
Open

Add Responses translation semantics#703
franciscojavierarceo wants to merge 1 commit into
codex/issue-213-chat-translation-corefrom
codex/issue-213-chat-translation-semantics

Conversation

@franciscojavierarceo

@franciscojavierarceo franciscojavierarceo commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Part of #213.

Summary

  • extend the translator with schema-complete Responses resource and stream-event conversion
  • preserve function-call history, structured output formats, allowed tool choices, strict function schemas, logprobs settings, and content_filter incomplete status
  • add curated Chat Completions recording fixtures; the fixture provenance comes from OGX compatibility testing

Stack

Validation

  • cargo test -p praxis-proxy-filter --lib --features ai-inference translation
  • cargo test -p praxis-proxy-filter --lib --features ai-inference openai::responses
  • make lint

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Add Responses translation semantics

Extends the Chat Completions translator with response/stream conversion and schema-complete resource building. The request-side additions (logprobs, text format, stream options, function-call history, strict schemas) are well structured and tested. The response and stream translators are substantial and mostly correct.

Severity Count
Medium 3

Non-inline findings

None -- all findings are inline.

let name = obj.get("name").and_then(Value::as_str).unwrap_or("");
let arguments = obj.get("arguments").and_then(Value::as_str).unwrap_or("{}");

messages.push(json!({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] append_function_call creates a separate assistant message per function call item. When the Responses input contains consecutive function_call items (parallel tool calls), the Chat Completions API expects them batched into a single assistant message's tool_calls array. Separate messages will cause provider errors because the intervening tool response messages won't have a matching preceding tool_calls entry.

Merge consecutive function_call items into one assistant message, or accumulate all tool calls and emit a single message at the end of the function-call sequence.

"url": url
}
})
if let Some(url) = part.get("image_url").or_else(|| part.get("url")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] The base version fell back to part.get("file_id") for input images, which matches the Responses API input_image schema. This PR changes the fallback to part.get("url"), which is not a documented input_image field. If a caller sends {"type": "input_image", "file_id": "file-abc"}, it will now fall through to the else branch and clone the raw part instead of extracting the file reference.

Restore file_id as an additional fallback: .or_else(|| part.get("file_id")).

state.finish_reason = Some(finish_reason.to_owned());
}

let content = choice

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] process_stream_choice only extracts delta.content (text). Tool-call streaming chunks carry deltas in delta.tool_calls[].function.arguments and delta.tool_calls[].function.name, which are silently dropped here. A streaming request that triggers function calls will produce a terminal response.completed event with an empty output array and no function call items.

If tool-call streaming is out of scope for this PR, add a // TODO or tracking issue and document the limitation. Otherwise, accumulate delta.tool_calls fragments and emit function_call output items in finish_stream.

@shaneutt shaneutt moved this to Review in AI Gateway Jun 23, 2026
@shaneutt shaneutt added this to the v0.4.0 milestone Jun 23, 2026
@franciscojavierarceo franciscojavierarceo force-pushed the codex/issue-213-chat-translation-core branch from 77e19aa to 6568916 Compare June 24, 2026 02:13
@franciscojavierarceo franciscojavierarceo force-pushed the codex/issue-213-chat-translation-semantics branch from 06ef27b to 9c51857 Compare June 24, 2026 02:13
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
@franciscojavierarceo franciscojavierarceo force-pushed the codex/issue-213-chat-translation-core branch from 6568916 to 4eb496c Compare June 24, 2026 09:24
@franciscojavierarceo franciscojavierarceo force-pushed the codex/issue-213-chat-translation-semantics branch from 9c51857 to 83442d7 Compare June 24, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

4 participants