[GH-ISSUE #2420] [Issue]: 11-PROV-CONTRACT-tool-call-roundtrip drops OpenAI Responses tool roundtrip shape #1185

Closed
opened 2026-10-21 05:28:31 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2420

Originally assigned to: @SpicyMarinara on GitHub.

Summary

11-PROV-CONTRACT-tool-call-roundtrip gap: OpenAI Responses tool-call transport does not preserve streamed tool calls and follow-up tool-result messages in the same provider-native shape legacy used.

Linked target: #2410.

Expected behavior

Legacy OpenAI Responses transport maps assistant tool_calls to Responses function_call items, maps tool messages to function_call_output, and accumulates streamed function-call deltas before returning final tool-call objects.

Actual behavior

Refactor Responses input maps tool messages to plain user messages and ignores assistant tool_calls when building Responses input. Refactor Responses streaming emits raw response.function_call_arguments.delta events as tool_call; the engine normalizer requires a tool name/function shape, so streamed Responses tool calls can be dropped before execution/follow-up.

Steps to reproduce

  1. Static trace 11-PROV-CONTRACT-tool-call-roundtrip in #2410.
  2. Compare legacy main:packages/server/src/services/llm/providers/openai.provider.ts Responses tool input/stream handling with refactor src-tauri/crates/llm/src/lib.rs.
  3. Observe refactor lacks legacy function_call / function_call_output history mapping and emits Responses argument deltas before they are final tool-call objects.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor parityscan, current target source refactor@09923989
  • Run mode: static trace
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not run
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: OpenAI Responses / OpenAI-compatible tool transport

Logs, screenshots, or video

Proof:

  • Legacy tool DTO contract: main:packages/server/src/services/llm/base-provider.ts:42
  • Legacy OpenAI chat multimodal/tool history mapping: main:packages/server/src/services/llm/providers/openai.provider.ts:685
  • Legacy Responses maps tool messages to function_call_output and assistant tool_calls to function_call: main:packages/server/src/services/llm/providers/openai.provider.ts:1245
  • Legacy Responses streaming accumulates function-call deltas and returns final tool calls: main:packages/server/src/services/llm/providers/openai.provider.ts:1727
  • Refactor DTO carries tool_call_id, tool_calls, and tools: src-tauri/crates/llm/src/lib.rs:34
  • Refactor command parses tool fields from request bodies: src-tauri/src/commands/storage/llm.rs:51
  • Refactor Responses input collapses non-assistant/system roles to user and does not special-case tool history: src-tauri/crates/llm/src/lib.rs:1953
  • Refactor Responses stream emits raw argument delta as tool_call: src-tauri/crates/llm/src/lib.rs:2196
  • Refactor engine normalizer requires tool name/function shape: src/engine/generation/tools-runtime.ts:63

Regression notes

Legacy main preserved Responses tool roundtrip shape for follow-up tool-result messages and streamed function-call deltas. Refactor provider transport regresses that shape for OpenAI Responses.

Additional context

Acceptance criteria:

  • 11-PROV-CONTRACT-tool-call-roundtrip preserves assistant tool_calls and tool-result messages for OpenAI Responses using provider-native function_call / function_call_output input items.
  • Responses streaming accumulates function-call deltas and emits final normalized tool-call objects with stable id, function.name, and function.arguments.
  • Chat Completions/OpenAI-compatible tool-call behavior remains intact.
  • Target 13 tool execution remains out of scope; this fix only owns provider payload and parsed tool-call shape.
  • Add focused mocked-provider or unit proof for Responses tool-call history and streamed tool-call finalization.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2420 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `11-PROV-CONTRACT-tool-call-roundtrip` gap: OpenAI Responses tool-call transport does not preserve streamed tool calls and follow-up tool-result messages in the same provider-native shape legacy used. Linked target: #2410. ## Expected behavior Legacy OpenAI Responses transport maps assistant `tool_calls` to Responses `function_call` items, maps tool messages to `function_call_output`, and accumulates streamed function-call deltas before returning final tool-call objects. ## Actual behavior Refactor Responses input maps `tool` messages to plain user messages and ignores assistant `tool_calls` when building Responses input. Refactor Responses streaming emits raw `response.function_call_arguments.delta` events as `tool_call`; the engine normalizer requires a tool name/function shape, so streamed Responses tool calls can be dropped before execution/follow-up. ## Steps to reproduce 1. Static trace `11-PROV-CONTRACT-tool-call-roundtrip` in #2410. 2. Compare legacy `main:packages/server/src/services/llm/providers/openai.provider.ts` Responses tool input/stream handling with refactor `src-tauri/crates/llm/src/lib.rs`. 3. Observe refactor lacks legacy `function_call` / `function_call_output` history mapping and emits Responses argument deltas before they are final tool-call objects. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor parityscan, current target source `refactor@09923989` - Run mode: static trace - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not run - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: OpenAI Responses / OpenAI-compatible tool transport ## Logs, screenshots, or video Proof: - Legacy tool DTO contract: `main:packages/server/src/services/llm/base-provider.ts:42` - Legacy OpenAI chat multimodal/tool history mapping: `main:packages/server/src/services/llm/providers/openai.provider.ts:685` - Legacy Responses maps `tool` messages to `function_call_output` and assistant `tool_calls` to `function_call`: `main:packages/server/src/services/llm/providers/openai.provider.ts:1245` - Legacy Responses streaming accumulates function-call deltas and returns final tool calls: `main:packages/server/src/services/llm/providers/openai.provider.ts:1727` - Refactor DTO carries `tool_call_id`, `tool_calls`, and `tools`: `src-tauri/crates/llm/src/lib.rs:34` - Refactor command parses tool fields from request bodies: `src-tauri/src/commands/storage/llm.rs:51` - Refactor Responses input collapses non-assistant/system roles to `user` and does not special-case tool history: `src-tauri/crates/llm/src/lib.rs:1953` - Refactor Responses stream emits raw argument delta as `tool_call`: `src-tauri/crates/llm/src/lib.rs:2196` - Refactor engine normalizer requires tool name/function shape: `src/engine/generation/tools-runtime.ts:63` ## Regression notes Legacy `main` preserved Responses tool roundtrip shape for follow-up tool-result messages and streamed function-call deltas. Refactor provider transport regresses that shape for OpenAI Responses. ## Additional context Acceptance criteria: - `11-PROV-CONTRACT-tool-call-roundtrip` preserves assistant `tool_calls` and tool-result messages for OpenAI Responses using provider-native `function_call` / `function_call_output` input items. - Responses streaming accumulates function-call deltas and emits final normalized tool-call objects with stable `id`, `function.name`, and `function.arguments`. - Chat Completions/OpenAI-compatible tool-call behavior remains intact. - Target 13 tool execution remains out of scope; this fix only owns provider payload and parsed tool-call shape. - Add focused mocked-provider or unit proof for Responses tool-call history and streamed tool-call finalization. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:31 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jun 6, 2026):

Fixed on refactor in 6fbaad26.\n\nWhat changed:\n- OpenAI Responses request input now preserves assistant tool_calls as provider-native function_call items.\n- Tool result messages now become function_call_output items.\n- Non-fc tool call IDs are mapped consistently to fc_mapped_N so function_call and function_call_output share the same Responses-valid ID.\n- Responses streaming now accumulates output_item.added, function_call_arguments.delta/done, and output_item.done/completed payloads, then emits final normalized tool_call chunks with stable id, function.name, and function.arguments.\n- Chat Completions/OpenAI-compatible tool-call accumulation was left intact.\n\nVerification:\n- cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm openai_responses -- --nocapture\n- cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm openai_chat_stream_accumulates_tool_call_deltas -- --nocapture\n- cargo check --manifest-path src-tauri/Cargo.toml --workspace\n- pnpm check:architecture

<!-- gh-comment-id:4638288693 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed on refactor in 6fbaad26.\n\nWhat changed:\n- OpenAI Responses request input now preserves assistant tool_calls as provider-native function_call items.\n- Tool result messages now become function_call_output items.\n- Non-fc tool call IDs are mapped consistently to fc_mapped_N so function_call and function_call_output share the same Responses-valid ID.\n- Responses streaming now accumulates output_item.added, function_call_arguments.delta/done, and output_item.done/completed payloads, then emits final normalized tool_call chunks with stable id, function.name, and function.arguments.\n- Chat Completions/OpenAI-compatible tool-call accumulation was left intact.\n\nVerification:\n- cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm openai_responses -- --nocapture\n- cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm openai_chat_stream_accumulates_tool_call_deltas -- --nocapture\n- cargo check --manifest-path src-tauri/Cargo.toml --workspace\n- pnpm check:architecture
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1185
No description provided.