LangGraphScore Conditional Outputs Override by Top-Level Output Mappings
Summary
LangGraphScore configurations with conditional outputs are being overridden by top-level output mappings, causing incorrect score results. When a node's conditions should trigger specific output values (e.g., value: "Yes"), the final result shows the classification value instead (e.g., value: "Computer_With_Internet").
Environment
- Plexus Version: Latest main branch
- Python Version: 3.11
- Affected Component:
plexus/scores/LangGraphScore.py
Bug Description
Expected Behavior
When a LangGraphScore has a node with conditions that route to END and specify conditional outputs, those outputs should be preserved in the final result, taking precedence over any top-level output mappings.
Actual Behavior
Top-level output mappings (e.g., value: classification) override conditional outputs, causing incorrect results to be returned.
Reproduction Case
Score Configuration
# Simplified example based on "Computer w/ Internet" score (scorecard 1039, score 45417)
output:
value: classification # This is overriding conditional outputs
nodes:
device_response_analyzer:
type: Classifier
prompt: "Classify if device has internet access"
classes:
- Computer_With_Internet
- Computer_Without_Internet
- Mobile_Device
conditions:
Computer_With_Internet:
target: END
output:
value: "Yes" # This should be the final value
explanation: "Computer with internet access detected"
Test Input
Any input that gets classified as "Computer_With_Internet"
Expected Output
{
"value": "Yes",
"explanation": "Computer with internet access detected",
"classification": "Computer_With_Internet"
}
Actual Output
{
"value": "Computer_With_Internet", // ❌ Wrong - should be "Yes"
"explanation": "Computer with internet access detected",
"classification": "Computer_With_Internet"
}
Steps to Reproduce
-
Create a LangGraphScore with:
- A node that has conditions routing to END
- Conditional outputs that set specific values
- Top-level output mapping (e.g.,
value: classification)
-
Run a prediction that triggers the condition
-
Observe that the final result uses the top-level output mapping instead of the conditional output
Technical Analysis
Root Cause
In plexus/scores/LangGraphScore.py, the add_edges method appears to have issues with conditional routing logic:
- Final Node Conditions: Conditions on final nodes may not be properly processed
- Conditional Routing: The routing from conditional nodes to END may not preserve conditional outputs
- Output Priority: Top-level output mappings are taking precedence over conditional outputs
Code Location
The issue is in the add_edges method of the LangGraphScore class, specifically around line areas that handle:
- Conditional edge creation
- Final node processing
- Output aliasing logic
Impact
Severity: High
This bug affects the core functionality of LangGraphScore conditional logic, causing incorrect classification results.
Affected Scores
Any LangGraphScore that uses:
- Conditional routing to END
- Conditional outputs that differ from top-level mappings
- Multiple nodes with conditions
Business Impact
- Incorrect score results in production
- Potential misclassification of important data
- Unreliable conditional logic in complex scoring workflows
Additional Context
Real-World Example
The "Computer w/ Internet" score in production is affected:
- Scorecard ID: 1039
- Score ID: 45417
- Symptom: Returns
"Computer_With_Internet" instead of "Yes"
Testing Suggestions
- Create unit tests with single-node conditional scenarios
- Test multi-node workflows with conditions on middle nodes
- Test final node conditions routing to END
- Verify output precedence rules
Debugging Information
When testing predictions with the affected score:
# Using MCP service to test
plexus_predict(
scorecard_name="Computer w/ Internet",
score_name="Computer w/ Internet",
item_id="test_item"
)
Proposed Investigation Steps
- Code Review: Examine the
add_edges method for conditional routing logic
- Debug Logging: Add comprehensive logging to trace output value precedence
- Unit Tests: Create regression tests for various conditional scenarios
- Integration Testing: Test with real score configurations
Related Files
plexus/scores/LangGraphScore.py - Main implementation
plexus/scores/LangGraphScore_test.py - Test file for adding regression tests
Labels Suggestion
bug
high-priority
scoring
langgraph
Note: This bug affects the reliability of conditional scoring logic and should be prioritized for investigation and resolution.
LangGraphScore Conditional Outputs Override by Top-Level Output Mappings
Summary
LangGraphScore configurations with conditional outputs are being overridden by top-level output mappings, causing incorrect score results. When a node's conditions should trigger specific output values (e.g.,
value: "Yes"), the final result shows the classification value instead (e.g.,value: "Computer_With_Internet").Environment
plexus/scores/LangGraphScore.pyBug Description
Expected Behavior
When a LangGraphScore has a node with conditions that route to END and specify conditional outputs, those outputs should be preserved in the final result, taking precedence over any top-level output mappings.
Actual Behavior
Top-level output mappings (e.g.,
value: classification) override conditional outputs, causing incorrect results to be returned.Reproduction Case
Score Configuration
Test Input
Any input that gets classified as "Computer_With_Internet"
Expected Output
{ "value": "Yes", "explanation": "Computer with internet access detected", "classification": "Computer_With_Internet" }Actual Output
{ "value": "Computer_With_Internet", // ❌ Wrong - should be "Yes" "explanation": "Computer with internet access detected", "classification": "Computer_With_Internet" }Steps to Reproduce
Create a LangGraphScore with:
value: classification)Run a prediction that triggers the condition
Observe that the final result uses the top-level output mapping instead of the conditional output
Technical Analysis
Root Cause
In
plexus/scores/LangGraphScore.py, theadd_edgesmethod appears to have issues with conditional routing logic:Code Location
The issue is in the
add_edgesmethod of theLangGraphScoreclass, specifically around line areas that handle:Impact
Severity: High
This bug affects the core functionality of LangGraphScore conditional logic, causing incorrect classification results.
Affected Scores
Any LangGraphScore that uses:
Business Impact
Additional Context
Real-World Example
The "Computer w/ Internet" score in production is affected:
"Computer_With_Internet"instead of"Yes"Testing Suggestions
Debugging Information
When testing predictions with the affected score:
Proposed Investigation Steps
add_edgesmethod for conditional routing logicRelated Files
plexus/scores/LangGraphScore.py- Main implementationplexus/scores/LangGraphScore_test.py- Test file for adding regression testsLabels Suggestion
bughigh-priorityscoringlanggraphNote: This bug affects the reliability of conditional scoring logic and should be prioritized for investigation and resolution.