Skip to content

fix: resolve wire-format regressions in typed API response structs - #1

Merged
hankbobtheresearchoor merged 1 commit into
hankbobtheresearchoor:fix/typed-api-responsesfrom
Layr-Labs:fix/typed-api-responses-review-fixes
May 18, 2026
Merged

hankbobtheresearchoor merged 1 commit into
hankbobtheresearchoor:fix/typed-api-responsesfrom
Layr-Labs:fix/typed-api-responses-review-fixes

Conversation

@Gajesh2007

Copy link
Copy Markdown

Review fixes for Layr-Labs#166. Merge this into your branch before the main PR is merged.

Changes

Wire-format fixes (breaking regressions)

  • Remove omitempty from ResponsesUsageDetail fields — cached_tokens and reasoning_tokens were silently dropped when zero-valued. The OpenAI API always includes these.
  • Fix incomplete_details serialization — was omitted entirely instead of emitting null. Changed type from any with omitempty to *ResponsesIncompleteDetail without omitempty.
  • Type Usage field as ResponsesUsage — was any, defeating the purpose of the typed struct refactor.

Error handling

  • Handle json.Marshal/json.Unmarshal errors in the Responses API conversion path — previously both errors were silently discarded. Now logs a warning and returns 502 on failure.

Quality

  • Fix split godoc comment — spurious blank line in handleNonStreamingResponseWithFirstChunk doc comment.
  • Add wire-format regression test — TestChatCompletionToResponses now marshals the result to JSON and verifies incomplete_details, cached_tokens, and reasoning_tokens are present.

Test results

  • go vet ./api/... — clean
  • go test ./api/ — all pass

@hankbobtheresearchoor
hankbobtheresearchoor merged commit 3130fc5 into hankbobtheresearchoor:fix/typed-api-responses May 18, 2026
hankbobtheresearchoor pushed a commit that referenced this pull request May 24, 2026
…ayr-Labs#206)

mlx-swift: 49d73abc -> 5202134c (+4 commits)
  - Expose Cmlx product + enable jaccl distributed backend (PR #2)
  - ParallelFileReader batch_size 32 MiB -> 128 MiB (PR #1)

mlx-swift-lm: 8d1cbcd8 -> d164323f (+38 commits)
  - PR Layr-Labs#7: omlx-continuous-batching (BatchedEngine, vLLM-inspired scheduler)
  - PR Layr-Labs#10: MTP speculative decoding (Qwen3.5, Gemma 4, DeepSeek-V4)
  - PR Layr-Labs#19: parallel stacked shard loading
  - PR Layr-Labs#20: Gemma 4 chat templates + tool calls fix

API surface used by provider-swift (ModelContainer, LLMModelFactory,
BatchGenerator, GenerationBatchResponse, RowSampler, makeRowSampler,
LanguageModel, Tokenizer, BatchKVCache, Generation, GenerateStopReason,
UserInput, GenerateParameters) is unchanged. All new work in mlx-swift-lm
is additive (MTP, DeepSeek-V4, BatchedEngine, parallel shard loading).

Notes on the dependency graph:
- mlx-swift-lm main switched its mlx-swift dep from path to URL
  (Layr-Labs/mlx-swift#main). SPM identity resolution gives root-package
  path deps priority, so libs/mlx-swift remains the source of truth
  (verified via swift package show-dependencies).
- mlx-swift-lm main added hummingbird >= 2.0.0 and swift-transformers
  >= 1.3.2 for its new mlx-server target. Both compatible with
  provider-swift's existing pins (hummingbird exact 2.22.0,
  swift-transformers from 1.3.0).

Verification:
- swift build: clean (only pre-existing MLX.GPU.* -> Memory.* deprecation
  warnings; deprecations existed at 49d73abc as well).
- swift test: 207 tests / 18 suites pass in 3.1s. Live MLX tests
  (DARKBLOOM_LIVE_MLX_TESTS=1) still need to be exercised against prod
  models before merge -- recommended: ContinuousBatchingLiveTests on
  Qwen3 and a Gemma 4 end-to-end run (chat template + tool-call
  behavior changed in PR Layr-Labs#20).

Behavioral note: GenerationBatch.step() now auto-activates an MTP fast
path for MTPCapable models at batchSize == 1. No production catalog
model implements MTPCapable today, so prod impact is none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants