Skip to content

fix: replace map[string]any with protocol.InferenceRequestMessage in dispatchOneProvider#189

Open
hankbobtheresearchoor wants to merge 2 commits into
Layr-Labs:masterfrom
hankbobtheresearchoor:fix/typed-inference-request-wiremsg
Open

fix: replace map[string]any with protocol.InferenceRequestMessage in dispatchOneProvider#189
hankbobtheresearchoor wants to merge 2 commits into
Layr-Labs:masterfrom
hankbobtheresearchoor:fix/typed-inference-request-wiremsg

Conversation

@hankbobtheresearchoor

@hankbobtheresearchoor hankbobtheresearchoor commented May 19, 2026

Copy link
Copy Markdown
Contributor

Use the existing typed struct from coordinator/protocol/messages.go instead of an ad-hoc map[string]any for the inference request wire message in dispatchOneProvider.

Before: wireMsg := map[string]any{...} with string-keyed fields and a nested map[string]string for encrypted_body.

After: wireMsg := protocol.InferenceRequestMessage{...} with EncryptedBody: &protocol.EncryptedPayload{...}.

Both types already exist in the protocol package alongside all other wire message types — no new types needed.

  • Build passes
  • Tests pass (go test -race ./api/...)
  • Gofmt clean
  • Lint passes (0 issues)

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

…dispatchOneProvider

Use the existing typed struct from coordinator/protocol/messages.go
instead of an ad-hoc map[string]any for the inference request wire message.
EncryptedBody now uses *protocol.EncryptedPayload instead of a nested map.
@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown

@hankbobtheresearchoor is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@hankbobtheresearchoor

Copy link
Copy Markdown
Contributor Author

I'll take a look at this.

ethenotethan
ethenotethan previously approved these changes May 19, 2026

@hankbobtheresearchoor hankbobtheresearchoor left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review Summary

✅ The change in dispatchOneProvider (lines 230-237) is correct — good type-safety improvement.

🟡 Two more identical map[string]anyInferenceRequestMessage opportunities remain in the same file. See issue comment below for line numbers.

@hankbobtheresearchoor

Copy link
Copy Markdown
Contributor Author

🟡 Should Fix: Two more identical map[string]any wire messages remain

The PR correctly replaces map[string]any with protocol.InferenceRequestMessage in dispatchOneProvider, but the same pattern exists in two other places in coordinator/api/consumer.go:

  1. Line 1091-1098 — dispatch loop (speculative dispatch path):
wireMsg := map[string]any{
    "type":       protocol.TypeInferenceRequest,
    "request_id": requestID,
    "encrypted_body": map[string]string{
        "ephemeral_public_key": encrypted.EphemeralPublicKey,
        "ciphertext":           encrypted.Ciphertext,
    },
}
  1. Line 3422-3429 — third dispatch function:
wireMsg := map[string]any{
    "type":       protocol.TypeInferenceRequest,
    "request_id": requestID,
    "encrypted_body": map[string]string{
        "ephemeral_public_key": encrypted.EphemeralPublicKey,
        "ciphertext":           encrypted.Ciphertext,
    },
}

Both should use the same protocol.InferenceRequestMessage{... &protocol.EncryptedPayload{...}} pattern applied in dispatchOneProvider. Fixing all three makes the PR coverage complete and eliminates the last ad-hoc wire message construction for the inference request type.

@ethenotethan

Copy link
Copy Markdown
Contributor

@hankbobtheresearchoor implement the fixes you self referentially found in your review

@hankbobtheresearchoor

Copy link
Copy Markdown
Contributor Author

I'll take a look at this.

Two additional dispatch sites were still using ad-hoc map[string]any
instead of the typed protocol.InferenceRequestMessage:
- handleChatCompletions queued-provider dispatch (~line 1091)
- handleGenericInference dispatch (~line 3422)

Both now use the same typed struct as the original fix at line 230.
@hankbobtheresearchoor hankbobtheresearchoor force-pushed the fix/typed-inference-request-wiremsg branch from 3ed4fac to e41fad4 Compare May 19, 2026 21:53
@hankbobtheresearchoor

Copy link
Copy Markdown
Contributor Author

Review: PR #189

Verdict: Changes requested (now fixed — see commit below)

Summary

The PR replaces map[string]any with protocol.InferenceRequestMessage in dispatchOneProvider. Good change — using the typed struct that already exists in the protocol package is exactly right.

Issues Found & Fixed

Two identical map[string]any sites were missed. The same ad-hoc wire message construction appeared in 3 places, but only 1 was changed:

Site Location Original PR Now
dispatchOneProvider ~line 230 Fixed Fixed
handleChatCompletions queued dispatch ~line 1091 Missed Fixed (3ed4fac)
handleGenericInference dispatch ~line 3422 Missed Fixed (3ed4fac)

Both remaining sites now use protocol.InferenceRequestMessage with the same pattern.

Observation

The previous map[string]any produced exactly 3 keys: type, request_id, encrypted_body. The InferenceRequestMessage struct has a Body InferenceRequestBody field with json:"body,omitempty". Since Go's encoding/json does not treat zero-value structs as empty for omitempty, the wire message now includes "body":{"model":"","messages":null,"stream":false}. This is a behavioral change — providers should ignore unknown fields, so it's unlikely to cause issues, but worth noting. If strict wire compatibility is desired, Body could be changed to *InferenceRequestBody.

@ethenotethan ethenotethan requested a review from Gajesh2007 May 19, 2026 22:23
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.

2 participants