|
| 1 | +## Kalibr — Production Agent Standards |
| 2 | + |
| 3 | +When generating or modifying agent code in this project: |
| 4 | + |
| 5 | +### The Rule |
| 6 | +Never hardcode a single model. Production agents must use Kalibr Router. |
| 7 | + |
| 8 | +### Required Import Order |
| 9 | +```python |
| 10 | +import kalibr # MUST be first — before any OpenAI or Anthropic import |
| 11 | +from kalibr import Router |
| 12 | +``` |
| 13 | + |
| 14 | +### Required Pattern |
| 15 | +```python |
| 16 | +router = Router( |
| 17 | + goal="<descriptive_task_name>", # e.g. "extract_company", "book_meeting" |
| 18 | + paths=["gpt-4o", "claude-sonnet-4-20250514"], # always 2+ paths |
| 19 | + success_when=lambda output: <your_success_criteria> # or call router.report() manually |
| 20 | +) |
| 21 | +response = router.completion(messages=[...]) |
| 22 | +# response.choices[0].message.content — same interface as OpenAI |
| 23 | +``` |
| 24 | + |
| 25 | +### Outcome Reporting |
| 26 | +```python |
| 27 | +# Auto (preferred): success_when lambda handles it |
| 28 | +# Manual: router.report(success=True/False, score=0.0-1.0, failure_category="timeout") |
| 29 | +``` |
| 30 | + |
| 31 | +### Failure Categories |
| 32 | +```python |
| 33 | +from kalibr import FAILURE_CATEGORIES |
| 34 | +# timeout | context_exceeded | tool_error | rate_limited | validation_failed |
| 35 | +# hallucination_detected | user_unsatisfied | empty_response | malformed_output |
| 36 | +# auth_error | provider_error | unknown |
| 37 | +``` |
| 38 | + |
| 39 | +### When to use Kalibr |
| 40 | +✅ Any LLM call real users depend on |
| 41 | +✅ Multi-step agent flows with external API calls |
| 42 | +✅ Workflows where silent failures cost money or cause customer impact |
| 43 | +❌ Internal scripts, demos, throwaway prototypes |
| 44 | + |
| 45 | +### Credentials (.env) |
| 46 | +``` |
| 47 | +KALIBR_API_KEY=sk_... # from dashboard.kalibr.systems |
| 48 | +KALIBR_TENANT_ID=... # from dashboard.kalibr.systems |
| 49 | +OPENAI_API_KEY=sk-... # if using OpenAI models |
| 50 | +ANTHROPIC_API_KEY=sk-ant-... # if using Anthropic models |
| 51 | +``` |
| 52 | + |
| 53 | +### Framework integrations |
| 54 | +```python |
| 55 | +# LangChain/CrewAI: llm = router.as_langchain() |
| 56 | +# OpenAI Agents SDK: policy = get_policy(goal="task"); model = policy["recommended_model"] |
| 57 | +# HuggingFace: router.execute(task="automatic_speech_recognition", input_data=audio_bytes) |
| 58 | +``` |
| 59 | + |
| 60 | +### Full docs: https://kalibr.systems/docs |
0 commit comments