Conversation
gaoanze888
left a comment
There was a problem hiding this comment.
The production mapping is correct: @google/genai@2.21.0 defines TOO_MANY_TOOL_CALLS as a terminal tool-call failure, and both Google Generative AI and Vertex use this shared mapper. The exact head also restores npm run check, and the existing Google stop-reason suite passes 8/8.
One test gap remains: the test diff only adds TOO_MANY_TOOL_CALLS to the mocked enum. No test sets googleGenAiMock.finishReason to that value, so the suite still passes if the production case is removed. Please add a parameterized regression over the existing adapters table that asserts, for both Google and Vertex:
stopReason === "error"rawStopReason === "TOO_MANY_TOOL_CALLS"- the provider error message retains that reason
This is a two-line production fix for a dependency-enum addition, so the regression should directly exercise the newly handled value rather than only making the mock compile.
This comment is AI-generated by /wr
3c48ec1 to
16fb21a
Compare
gaoanze888
left a comment
There was a problem hiding this comment.
Rechecked the new exact head 16fb21a5823c. The production enum mapping is still correct and CI is green, but the requested behavioral regression is still missing: the only test change adds TOO_MANY_TOOL_CALLS to the mocked enum. No test assigns that finish reason or asserts the adapter result. Removing the production case FinishReason.TOO_MANY_TOOL_CALLS therefore still leaves the changed suite green. Please add the direct Google + Vertex adapter assertions from the previous review (stopReason, rawStopReason, and retained error reason).
Summary
mapStopReasonthrows on a Gemini response that finishes withTOO_MANY_TOOL_CALLS.@google/genai@2.21.0added the member toFinishReason. The exhaustive switch ingoogle-shared.tsdoes not list it, so the call falls through to thedefaultbranch and throwsUnhandled stop reason: TOO_MANY_TOOL_CALLSinstead of returning a stop reason. It is grouped withMALFORMED_FUNCTION_CALLandUNEXPECTED_TOOL_CALL, the other tool-call failures, and maps to"error".The same member is added to the
FinishReasonmock ingoogle-raw-stop-reason.test.ts, which keeps its own copy of the enum.This also unblocks
npm run checkon a clean checkout:tsgo --noEmitcurrently reports this as its only error, becausereasonis notneverin thedefaultbranch.Testing
npm run check— passes; before this change it fails ongoogle-shared.ts(402,10)npx vitest --runinpackages/ai— 120 files, 1062 passednpx vitest --run test/google-raw-stop-reason.test.ts— 8 passed