fix(agentengine): base64-encode []byte fields instead of failing thei… - #1387
Open
rizukijr wants to merge 1 commit into
Open
fix(agentengine): base64-encode []byte fields instead of failing thei…#1387rizukijr wants to merge 1 commit into
rizukijr wants to merge 1 commit into
Conversation
9 tasks
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Testing Plan
Unit Tests:
Added two tests to
encode_test.go, following the existing file's conventions:TestByteSlice- asession.Eventwith a non-emptyContent.Parts[0].ThoughtSignaturenow converts successfully, and theresulting
thought_signaturekey holds the expected base64 string(
{0xDE, 0xAD, 0xBE, 0xEF}->"3q2+7w==", matching whatencoding/jsonproduces for the same bytes).TestByteSliceOmitEmpty- confirmsomitemptyis unaffected: an empty[]byteis still correctly omitted, not encoded as an empty string.Ran the full existing package suite alongside the new tests - zero regressions:
Manual End-to-End (E2E) Tests:
Ran the real
agentenginelauncher (web agentengine- the same launchercomposition
agentengine.NewLauncheruses in production) locally against areal deployed, Vertex AI Sessions-backed Reasoning Engine resource, using
gemini-3.6-flash(emits a non-emptyThoughtSignatureon essentiallyevery turn, not just tool calls - the worst case observed). Sent the exact
async_stream_queryrequest shape Gemini Enterprise uses:Failed to convert: ... err: unsupported type: uint8and shipped to the client in rawGo/camelCase field names (
thoughtSignature,finishReason,invocationId) mixed into an otherwise snake_case stream.Failed to convertlog lines. The event nowserializes correctly, e.g.
"thought_signature": "AY89a1...", withconsistent snake_case throughout (
finish_reason,invocation_id, etc).Also confirmed this is not model- or version-specific: the same missing
reflect.Uint8case is present identically in all three publishedadk/v2releases (v2.0.0, v2.1.0, v2.2.0), and the bug reproduces ongemini-2.5-flashtoo on any function-calling turn (just not on everyturn, unlike
gemini-3.6-flash). Full details, including the live GeminiEnterprise retry-into-dead-session cascade this caused in production, are
in #1386.
Checklist
Additional context
convertSnake's type switch only ever handled signed integers(
Int/Int8/Int16/Int32/Int64) - there was no case forUint8orany other
Uint*kind. A[]bytefield is areflect.Slice, so it fellinto the generic per-element loop, and each individual byte (a bare
uint8) hit thedefault: unsupported typebranch, failing conversion ofthe entire containing struct.
encoding/json.Marshalalready solvesthis correctly (base64-encodes
[]byteautomatically) - this fix justapplies the same, standard approach instead of reinventing a worse version
of it for one specific hand-rolled converter.