|
1 | 1 | # Frequently Asked Questions |
2 | 2 |
|
3 | | -**Last Updated:** January 7, 2026 |
4 | | -**Version:** 3.9.1 |
| 3 | +**Last Updated:** January 9, 2026 |
| 4 | +**Version:** 3.10.0 |
5 | 5 |
|
6 | 6 | --- |
7 | 7 |
|
|
11 | 11 | 2. [Teaching AI Your Standards](#teaching-ai-your-standards) |
12 | 12 | 3. [Tool Compatibility](#tool-compatibility) |
13 | 13 | 4. [Implementation](#implementation) |
14 | | -5. [Results & ROI](#results--roi) |
15 | | -6. [Common Concerns](#common-concerns) |
16 | | -7. [Advanced Topics](#advanced-topics) |
| 14 | +5. [Cost Optimization](#cost-optimization) |
| 15 | +6. [Results & ROI](#results--roi) |
| 16 | +7. [Common Concerns](#common-concerns) |
| 17 | +8. [Advanced Topics](#advanced-topics) |
17 | 18 |
|
18 | 19 | --- |
19 | 20 |
|
@@ -391,6 +392,159 @@ Code review finds: bare except: |
391 | 392 |
|
392 | 393 | --- |
393 | 394 |
|
| 395 | +## Cost Optimization |
| 396 | + |
| 397 | +### What is intelligent tier fallback? |
| 398 | + |
| 399 | +**NEW in v3.10.0:** Automatic cost optimization that tries cheaper tiers first and only upgrades when quality gates fail. |
| 400 | + |
| 401 | +**How it works:** |
| 402 | +1. Start with CHEAP tier (Haiku - $0.03/1M tokens) |
| 403 | +2. Validate output with quality gates |
| 404 | +3. If validation fails → upgrade to CAPABLE (Sonnet 4.5 - $0.09/1M) |
| 405 | +4. Still failing? → upgrade to PREMIUM (Opus 4.5 - $0.45/1M) |
| 406 | +5. Track savings and learn from patterns |
| 407 | + |
| 408 | +**Enable it:** |
| 409 | +```bash |
| 410 | +empathy workflow run health-check --use-recommended-tier |
| 411 | +``` |
| 412 | + |
| 413 | +**Expected savings:** 30-50% on average workflow execution |
| 414 | + |
| 415 | +**Learn more:** [CHANGELOG.md v3.10.0](../CHANGELOG.md#3100---2026-01-09) |
| 416 | + |
| 417 | +--- |
| 418 | + |
| 419 | +### When should I use tier fallback? |
| 420 | + |
| 421 | +**✅ Use tier fallback when:** |
| 422 | +- Cost is a primary concern |
| 423 | +- Workflow has measurable quality metrics (health score, test coverage) |
| 424 | +- CHEAP tier often succeeds (simple refactoring, docs, health checks) |
| 425 | +- You can tolerate 2-3x latency increase on quality failures |
| 426 | +- You want automatic cost optimization |
| 427 | + |
| 428 | +**❌ Don't use tier fallback when:** |
| 429 | +- Time is critical (tier upgrades add latency) |
| 430 | +- Quality gates are hard to define |
| 431 | +- PREMIUM tier is always required (complex reasoning, novel problems) |
| 432 | +- You prefer predictable performance over cost savings |
| 433 | + |
| 434 | +**Best for:** health-check, test-gen, doc-gen, refactoring workflows |
| 435 | + |
| 436 | +**Not ideal for:** complex debugging, architecture design, novel feature implementation |
| 437 | + |
| 438 | +--- |
| 439 | + |
| 440 | +### How much can I save with tier fallback? |
| 441 | + |
| 442 | +**Real savings depend on your workflow success rates:** |
| 443 | + |
| 444 | +**Scenario 1: CHEAP often succeeds (60% of stages)** |
| 445 | +- Both stages succeed at CHEAP: **~90% savings** vs. all-PREMIUM |
| 446 | +- Typical result: **60-70% overall savings** |
| 447 | + |
| 448 | +**Scenario 2: Mixed success (40% CHEAP, 40% CAPABLE, 20% PREMIUM)** |
| 449 | +- Real-world mix: **40-50% savings** vs. all-PREMIUM |
| 450 | + |
| 451 | +**Scenario 3: CHEAP rarely succeeds (20% of stages)** |
| 452 | +- Most stages need CAPABLE or PREMIUM: **10-20% savings** |
| 453 | +- May not be worth the latency cost |
| 454 | + |
| 455 | +**Track your actual savings:** |
| 456 | +```bash |
| 457 | +empathy telemetry savings --days 30 |
| 458 | +``` |
| 459 | + |
| 460 | +**See detailed breakdown:** [TIER_FALLBACK_TEST_REPORT.md](../TIER_FALLBACK_TEST_REPORT.md) |
| 461 | + |
| 462 | +--- |
| 463 | + |
| 464 | +### What are quality gates? |
| 465 | + |
| 466 | +**Quality gates = validation checks that decide if a tier's output is acceptable.** |
| 467 | + |
| 468 | +**Default quality gates** (all workflows): |
| 469 | +- ✅ Execution succeeded (no exceptions) |
| 470 | +- ✅ Output is not empty |
| 471 | +- ✅ No error keys in response |
| 472 | + |
| 473 | +**Workflow-specific gates** (health-check): |
| 474 | +- ✅ Health score ≥ 95 (configurable with `--health-score-threshold`) |
| 475 | +- ✅ Diagnosis data present |
| 476 | +- ✅ Required fields populated |
| 477 | + |
| 478 | +**Custom quality gates:** Override `validate_output()` in your workflow: |
| 479 | +```python |
| 480 | +def validate_output(self, stage_output: dict) -> tuple[bool, str | None]: |
| 481 | + # Custom validation logic |
| 482 | + if stage_output.get("confidence", 0) < 0.8: |
| 483 | + return False, "confidence_too_low" |
| 484 | + return True, None |
| 485 | +``` |
| 486 | + |
| 487 | +**See code:** [src/empathy_os/workflows/base.py:156-187](../../src/empathy_os/workflows/base.py#L156-L187) |
| 488 | + |
| 489 | +--- |
| 490 | + |
| 491 | +### Can I customize the tier fallback behavior? |
| 492 | + |
| 493 | +**Yes! Several customization options:** |
| 494 | + |
| 495 | +**1. Change the starting threshold:** |
| 496 | +```bash |
| 497 | +empathy workflow run health-check --use-recommended-tier --health-score-threshold 90 |
| 498 | +``` |
| 499 | + |
| 500 | +**2. Use Python API for full control:** |
| 501 | +```python |
| 502 | +from empathy_os.workflows import get_workflow |
| 503 | + |
| 504 | +workflow_cls = get_workflow("health-check") |
| 505 | +workflow = workflow_cls( |
| 506 | + provider="anthropic", |
| 507 | + enable_tier_fallback=True, |
| 508 | + health_score_threshold=95, # Custom threshold |
| 509 | +) |
| 510 | + |
| 511 | +result = await workflow.execute(path=".") |
| 512 | +``` |
| 513 | + |
| 514 | +**3. Create custom workflows with specific quality gates:** |
| 515 | +```python |
| 516 | +class MyWorkflow(BaseWorkflow): |
| 517 | + def validate_output(self, stage_output: dict) -> tuple[bool, str | None]: |
| 518 | + # Your custom validation logic |
| 519 | + pass |
| 520 | +``` |
| 521 | + |
| 522 | +**See examples:** [CHANGELOG.md Migration Guide](../CHANGELOG.md#migration-guide) |
| 523 | + |
| 524 | +--- |
| 525 | + |
| 526 | +### Is tier fallback production-ready? |
| 527 | + |
| 528 | +**Yes!** Fully tested and validated: |
| 529 | + |
| 530 | +- ✅ **8/8 unit tests passing** (100%) |
| 531 | +- ✅ **89% code coverage** on tier_tracking module |
| 532 | +- ✅ **Zero lint errors, zero type errors** |
| 533 | +- ✅ **Comprehensive error handling** |
| 534 | +- ✅ **Backward compatible** (opt-in, default behavior unchanged) |
| 535 | +- ✅ **Full telemetry tracking** |
| 536 | + |
| 537 | +**Deployment checklist completed:** |
| 538 | +- ✅ All unit tests pass |
| 539 | +- ✅ Code coverage ≥80% on critical modules |
| 540 | +- ✅ Documentation updated |
| 541 | +- ✅ CHANGELOG.md entry added |
| 542 | +- ✅ Migration guide available |
| 543 | + |
| 544 | +**See full validation:** [TIER_FALLBACK_TEST_REPORT.md](../TIER_FALLBACK_TEST_REPORT.md) |
| 545 | + |
| 546 | +--- |
| 547 | + |
394 | 548 | ## Results & ROI |
395 | 549 |
|
396 | 550 | ### What results can I expect? |
|
0 commit comments