Skip to content

Conversation

@dannykopping
Copy link
Collaborator

In #63 @pawbana uncovered a latent bug in the OpenAI non-streaming interception handler. When injected tools are invoked, arguments are not being supplied correctly to the MCP invocation. The JSON unmarshaling was silently failing, and the code in general was brittle.

This also exposed a shortcoming in the tests whereby we'd just validate that the injected tool invocation was recorded (along with its args) but not that the actual MCP tool call took place! I've added a callAccumulator type which will track these invocations for testing.

Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
@dannykopping dannykopping force-pushed the openai_blocking_injected_tool_calls branch from 96729ce to 68cf38a Compare December 5, 2025 08:17
Copy link

@SasSwart SasSwart left a comment

Choose a reason for hiding this comment

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

Looks good!

I'm not sure what

			_ = json.NewEncoder(&buf).Encode(tc.Function.Arguments)
			_ = json.NewDecoder(&buf).Decode(&args)

was intended for. As far as I can tell it converted from a formal type to just a map, but then never used that map.

@dannykopping
Copy link
Collaborator Author

but then never used that map.

It was used:

res, err := tool.Call(ctx, args)

Thanks for the review 👍

@dannykopping dannykopping merged commit 4a00d06 into main Dec 5, 2025
1 check passed
@dannykopping dannykopping deleted the openai_blocking_injected_tool_calls branch December 5, 2025 08:44
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