fix(agents): tolerate output_text parts with None text (gemini-3.6-flash run crash) - #80
Open
inf-quantavius wants to merge 1 commit into
Open
Conversation
…apper gemini-3.6-flash (via the LiteLLM Responses translation) emits output_text parts with no text field on tool-calls-only turns; the SDK materializes them leniently with text=None and the mapper's join raised TypeError: sequence item 0: expected str instance, NoneType found, failing the whole HALO run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The first fixed-analysis HALO run on gemini-3.6-flash (pinned by monorepo #4289, merged 2026-07-24 10:31Z) crashed within one turn:
(dev halo_run
99790c24-…, analysis runiar_vEmBDW05ukFmvwyEofnke, smoke run 30091185355; dev Loki showssubagent sub-8e9b236a failed at depth=1: TypeError: …→Emitting halo.failed.)Root cause
Gemini via the LiteLLM Responses translation returns assistant messages whose
output_textpart carries notextfield on tool-calls-only turns — dev ClickHouse shows both gateway calls returned HTTP 200 with content[{"type":"output_text","annotations":[]}]alongsidefunction_callitems (ids carrying Gemini__thought__blobs). The SDK materializes these leniently asResponseOutputTextwithtext=None, and the mapper's(
engine/agents/openai_event_mapper.py:96) raises the exact TypeError, killing the run. gpt-5.5 and deepseek-v4-pro runs on the same project earlier the same day did not hit this — the model swap is the delta.Change
_map_assistant_message: joinpart.text or ""so a text-less part maps to empty content (content=Nonedownstream, same as tool-calls-only turns from other providers).model_construct(lenient parse), asserting the mapper emits a normal assistant item instead of raising.Validation
pytest tests/unit: 480 passed (12 in the mapper file, incl. the new regression test)ruff check+ruff format --check: cleanbasedpyrighton both touched files: 0 errorsRelated: #79 handles the finalization-protocol side of the model swap; this fixes the orthogonal crash that prevents gemini runs from getting past their first tool-calling turn at all.
Provenance
U0B5KMSTCKX)Note
Low Risk
Single-line defensive join in assistant message mapping with a regression test; no auth, data, or API contract changes.
Overview
Fixes HALO run crashes on Gemini when assistant turns are tool-calls-only: LiteLLM/Gemini can return
output_textparts with notextfield, which the SDK parses astext=None. Joining those values in_map_assistant_messageraisedTypeErrorand aborted the run.The mapper now joins
part.text or ""so missing text becomes empty assistant content (content=None), matching other providers’ tool-only turns. A unit test covers the lenientResponseOutputText(text=None)shape.Reviewed by Cursor Bugbot for commit 5309501. Bugbot is set up for automated code reviews on this repo. Configure here.