Conversation
Inject a legal empty Claude text content block before message_delta on normal thinking-only stops so Claude Code SDK can complete the turn. Do not pad max_tokens, tool turns, or empty streams, and do not forge truncation semantics.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7dfa16dd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| stopReason := "end_turn" | ||
| if params.SawToolCall { | ||
| stopReason = "tool_use" | ||
| } else if finish := gjson.GetBytes(rawJSON, "candidates.0.finishReason"); finish.Exists() && finish.String() == "MAX_TOKENS" { | ||
| stopReason = "max_tokens" |
There was a problem hiding this comment.
Restrict padding to actual normal finish reasons
When a thinking-only response ends with an abnormal Gemini reason such as SAFETY, RECITATION, or MALFORMED_FUNCTION_CALL, this logic leaves stopReason as end_turn, so NeedsEmptyTextPad inserts a visible empty-text block and causes the client to accept the blocked response as a normal completion. Gate padding on the original finish reason being STOP/unspecified rather than the already-collapsed Claude stop reason; the non-stream and Antigravity padding paths have the same issue.
Useful? React with 👍 / 👎.
Why
Antigravity→Claude and Gemini→Claude streams (and non-stream Messages) can end normally with only thinking and no
textortool_use. Claude Code SDK treats that silentend_turnas an incomplete turn, retries, and eventually reports a fake 32k output-token error.A legal empty Claude
textcontent block beforemessage_delta/message_stoplets the SDK complete the turn.What
end_turn/STOP/ empty) in the Antigravity and Gemini Claude translators.max_tokens/MAX_TOKENS, tool turns, or empty streams with no thinking.max_tokensor change real truncation semantics.Tests
end_turn/STOP/ empty; no pad onmax_tokens, existing text, tool_use, empty stream, or already padded.STOPemits empty text beforemessage_delta;MAX_TOKENSdoes not pad.