Skip to content

fix: preserve code_execution_result fields during union round-trip unmarshaling#330

Open
Aaravanand00 wants to merge 1 commit into
anthropics:mainfrom
Aaravanand00:fix/code-exec-union-unmarshal
Open

fix: preserve code_execution_result fields during union round-trip unmarshaling#330
Aaravanand00 wants to merge 1 commit into
anthropics:mainfrom
Aaravanand00:fix/code-exec-union-unmarshal

Conversation

@Aaravanand00
Copy link
Copy Markdown

What’s this fixing?

The issue turned out to be in union unmarshaling, not ToParam().
code_execution_result fields (stdout, stderr, return_code) were getting dropped during a round-trip because the discriminator wasn’t handled properly.

What changed?

  1. Added explicit handling for all variants in CodeExecutionToolResultBlockParamContentUnion.UnmarshalJSON
  2. Ensured correct struct population based on type
  3. Added round-trip + zero-value tests to verify fields are preserved

Notes

  1. No changes to ToParam()
  2. Kept the fix minimal and backward-compatible

…nion.UnmarshalJSON and harden round-trip tests
@Aaravanand00 Aaravanand00 requested a review from a team as a code owner April 28, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant