{"id":49075301,"url":"https://github.com/mangobanaani/sktk","last_synced_at":"2026-04-20T09:36:23.148Z","repository":{"id":340967099,"uuid":"1168386243","full_name":"mangobanaani/sktk","owner":"mangobanaani","description":"Convenience layer over Semantic Kernel for Python","archived":false,"fork":false,"pushed_at":"2026-03-09T20:21:56.000Z","size":642,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-10T01:36:09.005Z","etag":null,"topics":["agent-framework","ai-agents","anthropic","llm","llm-framework","multi-agent","openai","python","rag","semantic-kernel"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mangobanaani.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-27T10:25:43.000Z","updated_at":"2026-03-09T20:21:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mangobanaani/sktk","commit_stats":null,"previous_names":["mangobanaani/sktk"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mangobanaani/sktk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mangobanaani%2Fsktk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mangobanaani%2Fsktk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mangobanaani%2Fsktk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mangobanaani%2Fsktk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mangobanaani","download_url":"https://codeload.github.com/mangobanaani/sktk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mangobanaani%2Fsktk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32041846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-framework","ai-agents","anthropic","llm","llm-framework","multi-agent","openai","python","rag","semantic-kernel"],"created_at":"2026-04-20T09:36:22.255Z","updated_at":"2026-04-20T09:36:23.125Z","avatar_url":"https://github.com/mangobanaani.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sktk\n\nA production-grade convenience layer over [Semantic Kernel](https://github.com/microsoft/semantic-kernel) for Python. Reduces the boilerplate of building LLM agent systems.\n\n- **One-line agents** — create, invoke, and test agents with minimal setup\n- **Swappable LLM backends** — Anthropic Claude, Azure OpenAI, Gemini, or local models behind a unified protocol\n- **Guardrail pipeline** — PII filtering, prompt injection detection, content safety, token budgets, and rate limiting out of the box\n- **Persistent sessions** — conversation history and typed blackboard with in-memory, SQLite, or Redis backends\n- **Multi-agent orchestration** — teams, pipelines (`\u003e\u003e`), fan-out/fan-in, supervisor/worker, reflection, and debate patterns\n- **RAG built in** — chunking, dense/sparse/hybrid retrieval, FAISS and HNSW backends, grounding filters\n- **Observability** — token tracking with cost attribution, tamper-evident audit trails, profiling, OpenTelemetry tracing, token quotas\n- **Test without LLM calls** — `MockKernel`, scripted responses, plugin sandbox, prompt regression suites\n\n## Install\n\n```bash\npip install -e .\n```\n\nWith extras:\n\n```bash\npip install -e \".[redis,rag-faiss,dev]\"\n```\n\nRequires Python 3.11+.\n\n## Checkpoint configuration\n\n`CheckpointStore` supports a config-first workflow via `CheckpointConfig`:\n\n```python\nfrom sktk.team.checkpoint import CheckpointConfig, CheckpointStore\n\ncfg = CheckpointConfig(\n    backend=\"sqlite\",\n    path=\"checkpoints.db\",\n    max_checkpoints=1000,\n    max_workflows=1000,\n    max_state_bytes=256_000,\n    allow_overwrite=False,\n    shared_max_workers=4,\n    retry_attempts=2,\n    retry_delay=0.01,\n    retry_backoff=2.0,\n    retry_jitter=0.01,\n)\nstore = CheckpointStore.from_config(cfg)\n```\n\nNotes:\n- `allow_overwrite=False` prevents clobbering existing non-SQLite files.\n- `max_state_bytes` and `max_workflows` cap memory usage.\n- `metrics_hook` can be used to collect structured events without affecting core flow.\n- Set `freeze_registry=True` to prevent runtime backend registry mutation.\n- Set `allow_plugin_loading=False` to disable entry-point discovery.\n- Set `metrics_async=True` to emit metrics on a background dispatcher.\n\n### Backend plugins\n\nYou can provide custom checkpoint backends via Python entry points:\n\n```toml\n[project.entry-points.\"sktk.checkpoint_backends\"]\nmy_backend = \"my_pkg.checkpoints:factory\"\n```\n\nThe factory should accept a `CheckpointConfig` and return an object that implements\n`CheckpointBackend` (async `save/load/list/clear/close`). Plugin-specific settings\nshould be read from `CheckpointConfig.backend_options`.\n\nTo declare plugin compatibility, set a version attribute on your factory:\n\n```python\ndef factory(cfg):\n    ...\nfactory.__sktk_checkpoint_api__ = \"1.0\"\n```\n\nAt runtime, plugins are discovered lazily when a backend name isn’t found. You can\nforce discovery with:\n\n```python\nfrom sktk.team.checkpoint import load_backend_plugins\nload_backend_plugins()\n```\n\n### OpenTelemetry tracing\n\nIf you have OpenTelemetry installed and initialized via `sktk.observability.tracing.instrument()`,\nyou can enable spans for checkpoint operations:\n\n```python\nfrom sktk.observability.tracing import instrument\nfrom sktk.team.checkpoint import CheckpointConfig, CheckpointStore\n\ninstrument()\ncfg = CheckpointConfig(trace_enabled=True, trace_span_prefix=\"sktk.checkpoint\")\nstore = CheckpointStore.from_config(cfg)\n```\n\n### OpenTelemetry metrics\n\nTo export checkpoint metrics via OTEL, use the metrics hook:\n\n```python\nfrom sktk.observability.otel_metrics import instrument_metrics, make_metrics_hook\nfrom sktk.team.checkpoint import CheckpointConfig, CheckpointStore\n\ninstrument_metrics()\ncfg = CheckpointConfig(metrics_hook=make_metrics_hook())\nstore = CheckpointStore.from_config(cfg)\n```\n\n## Quick start\n\n```python\nimport asyncio\nfrom sktk import SKTKAgent\n\nasync def main():\n    agent = SKTKAgent(\n        name=\"assistant\",\n        instructions=\"Be concise.\",\n        _service=provider,  # AnthropicClaudeProvider, AzureOpenAIProvider, etc.\n    )\n    result = await agent.invoke(\"What is Python?\")\n    print(result)\n\nasyncio.run(main())\n```\n\nFor testing without a live LLM:\n\n```python\nagent = SKTKAgent.with_responses(\"bot\", [\"Hello!\", \"Goodbye!\"])\nresult = await agent.invoke(\"Hi\")  # returns \"Hello!\"\n```\n\n## Architecture\n\n```mermaid\ngraph TB\n    subgraph \"sktk.agent\"\n        Agent[SKTKAgent]\n        Tools[\"@tool + contracts\"]\n        Filters[\"Filter pipeline\"]\n        Hooks[LifecycleHooks]\n        MW[MiddlewareStack]\n        Providers[\"LLM Providers\"]\n        Router[Router]\n    end\n\n    subgraph \"sktk.core\"\n        Context[ExecutionContext]\n        Events[Typed events]\n        Resilience[\"RetryPolicy + CircuitBreaker\"]\n        Secrets[SecretsProvider]\n    end\n\n    subgraph \"sktk.team\"\n        Team[SKTKTeam]\n        Strategies[\"RoundRobin / Broadcast / Custom\"]\n        Topology[\"Pipeline DSL (\u003e\u003e)\"]\n    end\n\n    subgraph \"sktk.knowledge\"\n        KB[KnowledgeBase]\n        Chunking[Chunkers]\n        Retrieval[\"Dense / Sparse / Hybrid\"]\n        Grounding[GroundingFilter]\n    end\n\n    subgraph \"sktk.session\"\n        Session[Session]\n        History[\"ConversationHistory\"]\n        Blackboard[\"Blackboard\"]\n        Backends[\"Memory / SQLite / Redis\"]\n    end\n\n    subgraph \"sktk.observability\"\n        Tokens[TokenTracker]\n        Audit[AuditTrail]\n        Profiler[AgentProfiler]\n        Logging[\"Structured logging\"]\n        Tracing[\"OpenTelemetry\"]\n    end\n\n    Agent --\u003e Filters --\u003e Providers\n    Agent --\u003e Tools\n    Agent --\u003e Hooks\n    Agent --\u003e Session\n    Providers --\u003e Router\n    Team --\u003e Agent\n    Team --\u003e Strategies\n    KB --\u003e Chunking --\u003e Retrieval\n    Agent --\u003e Context --\u003e Events\n```\n\n## Package overview\n\n| Package | What it does |\n|---------|-------------|\n| `sktk.agent` | Agent abstraction, `@tool` decorator, typed contracts, filter pipeline, lifecycle hooks, middleware, approval gates, permissions, rate limiting, task planner, prompt templates |\n| `sktk.agent.providers` | Swappable LLM backends (Anthropic Claude, Azure OpenAI, Gemini, local) with a registry/factory pattern |\n| `sktk.agent.router` | Provider router with latency, cost, A/B, and fallback selection policies |\n| `sktk.core` | Execution context propagation, typed event dataclasses, exception hierarchy, retry/circuit-breaker, pluggable secrets management, configuration |\n| `sktk.knowledge` | RAG pipeline: text sources, fixed-size and sentence chunkers, BM25 sparse index, dense/hybrid retrieval with reciprocal rank fusion, optional FAISS and HNSW backends, grounding filters with token budgets |\n| `sktk.session` | Conversation history and typed blackboard with pluggable backends (in-memory, SQLite, Redis), conversation summarization strategies |\n| `sktk.team` | Multi-agent orchestration with `SKTKTeam`, composable strategies (round-robin, broadcast, capability-based), pipeline topology DSL with `\u003e\u003e` operator and Mermaid visualization |\n| `sktk.observability` | Token tracking with cost attribution, tamper-evident audit trails, performance profiling, structured context-aware logging, OpenTelemetry instrumentation, token quotas |\n| `sktk.testing` | `MockKernel` for scripted responses, `PluginSandbox` for isolated tool testing, `PromptSuite` for prompt regression, assertion helpers, pytest fixtures |\n\n## Guardrail filters\n\nFilters run at three stages -- input, output, and function call -- and can allow, deny, or modify content:\n\n| Filter | Stage | Purpose |\n|--------|-------|---------|\n| `PromptInjectionFilter` | input | Detects instruction overrides, role reassignment, system prompt extraction |\n| `PIIFilter` | input + output | Blocks emails, SSNs, phone numbers via regex |\n| `ContentSafetyFilter` | input + output | Configurable blocked-pattern matching |\n| `TokenBudgetFilter` | input | Rejects prompts exceeding a token budget |\n| `PermissionPolicy` | function_call | Allowlist/denylist for tool invocations |\n| `RateLimitPolicy` | input | Time-window call throttling with async locking |\n| `AutoApprovalFilter` | function_call | Auto-approve safe tools, gate sensitive ones for human approval |\n| `GroundingFilter` | input | Auto-inject RAG context from a `KnowledgeBase` |\n| `TokenQuotaFilter` | input + output | Per-user/session token consumption limits |\n\n## LLM providers\n\nSKTK uses a protocol-based provider abstraction. The framework ships with:\n\n| Provider | Backend |\n|----------|---------|\n| `AnthropicClaudeProvider` | Anthropic Messages API |\n| `AzureOpenAIProvider` | Azure OpenAI Chat Completions |\n| `GeminiProvider` | Google Gemini |\n| `LocalLLMProvider` | Any local model exposing a `chat()` coroutine |\n\nAll providers return a normalized `CompletionResult` with text, token usage, and metadata. Register custom providers via `ProviderRegistry`.\n\n## Multi-agent orchestration\n\n```mermaid\ngraph LR\n    subgraph \"Sequential (\u003e\u003e)\"\n        A1[researcher] --\u003e A2[analyst] --\u003e A3[writer]\n    end\n```\n\n```mermaid\ngraph LR\n    subgraph \"Fan-out / fan-in\"\n        B1[planner] --\u003e B2[searcher A]\n        B1 --\u003e B3[searcher B]\n        B2 --\u003e B4[synthesizer]\n        B3 --\u003e B4\n    end\n```\n\n```mermaid\ngraph LR\n    subgraph \"Team with strategy\"\n        C0[SKTKTeam] --\u003e C1[agent 1]\n        C0 --\u003e C2[agent 2]\n        C0 --\u003e C3[agent 3]\n    end\n```\n\nFive built-in patterns demonstrated in [`examples/concepts/multi_agent/patterns/`](examples/concepts/multi_agent/patterns/README.md): sequential pipeline, parallel fan-out/fan-in, supervisor/worker, reflection loop, and debate/consensus.\n\n## RAG pipeline\n\n```mermaid\ngraph LR\n    A[TextSource] --\u003e|chunker| B[Chunks]\n    B --\u003e|embedder| C[Vectors]\n    C --\u003e|backend| D[Index]\n    E[Query] --\u003e|embed + retrieve| D\n    D --\u003e|top-k scoring| F[ScoredChunk results]\n```\n\nThree retrieval modes: `DENSE` (cosine similarity), `SPARSE` (BM25), `HYBRID` (reciprocal rank fusion). Optional FAISS and HNSW backends for production-scale vector search.\n\n## Observability\n\n| Component | What it tracks |\n|-----------|---------------|\n| `TokenTracker` | Per-invocation token usage with cost attribution via `PricingModel` |\n| `AuditTrail` | Tamper-evident hash-chained audit entries with query and integrity verification |\n| `AgentProfiler` | Wall-clock timing breakdown per labeled section |\n| `SessionRecorder` | Full session replay recording |\n| `EventStream` | Pluggable event sinks for structured logging integration |\n| `TokenQuota` | Per-user/session token consumption limits and enforcement |\n| `instrument()` | OpenTelemetry span creation for distributed tracing |\n\n## Resilience\n\n| Pattern | What it does |\n|---------|-------------|\n| `RetryPolicy` | Exponential backoff with configurable jitter strategy |\n| `CircuitBreaker` | Tracks failures, trips open at threshold, half-open recovery with async locking |\n\n## Session management\n\n| Backend | Persistence | Use case |\n|---------|-------------|----------|\n| `InMemoryHistory` | None | Tests, short-lived conversations |\n| `SQLiteHistory` | Disk | Single-node, development |\n| `RedisHistory` | Network | Multi-node production |\n\nSessions include a typed `Blackboard` for cross-agent state sharing with put/get/scan/delete operations and pattern-based key lookup.\n\n## Examples\n\nSee [`examples/README.md`](examples/README.md) for the full learning path with 24 runnable examples.\n\nQuick start order:\n\n| Step | File | Focus |\n|------|------|-------|\n| 1 | [`01_basic_agent.py`](examples/getting_started/01_basic_agent.py) | Create and invoke an agent |\n| 2 | [`02_persistent_session.py`](examples/getting_started/02_persistent_session.py) | SQLite session persistence |\n| 3 | [`03_tools_and_contracts.py`](examples/getting_started/03_tools_and_contracts.py) | Tool registration, typed output contracts |\n| 4 | [`04_lifecycle_hooks.py`](examples/getting_started/04_lifecycle_hooks.py) | Lifecycle hooks, middleware wrapping |\n\nMost examples call the real Claude API. Set `ANTHROPIC_API_KEY` in a `.env` file at the project root. A few examples (session, resilience, knowledge, testing) run offline without an API key.\n\n## Testing\n\n```bash\npip install -e \".[dev]\"\npytest\n```\n\n750+ tests, 95% coverage target. The testing toolkit provides:\n\n- `MockKernel` / `with_responses()` for deterministic agent testing without LLM calls\n- `PluginSandbox` for isolated tool function testing\n- `PromptSuite` for prompt regression testing in CI\n- `assert_history_contains()`, `assert_events_emitted()`, `assert_blackboard_has()` helpers\n\n## Project structure\n\n```\nsrc/sktk/\n  agent/         # Agent, tools, filters, hooks, middleware, providers, router\n  core/          # Context, events, errors, types, resilience, secrets, config\n  knowledge/     # RAG: chunking, retrieval, grounding, backends (memory, FAISS, HNSW)\n  session/       # History, blackboard, backends (memory, SQLite, Redis)\n  team/          # Multi-agent strategies, topology DSL, capability routing\n  observability/ # Metrics, audit, profiling, logging, tracing, quotas\n  testing/       # Mocks, assertions, fixtures, sandbox\ntests/\n  unit/          # 710+ tests mirroring src/ structure\n  integration/   # Provider and router integration tests\n  e2e/           # End-to-end workflow tests\nexamples/\n  getting_started/   # Numbered walkthrough\n  concepts/          # Agent, multi-agent, knowledge, session, resilience, observability, testing\ndocs/\n  api/           # API reference (one file per package)\n  ops/           # Operations playbooks\n  policies/      # Versioning and migration policy\nbenchmarks/      # Runtime baselines and SLO gates\n```\n\n## Docs\n\n- API reference: [`docs/api/`](docs/api/index.md)\n- Versioning policy: [`docs/policies/versioning.md`](docs/policies/versioning.md)\n- Operations playbooks: [`docs/ops/README.md`](docs/ops/README.md)\n- Contributing: [`CONTRIBUTING.md`](CONTRIBUTING.md)\n- Changelog: [`CHANGELOG.md`](CHANGELOG.md)\n\n## Benchmarks\n\nRuntime baselines live in [`benchmarks/`](benchmarks/README.md).\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmangobanaani%2Fsktk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmangobanaani%2Fsktk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmangobanaani%2Fsktk/lists"}