Skip to content

fix(visualization): expand handoff() targets in agent graphs - #4517

Merged
seratch merged 2 commits into
openai:mainfrom
hsusul:fix/visualization-expand-handoff-targets
Aug 19, 2026
Merged

seratch merged 2 commits into
openai:mainfrom
hsusul:fix/visualization-expand-handoff-targets

Conversation

@hsusul

@hsusul hsusul commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

This pull request fixes incomplete agent graphs when handoffs use the recommended handoff() factory.

draw_graph already recurses into child agents when handoffs contains an Agent, but Handoff objects were rendered as name-only stubs. That skipped child tools, MCP servers, and "Child" -> "__end__" edges even though handoff() stores a recoverable _agent_ref.

When a live target agent is available, visualization now expands it the same way as an Agent handoff. Handoff objects without a recoverable agent reference stay name-only stubs.

Test plan

  • uv run pytest -q tests/test_visualization.py
  • .agents/skills/code-change-verification/scripts/run.sh
  • Confirmed handoff(child) graphs include child tools and __end__
  • Confirmed stub Handoff objects without _agent_ref remain name-only

Issue number

N/A

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

draw_graph treated handoff() objects as name-only stubs, so child tools
and __end__ edges were missing compared with Agent-in-handoffs graphs.
@seratch seratch added this to the 0.22.x milestone Aug 19, 2026

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this improves the outputs.

@seratch
seratch merged commit 9432f7e into openai:main Aug 19, 2026
17 checks passed
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.

2 participants