Thanks for your interest in contributing to the Kalibr Python SDK! This document provides guidelines and instructions for contributing.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/kalibr-sdk-python.git cd kalibr-sdk-python - Create a branch for your changes:
git checkout -b feat/my-new-feature
- Python 3.9 or higher
- pip or uv for package management
# Install in development mode with all dependencies
pip install -e ".[dev,langchain,crewai,openai-agents]"
# Or install just core dev dependencies
pip install -e ".[dev]"# Run all tests
pytest
# Run with coverage
pytest --cov=kalibr
# Run specific test file
pytest tests/test_intelligence.pyWe use black for formatting and ruff for linting:
# Format code (line length: 100)
black kalibr/ --line-length 100
# Check linting
ruff check kalibr/
# Fix auto-fixable issues
ruff check kalibr/ --fix# Run mypy
mypy kalibr/kalibr-sdk-python/
├── kalibr/ # Core SDK
│ ├── __init__.py # Main exports
│ ├── client.py # Kalibr client
│ ├── collector.py # OpenTelemetry collector setup
│ ├── instrumentation.py # Auto-instrumentation
│ ├── intelligence.py # Intelligence API client
│ ├── trace_capsule.py # TraceCapsule for cross-agent tracing
│ ├── simple_tracer.py # @trace decorator
│ ├── cost_adapter.py # Cost calculation adapters
│ └── cli/ # CLI commands
├── kalibr_langchain/ # LangChain integration
├── kalibr_crewai/ # CrewAI integration
├── kalibr_openai_agents/ # OpenAI Agents SDK integration
├── tests/ # Test suite
└── examples/ # Example scripts
- Use type hints for all function parameters and return values
- Write docstrings in Google style format
- Keep functions focused and small
- Prefer explicit over implicit
def get_policy(goal: str, constraints: dict | None = None) -> dict[str, Any]:
"""Get execution policy for a goal.
Queries the Intelligence API for the optimal model and execution
path based on historical outcome data.
Args:
goal: The goal to optimize for (e.g., "book_meeting").
constraints: Optional constraints dict with keys like
max_cost_usd, max_latency_ms, min_quality.
Returns:
Policy dict containing recommended_model, outcome_success_rate,
confidence, and alternatives.
Raises:
httpx.HTTPStatusError: If the API returns an error.
Example:
>>> policy = get_policy(goal="resolve_ticket")
>>> print(policy["recommended_model"])
'gpt-4o'
"""Use conventional commit prefixes:
| Prefix | Description |
|---|---|
feat: |
New feature |
fix: |
Bug fix |
docs: |
Documentation changes |
test: |
Adding or updating tests |
refactor: |
Code refactoring (no functional change) |
chore: |
Build, CI, or tooling changes |
Examples:
feat: add tenant_id parameter to get_policyfix: handle timeout in intelligence clientdocs: update README with TraceCapsule examples
- Update documentation if you're changing public APIs
- Add tests for new functionality
- Run the test suite and ensure all tests pass
- Update CHANGELOG.md if appropriate
- Create a PR against the
mainbranch - Request review from maintainers
Use the same format as commit messages:
feat: add new intelligence endpointfix: resolve race condition in collector
- Place tests in the
tests/directory - Name test files
test_<module>.py - Use pytest fixtures for common setup
- Mock external API calls
import pytest
from kalibr.intelligence import get_policy
def test_get_policy_returns_recommendation():
"""Test that get_policy returns a valid recommendation."""
policy = get_policy(goal="test_goal")
assert "recommended_model" in policy
assert "outcome_success_rate" in policy
assert 0 <= policy["outcome_success_rate"] <= 1To add a new framework integration:
- Create a new directory:
kalibr_<framework>/ - Add
__init__.pywith public exports - Add
README.mdwith usage documentation - Add optional dependency in
pyproject.toml - Add tests in
tests/test_<framework>.py - Update main README.md with integration section
If you discover a security vulnerability, please do not open a public issue. Instead, email support@kalibr.systems with details. We will respond promptly and work with you to address the issue.
- GitHub Discussions: For questions and feature requests
- Email: support@kalibr.systems
- Documentation: https://kalibr.systems/docs
By contributing, you agree that your contributions will be licensed under the Apache 2.0 License.