fix(llm): preserve opaque tool-call fields - #948
Conversation
Keep provider-returned extension fields on function tool calls and echo them through the OpenAI SDK on later turns. This prevents OpenAI-compatible providers such as Vertex Gemini from rejecting tool-result continuations when required metadata is dropped.\n\nCloses alibaba#947
|
|
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
|
Fresh staging evidence after the Pylon Vertex route fix: real webhook run |
Description
Preserve unknown JSON fields returned on OpenAI-compatible function tool calls and echo them on later assistant-history turns through the OpenAI SDK's supported
SetExtraFieldsmechanism.Vertex AI's OpenAI-compatible Gemini endpoint puts a required thought signature under
tool_calls[].extra_content. OCR previously reduced every returned tool call toid,type, andfunction, so a repository tool succeeded on turn one and the provider rejected turn two with HTTP 400. The fix is provider-independent: opaque extension fields survive the response-to-request round trip, while OCR continues to ownid,type, andfunction; invalid JSON is not forwarded; and the fields remain excluded from normal OCR JSON/session serialization.Type of Change
How Has This Been Tested?
make testpasses locallyTests and validation:
go test -count=1 ./internal/llm -skip 'TestShellRCFiles|TestTryShellRC'passes. The skipped tests are existing Unix-home assumptions that fail under Windows becauseos.UserHomeDirdoes not follow the test'sHOMEoverride.go vet ./...passes.extra_contenton turn one and rejects turn two unless OCR echoes it unchanged.The full Windows suite still contains unrelated permission/Unix-shell failures, and the race target requires a CGO toolchain not present on this host. CI remains the authoritative full race run.
Checklist
go fmt,go vet)Related Issues
Closes #947