Description
PR microsoft/agent-framework#3275 fixed the JSON serialization problem in the Agent Framework AG-UI integration, closing microsoft/agent-framework#3239, by serializing tool-call arguments with make_json_safe() before json.dumps().
However, the same unsafe serialization pattern still appears to exist in agent-framework-core observability. In latest agent-framework-core==1.3.0, agent_framework/observability.py::_capture_messages() still serializes OpenTelemetry message payloads with raw json.dumps(...), and the function-call branch keeps raw content.arguments.
I confirmed this is still an issue in the core workflow/request-info path: a workflow request_info event can be converted into function-call arguments containing a dataclass payload, and core observability then fails when _capture_messages() tries to serialize it with raw json.dumps(...).
Evidence from latest release
Package checked:
agent-framework-core==1.3.0
agent-framework-foundry==1.3.0
agent-framework-foundry-hosting==1.0.0a260507
In agent_framework/observability.py:
span.set_attribute(
OtelAttr.OUTPUT_MESSAGES if output else OtelAttr.INPUT_MESSAGES,
json.dumps(otel_messages, ensure_ascii=False),
)
The function_call branch preserves raw arguments:
case "function_call":
return {
"type": "tool_call",
"id": content.call_id,
"name": content.name,
"arguments": content.arguments,
}
There is no make_json_safe(...) and no default=... encoder in this path.
Why this matters
Workflow request_info events can contain framework or dataclass payloads. When those are surfaced as function-call arguments and telemetry captures messages, core observability can raise:
TypeError: Object of type HandoffAgentUserRequest is not JSON serializable
This affects Handoff/workflow scenarios outside the AG-UI adapter path, including Foundry-hosted agent scenarios where telemetry captures messages.
Expected behavior
Core observability should safely serialize message/tool-call payloads that contain dataclasses or framework objects emitted by workflow/handoff request-info flows.
Actual behavior
Core observability still passes raw function-call arguments into json.dumps(...), which can fail for dataclass/framework payloads.
Related issues / PRs
microsoft/agent-framework#3239 reported the AG-UI serialization failure.
microsoft/agent-framework#3275 fixed the AG-UI path by serializing arguments with make_json_safe(content.arguments).
- This issue is about the remaining core observability path in
agent-framework-core.
Description
PR
microsoft/agent-framework#3275fixed the JSON serialization problem in the Agent Framework AG-UI integration, closingmicrosoft/agent-framework#3239, by serializing tool-call arguments withmake_json_safe()beforejson.dumps().However, the same unsafe serialization pattern still appears to exist in
agent-framework-coreobservability. In latestagent-framework-core==1.3.0,agent_framework/observability.py::_capture_messages()still serializes OpenTelemetry message payloads with rawjson.dumps(...), and the function-call branch keeps rawcontent.arguments.I confirmed this is still an issue in the core workflow/request-info path: a workflow
request_infoevent can be converted into function-call arguments containing a dataclass payload, and core observability then fails when_capture_messages()tries to serialize it with rawjson.dumps(...).Evidence from latest release
Package checked:
In
agent_framework/observability.py:The
function_callbranch preserves raw arguments:There is no
make_json_safe(...)and nodefault=...encoder in this path.Why this matters
Workflow
request_infoevents can contain framework or dataclass payloads. When those are surfaced as function-call arguments and telemetry captures messages, core observability can raise:This affects Handoff/workflow scenarios outside the AG-UI adapter path, including Foundry-hosted agent scenarios where telemetry captures messages.
Expected behavior
Core observability should safely serialize message/tool-call payloads that contain dataclasses or framework objects emitted by workflow/handoff request-info flows.
Actual behavior
Core observability still passes raw function-call arguments into
json.dumps(...), which can fail for dataclass/framework payloads.Related issues / PRs
microsoft/agent-framework#3239reported the AG-UI serialization failure.microsoft/agent-framework#3275fixed the AG-UI path by serializing arguments withmake_json_safe(content.arguments).agent-framework-core.