Repository navigation
Description
Observed Behavior
When a function tool returns a dataclass, an Enum member or a set (or a dict/list that contains one of them), the text sent back to the model is the Python repr instead of JSON. For example an Enum value reaches the model as "Color.RED" and a dataclass as "Point(x=1)", so the model sees Python syntax rather than the actual values.
Expected Behavior
These should be converted to JSON values like Pydantic model results already are since #9036: Enum -> its value ("red"), dataclass -> a JSON object ({"x": 1}), set -> a JSON array (["a"]).
Steps to Reproduce
- Define a tool result containing an Enum, a dataclass or a set.
- Pass it through
FunctionTool.parse_result(this is whatFunctionTool.invokedoes with the return value). - Look at the text of the returned content.
Minimal Reproduction
from dataclasses import dataclass
from enum import Enum
from agent_framework import FunctionTool
class Color(Enum):
RED = "red"
@dataclass
class Point:
x: int
print(FunctionTool.parse_result({"color": Color.RED})[0].text) # {"color": "Color.RED"}
print(FunctionTool.parse_result(Point(x=1))[0].text) # "Point(x=1)"
print(FunctionTool.parse_result({"tags": {"a"}})[0].text) # {"tags": "{'a'}"}Error Messages and Stack Traces
No error. The output is just the repr strings shown above.
Package Versions
agent-framework-core: main (22b5e75)
Python Version
Python 3.13
Operating System
Linux
Regression
No
Additional Context
_make_dumpable handles Pydantic models (JSON mode, from #9036) and Content, but other objects fall through to json.dumps(..., default=str), so dataclasses, Enum members and sets end up as str() of the object. The same Color.RED inside a Pydantic model already becomes "red", but outside a model it doesn't. The parse_result docstring also says arbitrary objects are serialized to JSON text.
A possible fix is to convert dataclasses (recursively), Enum members (to .value) and sets/frozensets (to lists) in _make_dumpable before json.dumps. I have this with a test locally and can open a PR once the direction is agreed.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Nov 11, 2026
Reproduced on main (22b5e75) with a minimal script based on the report:
FunctionTool.parse_resultreturns{"color": "Color.RED"},"Point(x=1)"and{"tags": "{'a'}"}— Python reprs rather than JSON values. Run: https://github.com/microsoft/agent-framework/actions/runs/43079857465Support boundary: unclear. The
parse_resultdocstring suggests arbitrary objects are serialized to JSON, but I found no spec or decision record setting the scope, so a maintainer should decide. Routed to theagent-framework-coreowner. Maintainers decide on acceptance and priority.