Skip to content

[dotnet-port] Align tool approval response snapshots#279

Merged
qmuntal merged 2 commits into
mainfrom
dotnet-port/toolapproval-response-snapshot-d0ab1b00261fc990
Jun 11, 2026
Merged

[dotnet-port] Align tool approval response snapshots#279
qmuntal merged 2 commits into
mainfrom
dotnet-port/toolapproval-response-snapshot-d0ab1b00261fc990

Conversation

@qmuntal

@qmuntal qmuntal commented Jun 11, 2026

Copy link
Copy Markdown
Member

Snapshot tool-call content when creating approval responses so the approved call remains stable if the original request content is mutated before execution or serialization. This mirrors the upstream .NET workflow approval snapshot behavior from microsoft/agent-framework#6427.

Snapshot tool-call content when creating approval responses so the approved call remains stable if the original request content is mutated before execution or serialization. This mirrors the upstream .NET workflow approval snapshot behavior from microsoft/agent-framework#6427.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 11, 2026 11:57
@qmuntal
qmuntal requested a review from a team as a code owner June 11, 2026 11:57
@qmuntal qmuntal linked an issue Jun 11, 2026 that may be closed by this pull request
@qmuntal
qmuntal enabled auto-merge (squash) June 11, 2026 11:58

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.

Pull request overview

This PR updates tool-approval response creation to snapshot (clone) tool-call content and relevant headers at the time the approval response is created, so later mutations to the original request/tool-call object don’t change what ultimately gets approved/serialized—aligning behavior with the referenced upstream .NET workflow.

Changes:

  • Clone ToolApprovalRequestContent.ToolCall when building an approval response to make approvals stable against later mutations.
  • Clone ContentHeader.AdditionalProperties and Annotations when building approval responses.
  • Add tests validating snapshot behavior for both FunctionCallContent and MCPServerToolCallContent.
Show a summary per file
File Description
message/content.go Clones tool-call content and header fields when creating tool-approval responses.
message/content_test.go Adds tests ensuring approval responses are unaffected by subsequent mutations to the original tool call/request.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread message/content.go
Comment thread message/content.go
@qmuntal
qmuntal disabled auto-merge June 11, 2026 12:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@qmuntal
qmuntal enabled auto-merge (squash) June 11, 2026 12:07
@qmuntal
qmuntal merged commit 5c7226e into main Jun 11, 2026
13 checks passed
@qmuntal
qmuntal deleted the dotnet-port/toolapproval-response-snapshot-d0ab1b00261fc990 branch June 11, 2026 12:18
@github-actions

Copy link
Copy Markdown
Contributor

API Consistency Review: ✅ Aligned

Changed surface: (*ToolApprovalRequestContent).CreateResponse in message/content.go

What changed: CreateResponse now defensively clones the ToolCall content and shallow-copies ContentHeader.AdditionalProperties and Annotations into the returned ToolApprovalResponseContent, ensuring the approval response is stable if the caller mutates the original request object after calling this method. The PR also fixes a latent gap where Annotations and RawRepresentation were silently dropped from the response's ContentHeader.

Parity check vs .NET (microsoft/agent-framework):

The referenced upstream PR #6427 added snapshot behavior at the declarative executor layer (InvokeFunctionToolExecutor), persisting evaluated function parameters to workflow state before a checkpoint so they survive restore cycles. That is a different, complementary mechanism. The underlying ToolApprovalRequestContent.CreateResponse in .NET (from Microsoft.Extensions.AI) does not itself clone the ToolCall — the Go SDK is choosing to enforce copy isolation one level lower (at the factory method), which is both a valid Go idiom and consistent with the semantic goal (approved tool-call state must not change after approval is issued).

Parity check vs Python (microsoft/agent-framework):

Python does not have a ToolApproval harness equivalent in the framework today. No divergence to flag.

No parity issues found. The implementation approach is intentionally language-idiomatic (Go value-copy semantics, maps.Clone/slices.Clone) and semantically aligned with the .NET snapshot intent.

Generated by Go API Consistency Review Agent for issue #279 · sonnet46 1.9M ·

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.

[dotnet-port] Align tool approval response snapshots

3 participants