Skip to content

Preserve structured JsonElement tool arguments in GitHub Copilot agent events#5

Merged
kzu merged 2 commits intotooleventsfrom
copilot/add-raw-jsonelement-support
Mar 24, 2026
Merged

Preserve structured JsonElement tool arguments in GitHub Copilot agent events#5
kzu merged 2 commits intotooleventsfrom
copilot/add-raw-jsonelement-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 24, 2026

Motivation and Context

Nested tool arguments from Copilot tool execution events were being flattened into raw JSON strings. That breaks structured round-tripping through the AG-UI event pipeline by double-encoding object/array arguments.

Description

  • Argument preservation

    • Keep JsonValueKind.Object and JsonValueKind.Array as cloned JsonElement values instead of converting them to GetRawText().
    • Treat JsonValueKind.Undefined as null to avoid emitting ambiguous payloads.
  • Behavioral impact

    • Primitive values continue to map as before.
    • Structured tool arguments now serialize downstream as JSON objects/arrays rather than stringified JSON blobs.
  • Coverage

    • Update the existing unit test to assert object and array arguments remain structured JsonElement values.
arguments[property.Name] = property.Value.ValueKind switch
{
    JsonValueKind.Object => property.Value.Clone(),
    JsonValueKind.Array => property.Value.Clone(),
    JsonValueKind.Undefined => null,
    _ => /* existing primitive handling */
};

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@kzu kzu marked this pull request as ready for review March 24, 2026 16:24
@kzu kzu merged commit 90b9659 into toolevents Mar 24, 2026
0 of 2 checks passed
kzu added a commit that referenced this pull request Mar 28, 2026
…t events (#5)

* Implement raw JsonElement argument handling

Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kzu/agent-framework/sessions/ca9509f7-6318-4f1a-8ba2-17e4207bc7c4

* Fix test validation and preserve structured JSON args

Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kzu/agent-framework/sessions/ca9509f7-6318-4f1a-8ba2-17e4207bc7c4

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
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.

2 participants