Context
Tools that aggregate from multiple sources or steps.
Problem
Complete failure hides successful partial results.
Solution
Degrade gracefully:
- Return what worked: Don't discard successes
- Note what failed: Explain gaps
- Indicate completeness: Partial vs full
- Suggest remediation: How to get the rest
- Return what worked: Don't discard successes
- Note what failed: Explain gaps
- Indicate completeness: Partial vs full
- Suggest remediation: How to get the rest
Examples
Python
@tool
def get_unified_profile(user_id: str) -> UnifiedProfile:
"""Get user profile from multiple sources.
Returns partial data if some sources fail.
"""
profile = UnifiedProfile()
errors = []
try:
profile.crm_data = crm_api.get_user(user_id)
except Exception as e:
errors.append(f"CRM unavailable: {e}")
try:
profile.email_data = email_api.get_user(user_id)
except Exception as e:
errors.append(f"Email service unavailable: {e}")
profile.completeness = "full" if not errors else "partial"
profile.errors = errors or None
profile.retry_hint = "Call again later to get missing data" if errors else None
return profile Considerations
- Always return something useful if possible
- Clearly indicate what's missing
- Provide retry guidance for missing parts