Skip to content

Stop serializing FunctionCall/Result Error to match .NET JsonIgnore Exception - #625

Open
PratikDhanave (PratikDhanave) wants to merge 4 commits into
microsoft:mainfrom
PratikDhanaveFork:stop-serializing-functioncall-result-error
Open

Stop serializing FunctionCall/Result Error to match .NET JsonIgnore Exception#625
PratikDhanave (PratikDhanave) wants to merge 4 commits into
microsoft:mainfrom
PratikDhanaveFork:stop-serializing-functioncall-result-error

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

What

Remove the Error field from serializedFunctionCallContent and serializedFunctionResultContent, and drop the marshal/unmarshal logic that persisted it as a string and reconstructed it via errors.New. The in-memory Error error field on FunctionCallContent and FunctionResultContent stays as informational-only state.

Why

In .NET, both FunctionCallContent.Exception and FunctionResultContent.Exception carry [JsonIgnore] and are never serialized. Python behaves the same way. The Go port instead serialized the error to an Error string and, on unmarshal, fabricated a synthetic errors.New(...) that was never part of the original object graph. That diverges from the other SDKs and reconstructs an error value with a lost type/wrapping that the producer never intended to persist. This change aligns the wire format with .NET/Python: the exception is a local mapping/diagnostic detail, not serialized state.

Tests

  • Added TestFunctionCallContent_ErrorNotSerialized and TestFunctionResultContent_ErrorNotSerialized in message/content_test.go: marshaling a content with a non-nil Error produces JSON with no Error key, and unmarshaling JSON without an Error key yields a nil Error field.
  • Updated TestContentEncoding_Roundtrip to drop the Error it previously set on FunctionResultContent, since that value is intentionally no longer round-tripped.
  • go build ./..., go vet ./message/..., and go test ./message/... all pass.

Copilot AI review requested due to automatic review settings July 23, 2026 05:46
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner July 23, 2026 05:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the stop-serializing-functioncall-result-error branch from db2295b to df7ffef Compare July 23, 2026 08:54
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the stop-serializing-functioncall-result-error branch from df7ffef to bbaf6fd Compare July 23, 2026 15:43
@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 23, 2026
@github-actions

This comment has been minimized.

@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the stop-serializing-functioncall-result-error branch from bbaf6fd to 6985390 Compare July 24, 2026 01:41
@github-actions github-actions Bot added the public-api-change Pull Request changes public APIs label Jul 24, 2026
@github-actions

This comment has been minimized.

.NET marks FunctionCallContent.Exception and FunctionResultContent.Exception
with [JsonIgnore], so they are never persisted. The Go port instead wrote the
error as an Error string and reconstructed a synthetic errors.New on unmarshal,
diverging from .NET/Python and fabricating an error value that was never in the
serialized payload. Drop the Error field from the serialized structs so the
in-memory Error stays informational-only and is not round-tripped.
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the stop-serializing-functioncall-result-error branch from 6985390 to b15a84e Compare July 24, 2026 09:36
@gdams

Copy link
Copy Markdown
Member

PratikDhanave (@PratikDhanave) linter issue

@github-actions

This comment has been minimized.

@gdams

Copy link
Copy Markdown
Member

Copilot fix the failing linter checks

# Conflicts:
#	message/content_test.go
auto-merge was automatically disabled August 20, 2026 11:45

Head branch was pushed to by a user without write access

@github-actions github-actions Bot added area:message Changes files in the message area size:medium At most 100 changed lines across at most 5 files pending-auto-risk Automatic risk classification is in progress labels Aug 20, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added failed-auto-risk Automatic risk classification was inconclusive or failed and removed pending-auto-risk Automatic risk classification is in progress labels Aug 20, 2026
# Conflicts:
#	message/content_test.go
@github-actions github-actions Bot added pending-auto-risk Automatic risk classification is in progress and removed failed-auto-risk Automatic risk classification was inconclusive or failed labels Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Parity Review — ✅ Approved

PR scope: message/content.go — removes Error field from the unexported serializedFunctionCallContent and serializedFunctionResultContent structs, stopping the Go SDK from round-tripping the error through JSON.

Upstream verification:

  • .NET (Microsoft.Extensions.AI.FunctionCallContent / FunctionResultContent): Exception carries [JsonIgnore] and is never included in the wire format. FunctionCallEventGenerator.cs in this repo confirms the framework uses FunctionCallContent from Microsoft.Extensions.AI without any exception serialization.
  • Python (python/packages/core/agent_framework/_workflows/_function_executor.py): no error field is persisted to the message payload; exceptions are runtime-only.

Go contract mapping:

  • Exported FunctionCallContent.Error error and FunctionResultContent.Error error fields remain unchanged — in-memory, diagnostic use only.
  • Serialization/deserialization now omits the Error key in JSON, matching the .NET [JsonIgnore] contract exactly.
  • No exported API signatures were added, removed, or renamed; only observable wire-format behavior changed.

Verdict: This PR restores cross-SDK wire-format parity. The public-api-change label is appropriate because the JSON representation of these types changed (a breaking wire-format fix). No parity issues found — parity-approved label retained.

Generated by Go API Consistency Review Agent · sonnet46 · 27.8 AIC · ⌖ 5.76 AIC · ⊞ 6K ·

@github-actions github-actions Bot added risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:message Changes files in the message area parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs risk:medium Contained production impact requiring normal review depth size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants