Implementation:Microsoft Agent framework WorkflowRunResult Get Outputs
Appearance
Template:Microsoft Agent framework Sidebar
| Property | Value |
|---|---|
| Implementation Name | WorkflowRunResult Get Outputs |
| SDK | Microsoft Agent Framework |
| Repository | Microsoft Agent Framework |
| Source File | python/packages/core/agent_framework/_workflows/_workflow.py
|
| Line Range | L40-96 |
| Import | Returned from workflow.run()
|
| Type | Instance methods on result container |
| Domains | Agent_Architecture, Workflow_Engine |
Overview
The WorkflowRunResult class is the result container returned from a completed workflow execution in the Microsoft Agent Framework. It extends list[WorkflowEvent], storing the full sequence of events emitted during the workflow run. Its key methods -- get_outputs(), get_request_info_events(), and get_final_state() -- provide structured access to the outputs, metadata, and terminal state of the execution.
Code Reference
Source Location
| Property | Value |
|---|---|
| File | python/packages/core/agent_framework/_workflows/_workflow.py
|
| Class | WorkflowRunResult(list[WorkflowEvent])
|
| Lines | 40-96 |
Key Methods
| Method | Return Type | Description |
|---|---|---|
get_outputs() |
list[Any] |
Collects all values yielded via ctx.yield_output() during execution. The default aggregator returns list[Message]; custom aggregators may return any type.
|
get_request_info_events() |
list[WorkflowEvent] |
Returns the subset of events that carry request-level metadata, useful for debugging and observability. |
get_final_state() |
WorkflowRunState |
Returns the terminal state of the workflow run, indicating whether it completed successfully, was cancelled, or encountered an error. |
Import Statement
# WorkflowRunResult is returned from workflow.run(), not imported directly
result = await workflow.run("Create a report")
I/O Contract
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
self |
WorkflowRunResult (extends list[WorkflowEvent]) |
N/A | The result object itself, populated with the complete event stream from a finished workflow execution. |
Outputs
| Method | Return Type | Description |
|---|---|---|
get_outputs() |
list[Any] |
All outputs yielded during workflow execution, aggregated in order. With the default aggregator, each element is a Message. With a custom aggregator, the return type matches the aggregator's output type.
|
get_request_info_events() |
list[WorkflowEvent] |
Workflow events containing request-level metadata (e.g., which agent was invoked, timing information). |
get_final_state() |
WorkflowRunState |
The terminal execution state. Possible values include completed, cancelled, or error states. |
Execution Flow
The WorkflowRunResult methods operate over the stored event list as follows:
get_outputs(): Iterates over allWorkflowEvententries inself, filters for events that represent yielded outputs (produced byctx.yield_output()calls during execution), extracts the output values, and returns them as a list. If a custom aggregator was configured on the workflow, the raw output values are passed through the aggregator before being returned.get_request_info_events(): Filters the event list for events whose type indicates request-level metadata, returning only those events.get_final_state(): Inspects the event list (typically the last event or a dedicated state event) to determine the terminalWorkflowRunStateand returns it.
Usage Examples
Basic Output Extraction
result = await workflow.run("Create a report")
outputs = result.get_outputs()
for output in outputs:
if isinstance(output, list):
for msg in output:
print(f"[{msg.author_name}]: {msg.text}")
state = result.get_final_state()
print(f"Final state: {state}")
Inspecting Request Info Events
result = await workflow.run("Summarize the data")
info_events = result.get_request_info_events()
for event in info_events:
print(f"Event type: {event.type}, data: {event.data}")
Checking Terminal State Before Processing
result = await workflow.run("Process the dataset")
state = result.get_final_state()
if state == WorkflowRunState.COMPLETED:
outputs = result.get_outputs()
print(f"Workflow produced {len(outputs)} outputs")
else:
print(f"Workflow did not complete successfully: {state}")
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment