Conversation
5c4e7b0 to
7465ac6
Compare
11aeeb0 to
be0adac
Compare
be0adac to
809aae2
Compare
intercept/responses/reqpayload.go
Outdated
|
|
||
| existing, err := p.existingToolItems() | ||
| if err != nil { | ||
| return p, err |
| raw: []byte(`{"model":123,"stream":"yes","input":42}`), | ||
| want: `{"model":123,"stream":"yes","input":42}`, | ||
| model: "123", | ||
| stream: false, |
There was a problem hiding this comment.
I understand that this is a consequence of not unmarshaling the payload, but this feels like an odd behaviour to test for without explicitly documenting this shortcoming of the new approach.
It won't matter once we move towards a reverse-proxy model, though.
There was a problem hiding this comment.
Where should it be documented?
There was a problem hiding this comment.
Even just documenting it here is fine. I just don't want us to mistake "this is how it works" for "this is how it should work".
| if tc.wantSame { | ||
| require.Equal(t, p, updated) | ||
| } |
There was a problem hiding this comment.
Nit: you could drop this and just specify wantNames.
There was a problem hiding this comment.
I've left it as is since it is a bit more stronger check as it checks whole JSON instead of just ".tools" field.
| assert.Equal(t, p, updated) | ||
| } | ||
| if tc.wantFlagSet { | ||
| assert.False(t, gjson.GetBytes(updated, "parallel_tool_calls").Bool()) |
There was a problem hiding this comment.
We should have a helper for this in the ResponsesRequestPayload type rather than scattering business logic around like this.
| wantFlagSet bool | ||
| }{ | ||
| { | ||
| name: "sets flag when tools exist", |
There was a problem hiding this comment.
It's more complicated than this now.
We only disable parallel tool calls when injected tools are defined, regardless of whether any client-issued tools exist.
intercept/responses/reqpayload.go
Outdated
| return p.set(reqPathParallelToolCalls, false) | ||
| } | ||
|
|
||
| func (p ResponsesRequestPayload) withAppendedInputItems(items []responses.ResponseInputItemUnionParam) (ResponsesRequestPayload, error) { |
There was a problem hiding this comment.
Nit: I'd prefer this were named as setters, which is what they are.
The "withXXX" pattern is usually used with the options pattern.
| name: "unsupported input shape errors during rewrite", | ||
| raw: []byte(`{"model":"gpt-4o","input":123}`), | ||
| items: []responses.ResponseInputItemUnionParam{responses.ResponseInputItemParamOfFunctionCallOutput("call_123", "done")}, | ||
| wantErr: "unsupported input type", |
There was a problem hiding this comment.
This error is not going to be useful to us or operators. We should include the field name and the type of the field plus the type of the incoming value.
There was a problem hiding this comment.
Updated error messages and the tests to check full error message instead of just a fragment of it.
| require.NoError(t, err) | ||
| } | ||
|
|
||
| require.True(t, json.Valid(updated)) |
There was a problem hiding this comment.
These are not necessary in the tests since NewResponsesRequestPayload already rejects invalid input.
|
|
||
| // Disable parallel tool calls after injecting tools, so the check for | ||
| // existing tools in the payload sees the newly injected ones. | ||
| i.disableParallelToolCalls() |
There was a problem hiding this comment.
I didn't notice this when I refactored the parallel tool calls logic, but disableParallelToolCalls is now being called twice in this func.
There was a problem hiding this comment.
Thanks, I was supposed to fix it but it got lost. I'll need to double check if it works after rebase.
intercept/responses/reqpayload.go
Outdated
| return nil, fmt.Errorf("responses empty request body") | ||
| } | ||
| if !json.Valid(raw) { | ||
| return nil, fmt.Errorf("responses invalid JSON request body") |
There was a problem hiding this comment.
Nit: this reads a bit strangely.
| return nil, fmt.Errorf("responses invalid JSON request body") | |
| return nil, fmt.Errorf("invalid JSON payload") |
There was a problem hiding this comment.
I think I changed it to match copilot tests
aibridge/provider/copilot_test.go
Line 129 in b3cd38b
aibridge/provider/copilot_test.go
Line 220 in b3cd38b
but yeah, it sound a bit weird. Changed.
809aae2 to
93d2b9c
Compare
… in responses interceptor
93d2b9c to
5f14de7
Compare
ssncferreira
left a comment
There was a problem hiding this comment.
LGTM 🧹 nice refactor! Just a few nits

Refactored the responses interceptor replacing
ResponsesNewParamsWrapperwith a newResponsesRequestPayloadtype that wraps raw JSON bytes and consolidates operations made on request payload.