Conversation
Implements a two-model HITL system for intelligent human intervention: 1. WHEN-TO-TRIGGER MODEL (Small LLM) - Takes raw user query as input - Returns decision (TRIGGER/NO_TRIGGER), confidence score, and reasons - Detects: budget constraints, missing origin, market volatility, budget exceeded 2. WHAT-TO-RESPOND MODEL (Small LLM) - Takes user query + trigger output - Generates allocation scenarios with cost/quality analysis - Provides recommendations and rationale New files: - hitl.py: Model interfaces, data classes, and mock implementations - graph_hitl.py: LangGraph with interrupt() support for async human review - api_hitl.py: REST endpoints for HITL workflow (/agent/prompt/hitl, /resume) Flow: 1. User query -> WHEN-TO-TRIGGER model -> if confidence >= 65% 2. WHAT-TO-RESPOND model generates scenarios 3. interrupt() pauses execution, returns options to caller 4. Human reviews and selects scenario 5. resume() continues execution with human decision Mock implementations ready for real model integration via HITLModelFactory.
…onses - Strip trailing whitespace from farm inventory responses to avoid Bedrock Claude error: 'final assistant content cannot end with trailing whitespace' - Applied fix to both single farm and all farms inventory nodes
- Add HITLScenarios component for displaying HITL options to user - Add useHITLAPI hook for HITL API interactions - Update ChatArea to integrate HITL flow and scenario selection - Update App.tsx with HITL state management and callbacks - Add PUBLISH_SUBSCRIBE_HITL pattern to patternUtils - Add Human-in-the-Loop section to Sidebar navigation
shkurapa
requested review from
Shridhar-2205,
codyhartsook,
shanchunyang0919 and
therealaditigupta
as code owners
January 20, 2026 23:41
Based on code review standards: Documentation: - Enhanced file headers with purpose, architecture, and example usage - Added comprehensive docstrings with Args/Returns sections - Added inline comments explaining complex logic Type Hints: - Added return type hints (Dict[str, Any]) to node methods - Added Optional type hints for nullable variables Exception Handling: - Changed logger.error to logger.exception for full tracebacks - Include exception type in error messages for debugging Testing: - Added test_hitl.py with pytest unit tests - Tests cover data models, mock model inference, and integration - Includes fixtures for reusable test data Variable Naming: - Renamed loop variable 'f' to 'farm_name' for clarity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a Human-in-the-Loop (HITL) system for the Lungo auction supervisor, enabling human oversight for high-stakes order decisions using LangGraph's
interrupt()capability.Overview
The HITL system uses two specialized models to determine when and how to involve humans in the decision-making process:
Key Features
New Files
Backend:
agents/supervisors/auction/graph/hitl.py- Model interfaces and mock implementationsagents/supervisors/auction/graph/graph_hitl.py- HITL-enabled LangGraph with interrupt nodesagents/supervisors/auction/api_hitl.py- REST endpoints for HITL workflow (/agent/prompt/hitl,/agent/prompt/hitl/resume)Frontend:
frontend/src/hooks/useHITLAPI.ts- React hook for HITL API interactionsfrontend/src/components/Chat/HITLScenarios.tsx- Scenario display and selection componentModified Files
agents/supervisors/auction/main.py- Include HITL routerfrontend/src/App.tsx- HITL state managementfrontend/src/components/Chat/ChatArea.tsx- HITL flow integrationfrontend/src/components/Sidebar/Sidebar.tsx- New "Human-in-the-Loop" navigation sectionfrontend/src/utils/patternUtils.ts- AddedPUBLISH_SUBSCRIBE_HITLpatternGraph Flow
Example Usage
Prompt:
I need to place our Q2 order. 500 lbs total, budget capped at $2,000. What are our options?The system:
Testing
Select "Human-in-the-Loop > A2A NATS (HITL)" in the sidebar and try the example prompt above.