refactor(chat/responses): canonicalize input at the entry boundary#136
Draft
Menci wants to merge 1 commit into
Draft
refactor(chat/responses): canonicalize input at the entry boundary#136Menci wants to merge 1 commit into
Menci wants to merge 1 commit into
Conversation
Wire `ResponsesPayload.input` is `string | InputItem[]`. The HTTP/WS
entries normalize a bare-string `input` to a single synthetic
user-role message immediately on parse, so every internal reader sees
array-only input. Encoded in the type system via a new
`CanonicalResponsesPayload = Omit<ResponsesPayload, 'input'> &
{ input: ResponsesInputItem[] }`.
Plumbed through every signature past the entry: ResponsesServeGenerateArgs,
ResponsesServeCompactArgs, ResponsesAttemptInvokeArgs, ResponsesInvocation
(the gateway-internal interceptor variant — provider-package
ResponsesInvocation stays wire-shaped), ResponsesServePlan.prepared,
RewrittenResponsesPayload, expandPreviousResponseId, normalizeAssistantInputText.
Cross-protocol entries (messages/gemini translating to responses)
re-canonicalize the translated payload via the exported
`canonicalizeResponsesPayload` helper.
Removes every internal `typeof input === 'string'` branch:
expandPreviousResponseId, expandShimCompactionItems, simulateCompaction
(the shim's `originalInputItems` materialization), containsCompactionTrigger,
withInterleavedSystemDemotedToUser. Drops `materializeInput` in serve-prep
(input is already array). Drops the matching obsolete tests.
3 tasks
88cd186 to
ce88d6a
Compare
2789279 to
e8ea938
Compare
ce88d6a to
87e1ce3
Compare
e8ea938 to
1cd85a8
Compare
87e1ce3 to
0c05f80
Compare
1cd85a8 to
5037202
Compare
0c05f80 to
5db19d3
Compare
5b2a41a to
9539807
Compare
046b62e to
c3ba39e
Compare
9539807 to
e0ca637
Compare
c3ba39e to
d6913b4
Compare
b9e938e to
d8c7a48
Compare
7d8f28f to
afd2d8d
Compare
d8c7a48 to
e8f031e
Compare
afd2d8d to
eb646be
Compare
e8f031e to
fa7a3b6
Compare
eb646be to
4b78b8d
Compare
22ea872 to
feaa92c
Compare
f8c9e6e to
9753aa9
Compare
141056c to
c14d814
Compare
3fd8b66 to
a00cf7c
Compare
e95e773 to
dd6d30f
Compare
a00cf7c to
4d16702
Compare
dd6d30f to
b1b3830
Compare
4d16702 to
69a13dd
Compare
b1b3830 to
e5d21ad
Compare
69a13dd to
977e529
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire `ResponsesPayload.input` is `string | InputItem[]`. The HTTP/WS entries normalize a bare-string `input` to a single synthetic user-role message immediately on parse, so every internal reader sees array-only input. Encoded in the type system via `CanonicalResponsesPayload = Omit<ResponsesPayload, 'input'> & { input: ResponsesInputItem[] }`.
Plumbed through every signature past the entry: `ResponsesServeGenerateArgs`, `ResponsesServeCompactArgs`, `ResponsesAttemptInvokeArgs`, `ResponsesInvocation` (the gateway-internal interceptor variant — provider-package `ResponsesInvocation` stays wire-shaped), `ResponsesServePlan.prepared`, `RewrittenResponsesPayload`, `expandPreviousResponseId`, `normalizeAssistantInputText`. Cross-protocol entries (messages/gemini translating to responses) re-canonicalize the translated payload via the exported `canonicalizeResponsesPayload` helper.
Removes every internal `typeof input === 'string'` branch: `expandPreviousResponseId`, `expandShimCompactionItems`, `simulateCompaction` (the shim's `originalInputItems` materialization), `containsCompactionTrigger`, `withInterleavedSystemDemotedToUser`, plus the matching obsolete tests.
Test plan