Skip to content

Conversation

aperkins1310
Copy link
Contributor

Firstly thanks, this project is super helpful and so I've made a bunch of changes that I'll submit back to upstream to try give back a bit.

The first of which is this, supporting more complex hierarchies of agents. Such as:
Screenshot 2025-08-29 at 13 37 17
This is the existing "supervisor + 2 siblings" 2-layer system:
Screenshot 2025-08-29 at 13 52 05

A few bits of note:

  • The previous behaviour on the UI side relied on "finish_reason != tool_calls", which doesn't work for all models (gemini for example just uses STOP even for tool calls. An explicit handback message makes this work across all models. Also included tests.
  • The previous behaviour on the service side was hardcoded to supervisor, research_expert and math_expert. Now the only requirement is supervisor graphs contain supervisor, and sub agents contain sub-agent in their names. The langgraph_supervisor_hierarchy_agent shows how to handle the "middle" layers, which are both supervisors and sub agents. Included tests for the service behaviour.
  • In order to nest statuses, we need to update streamlit to include Allow nesting expander, columns, popover and chat_message streamlit/streamlit#11272
  • The test_service_e2e test failed locally if you have database settings that would work in the docker compose, but not out. Now we default out the settings when they're imported in memory/__init__.py

- Enhanced service.py to handle sub-agent message filtering
- Added langgraph_supervisor_hierarchy_agent.py with 3-layer hierarchy example
- Added comprehensive test for hierarchical agent message flow
- Updated test fixtures for better import handling

This builds on upstream's basic subgraph support (2e6c622) by adding:
- Sophisticated node detection for supervisors and sub-agents
- Proper message handling for handback tools and results
- Support for nested agent hierarchies with proper naming conventions
Enhanced Streamlit UI to properly display nested agent hierarchies:

- Different visual indicators for sub-agents (💼) vs tools (🛠️)
- Recursive handling of nested sub-agent transfers
- Proper status container management for multi-level hierarchies
- Support for transfer_back_to handoff messages
- Expanded status containers for better visibility
- Updated tests to match new UI labels

This complements the service layer changes by providing a clear
visual representation of complex agent hierarchies in the UI.
Added test fixtures and test cases to validate:
- Multi-agent message fixtures for reusable test data
- Hierarchical sub-agent UI rendering with proper status containers
- Visual indicators (💼 for sub-agents, 🛠️ for tools)
- Popover functionality for tool calls within sub-agents
- Proper message flow through transfer_to/transfer_back_to patterns

These tests ensure the UI correctly displays complex agent hierarchies
with proper visual organization and user experience.
Added three critical test patterns for hierarchical sub-agents:

1. test_app_streaming_single_sub_agent:
   - Tests single sub-agent with multiple tool calls
   - Validates popover functionality for tools within sub-agents
   - Ensures proper status container organization

2. test_app_streaming_sequential_sub_agents:
   - Tests supervisor -> agent A -> supervisor -> agent C -> supervisor flow
   - Validates sequential agent handoffs with proper UI separation
   - Ensures multiple status containers are handled correctly

3. test_app_streaming_nested_sub_agents:
   - Tests true nesting: supervisor -> agent A -> agent B -> agent A -> supervisor
   - Validates recursive status container nesting
   - Ensures proper visual hierarchy for deeply nested agents

These tests provide comprehensive coverage of all hierarchical patterns
and ensure the UI correctly handles complex multi-agent workflows.
@JoshuaC215
Copy link
Owner

I’m traveling the next few days but will take a look at this next week, thanks!

Copy link

codecov bot commented Aug 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.34%. Comparing base (28e3df9) to head (18effc3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Coverage Δ
src/agents/agents.py 100.00% <100.00%> (ø)
src/agents/langgraph_supervisor_agent.py 85.71% <ø> (+7.14%) ⬆️
src/agents/langgraph_supervisor_hierarchy_agent.py 100.00% <100.00%> (ø)
src/service/service.py 82.50% <100.00%> (+3.00%) ⬆️
src/streamlit_app.py 75.09% <100.00%> (+13.95%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoshuaC215
Copy link
Owner

This is awesome!! Thank you @aperkins1310 !!!

@JoshuaC215 JoshuaC215 merged commit 3b6f962 into JoshuaC215:main Sep 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants