This document demonstrates the new score-configs apply functionality with comprehensive value validation.
Apply a score configuration to traces or sessions with automatic validation:
# Apply to a trace
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value "Very Helpful"
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value 4
# Apply to a session
coaia fuse score-configs apply "Quality Check" --session-id xyz789 --value true
coaia fuse score-configs apply "Quality Check" --session-id xyz789 --value "yes"
# Apply to trace with observation and comment
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --observation-id obs456 --value 8.5 --comment "High accuracy result"
# Using config ID instead of name
coaia fuse score-configs apply --config-id cfg-123 --session-id xyz789 --value false# List all available configs
coaia fuse score-configs available
# Filter by category
coaia fuse score-configs available --category narrative
# Show only cached configs (faster)
coaia fuse score-configs available --cached-only
# JSON output
coaia fuse score-configs available --json# Show basic config info
coaia fuse score-configs show "Helpfulness"
# Show with validation requirements
coaia fuse score-configs show "Helpfulness" --requirements
# JSON output
coaia fuse score-configs show "Accuracy Score" --json# Apply score to trace
coaia fuse scores apply --trace-id abc123 --name "Custom Score" --value 7.5
# Apply score to session
coaia fuse scores apply --session-id xyz789 --score-id score-123 --value 8.0 --comment "Good performance"
# Apply to specific observation
coaia fuse scores apply --trace-id abc123 --observation-id obs456 --name "Quality" --value 9.0# These will work:
coaia fuse score-configs apply "Pass/Fail" --trace-id abc123 --value true
coaia fuse score-configs apply "Pass/Fail" --trace-id abc123 --value "false"
coaia fuse score-configs apply "Pass/Fail" --trace-id abc123 --value 1
coaia fuse score-configs apply "Pass/Fail" --trace-id abc123 --value "yes"
coaia fuse score-configs apply "Pass/Fail" --trace-id abc123 --value "off"
# This will fail with helpful error:
coaia fuse score-configs apply "Pass/Fail" --trace-id abc123 --value "maybe"
# Error: Invalid boolean value 'maybe'. Use true/false, 1/0, yes/no, or on/off# These will work (by value):
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value 4
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value "3"
# These will work (by label, case-insensitive):
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value "Very Helpful"
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value "helpful"
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value "NOT HELPFUL"
# This will fail with helpful error showing valid options:
coaia fuse score-configs apply "Helpfulness" --trace-id abc123 --value "amazing"
# Error: Invalid categorical value 'amazing'. Valid options: 'Not Helpful' (1), 'Somewhat Helpful' (2), 'Helpful' (3), 'Very Helpful' (4), 'Extremely Helpful' (5)# These will work (within range 0.0-10.0):
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value 5.5
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value "8"
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value 0.0
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value "10.0"
# These will fail with range information:
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value -1
# Error: Value -1.0 is below minimum. Valid range: 0.0 to 10.0
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value 15
# Error: Value 15.0 is above maximum. Valid range: 0.0 to 10.0
coaia fuse score-configs apply "Accuracy Score" --trace-id abc123 --value "not-a-number"
# Error: Invalid numeric value 'not-a-number'. Must be a numberThe system uses smart caching to optimize performance:
- Cache-first retrieval: Checks project cache before API calls
- Auto-refresh: Refreshes stale cache entries automatically
- Cache management: Updates cache after successful API calls
- Project-aware: Maintains separate cache per Langfuse project
Comprehensive error messages help users understand validation requirements:
- Config not found: Clear message when configuration doesn't exist
- Validation errors: Detailed explanation of why value was rejected
- Target validation: Ensures exactly one of trace-id or session-id is specified
- Type-specific guidance: Shows valid options for categorical, range for numeric, formats for boolean
- Seamless integration: Uses existing
create_score_for_target()function - Backward compatibility: All existing score commands continue to work
- Enhanced functionality: Existing
scores applynow supports sessions - Consistent patterns: Follows established CLI argument patterns
- Smart caching: Reduces API calls through intelligent caching
- Batch operations: Cache warming reduces latency for multiple operations
- Local validation: Client-side validation prevents unnecessary API calls
- Efficient lookups: Name-to-ID resolution cached locally
- Interactive scoring: Quick manual scoring with validation feedback
- Automated workflows: Script-based scoring with error handling
- Batch processing: Apply multiple scores efficiently using cached configs
- Quality assurance: Validate score values before submission
- Team collaboration: Share and reuse score configurations consistently