Repository navigation
Add typed execute-tool schema payloads - #267
Merged
Hector Hernandez (hectorhdzg) merged 21 commits intoSep 24, 2026
Merged
Hector Hernandez (hectorhdzg) merged 21 commits into
Hector Hernandez (hectorhdzg) merged 21 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The tox mypy commands already pass --ignore-missing-imports, so the msal section was unnecessary and unrelated to the execute-tool schema feature. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Serialization of typed execute-tool payloads is now non-throwing and matches the .NET contract (PR microsoft/opentelemetry-distro-dotnet#149). Any per-value failure, reference cycle, unsupported type, non-finite float (allow_nan=False), undefined enum token, or extension-data collision replaces the payload with the diagnostic object {"serialization_error":"Failed to serialize execute tool payload."} instead of leaking an exception or orphaning the span. Disabled telemetry paths are safe for the same reason. None is now omitted only for model properties; None inside caller-supplied mappings and lists is preserved as JSON null. Bytes serialize as base64, datetime/date/time as ISO-8601, UUID and enums as their string values, and Decimal as a JSON number. Adds public ToolCallAction, ToolCallOutcomeStatus, and ToolPolicyDecision str enums matching .NET. Typed enum fields accept enum members and the exact lowercase tokens for backward compatibility, rejecting undefined, mis-cased, numeric, boolean, and foreign-enum values. Extension-data collisions are checked only against properties that are actually serialized, so extension data may supply a key whose model property is None while still being rejected when it would overwrite a present property. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…modes Covers the ToolCallAction, ToolCallOutcomeStatus, and ToolPolicyDecision tokens, the accepted exact lowercase strings, null retention inside caller mappings and lists, extension-data collision rules, and the non-throwing diagnostic payload. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ections Raw dictionary arguments and results now share the diagnostic fallback with the typed models, matching .NET PR microsoft/opentelemetry-distro-dotnet#149 where the dictionary overloads also route through MessageUtils.SerializeToolPayload. Previously a cyclic or otherwise unserializable dictionary raised out of ExecuteToolScope.start(), leaving the span started but never ended. The existing safe_json_dumps output is unchanged for payloads that already serialized. Typed payload serialization now emits sets, frozensets, and other sized collections as JSON arrays instead of discarding the whole payload, matching how .NET writes any IEnumerable value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Performance comparisonThreshold: regressions >15.0% on gating scenarios fail the build. Higher ops/s is better; positive Δ means the PR is slower.
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Nikhil Navakiran (nikhilNava)
marked this pull request as ready for review
September 15, 2026 18:52
Copilot started reviewing on behalf of
Nikhil Navakiran (nikhilNava)
September 15, 2026 18:55
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Three moderate serialization issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds typed Agent365 execute-tool schema models, enums, nested metadata, serialization, telemetry integration, tests, and documentation while preserving raw payload support.
Changes:
- Adds versioned argument/result models and public exports.
- Integrates typed payload serialization into tool scopes.
- Adds tests, documentation, and changelog updates.
- Three moderate serialization issues remain in
tool_call_schema.py: enum validation bypass viaextension_data(1 vote), Decimal precision loss (3 votes), and UTC timestamp formatting mismatch (1 vote).
File summaries
| File | Summary |
|---|---|
tests/a365/test_tool_call_schema.py |
Tests schema serialization behavior. |
tests/a365/test_execute_tool_scope.py |
Tests scope integration and failure handling. |
src/microsoft/opentelemetry/a365/README.md |
Lists the new model module. |
src/microsoft/opentelemetry/a365/core/tool_call_details.py |
Adds typed argument support. |
src/microsoft/opentelemetry/a365/core/models/tool_call_schema.py |
Defines typed models and serializer; contains the three moderate issues noted above. |
src/microsoft/opentelemetry/a365/core/execute_tool_scope.py |
Serializes typed and raw tool payloads. |
src/microsoft/opentelemetry/a365/core/__init__.py |
Exposes the new public API. |
README.md |
Adds usage overview. |
CHANGELOG.md |
Records the unreleased feature. |
A365_DOCUMENTATION.md |
Documents the schema contract. |
Review details
Suppressed comments (2)
src/microsoft/opentelemetry/a365/core/models/tool_call_schema.py:297
- Enum validation can be bypassed through
extension_datawhenever the typed property isNone: for example,ExecuteToolCallArguments(extension_data={"action": "write"})emitsaction: "write", even though the documented enum contract says undefined tokens are rejected. When an extension key matches a declared enum field, validate it with_coerce_enum(while still allowing valid tokens) instead of serializing it as an arbitrary value.
for key, item_value in extension_data.items():
json_key = _json_object_key(key)
if json_key in serialized:
raise ValueError(f"Extension data cannot overwrite execute tool payload property '{json_key}'.")
serialized[json_key] = _to_json_value(item_value, stack)
src/microsoft/opentelemetry/a365/core/models/tool_call_schema.py:202
datetime.isoformat()renders a UTC-aware value with+00:00, whereas the parity implementation'sSystem.Text.Jsonserialization emits UTCDateTimevalues with theZdesignator. A timestamp indataor extension data therefore produces a different execute-tool payload (the added test currently locks in+00:00); normalize UTC-aware datetimes to the contract'sZform and add a regression case.
def _to_isoformat(value: datetime.datetime | datetime.date | datetime.time) -> str:
"""Return the ISO-8601 text for a date/time value."""
return value.isoformat()
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Hector Hernandez (hectorhdzg)
approved these changes
Sep 24, 2026
Jackson Weber (JacksonWeber)
approved these changes
Sep 24, 2026
Hector Hernandez (hectorhdzg)
merged commit Sep 24, 2026
10cf953
into
microsoft:main
12 checks passed
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.
Summary
Python parity for the non-ETW behavior in microsoft/opentelemetry-distro-dotnet#149.
Validation
Compatibility Note
The JSON wire contract now wraps provider-specific extension values under metadata. The corresponding .NET, JavaScript, schema, and downstream parser updates must roll out as a coordinated contract change.