Skip to content

fix(graph_workflow): report node type value in export_summary - #2027

Open
aayushbaluni wants to merge 1 commit into
kyegomez:masterfrom
aayushbaluni:fix/1839-export-summary-node-type
Open

fix(graph_workflow): report node type value in export_summary#2027
aayushbaluni wants to merge 1 commit into
kyegomez:masterfrom
aayushbaluni:fix/1839-export-summary-node-type

Conversation

@aayushbaluni

Copy link
Copy Markdown

Summary

export_summary reports node types as "NodeType.AGENT" instead of the enum value "agent", disagreeing with every other serializer in the file.

This is a follow-up to #2017, which consolidated GraphWorkflow's serialization internals and fixed the round-trip bug from #1839. That work switched the node payload helpers to node.type.value and added _parse_node_type for the legacy spelling. One call site was not converted.

The bug

# swarms/structs/graph_workflow.py, export_summary()
"agents": [
    {
        "id": node.id,
        "type": str(node.type),      # -> "NodeType.AGENT"

NodeType is a str Enum, so str(node.type) renders the repr, not the value. Observed on current master:

export_summary types    : ['NodeType.AGENT', 'NodeType.AGENT']
to_json types           : ['agent', 'agent']

Every other serializer emits the value (_node_payload for to_dict/to_spec, and to_json's own node payload), and from_json parses with _parse_node_type. So the same workflow describes its node types two different ways depending on which method you call.

Scope

This is cosmetic, not a functional break. Nothing deserializes a summary, so unlike #1839 it cannot cause a load failure. It matters because it leaks a Python-internal spelling into user-facing output and is inconsistent with the exports, which is exactly the confusion #1839 started from.

The fix is one line, matching the convention already used elsewhere in the file:

"type": node.type.value,

Testing

Added test_export_summary_reports_node_type_value, which asserts the summary reports "agent" and that it agrees with what the deep export writes for the same nodes.

  • tests/structs/test_graph_workflow.py: 59 passed, 11 skipped (58 passed before, +1 new)
  • Mutation-checked: restoring str(node.type) fails the new test with AssertionError: assert ['NodeType.AGENT', 'NodeType.AGENT'] == ['agent', 'agent'] and leaves the other 58 green, so the test measures the fix rather than decorating it
  • black --line-length 70: clean
  • ruff check swarms/structs/graph_workflow.py: 236 errors before and 236 after, all pre-existing and unrelated, so this adds none

Closes the residual part of #1839. My earlier PR #1898 is closed as superseded by #2017.

`export_summary` built its agent entries with `str(node.type)`, which
renders as "NodeType.AGENT" rather than the enum value "agent".

Every other serializer emits the value: `to_dict`/`to_spec` via the
node payload helper, `to_json` via its own node payload, and
`from_json` parses with `_parse_node_type`. `export_summary` was the
last site still emitting the repr, so the summary disagreed with the
exports for the same workflow and leaked a Python-internal spelling
into user-facing output.

Adds a regression test asserting the summary reports "agent" and
matches what the deep export writes for the same nodes.
@aayushbaluni
aayushbaluni requested a review from kyegomez as a code owner August 25, 2026 05:08
@github-actions

Copy link
Copy Markdown

Hello there, thank you for opening an PR ! 🙏🏻 The team was notified and they will get back to you asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant