microsoft / microsoft/promptflow
[Feature Request] Make flow output json dump configurable to allow object as output
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.2k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
I want to return an class as output for the python tool however it shows error JSON dump failed: For example for the following code:
it will return an error
@dataclass
class ThoughtStep:
title: str
description: Optional[Any]
props: Optional[dict[str, Any]] = None
# The inputs section will change based on the arguments of the tool function, after you save the code
# Adding type to arguments and return value will help the system show the types properly
# Please update the function name/signature per need
@tool
def my_python_tool(zone_instruction: str, modify_query:str, answer_question:str) -> list:
thought_steps = [
ThoughtStep(title="Look up Zone Instruction", description=zone_instruction, props=None),
ThoughtStep(title="Modify the query with history and zone instruction", description=modify_query, props=None),
ThoughtStep(title="Search relevant documentation", description=None, props=None),
ThoughtStep(title="Answer the questions", description=answer_question, props=None)
]
return thought_steps
Describe the solution you'd like
Allow option to inject how to serialise an complex object
Describe alternatives you've considered
My current work around is to manually use jsonoutput = json.dumps(thought_steps, default=lambda o: o.dict) inside the pythong tool and return a string instead
Additional context
Happy to connect to explain in more detail if it helps
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python tool output failure with the provided ThoughtStep dataclass and trace where flow output serialization rejects the returned object. Define how callers can provide serialization behavior, then verify complex objects can be returned without the manual json.dumps workaround while existing outputs continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100