Framework for building AI agents
Project description
Logos ADK โ AI Agent Development Kit
Logos ADK is a Python framework for building AI agents, multi-agent systems, and workflow-driven applications. It combines tools, memory, guardrails, RAG, observability, and serving primitives in one codebase.
๐ Features
Core Capabilities
| Feature | Description |
|---|---|
| ๐ค Agent System | Create agents with configurable models, roles, goals, and backstories |
| ๐ง Tools | Async tool registration with automatic schema generation |
| ๐ง Memory | Session, long-term, and shared memory with multiple strategies |
| ๐ก๏ธ Guardrails | Input/output validation with multiple guard types |
| ๐ RAG | Retrieval with loaders, splitters, and vector stores |
| ๐ MCP | Model Context Protocol integration for external tool servers |
| ๐ฅ Teams | Multi-agent orchestration with configurable topology |
| ๐ Workflows | Graph, pipeline, crew, and swarm orchestration |
| ๐ญ Observability | Built-in tracing with multiple exporters |
| ๐พ Caching | Exact and semantic response caching |
| ๐ Serving | HTTP API with streaming and CORS support |
| ๐๏ธ CLI | Command-line interface for chat, testing, and operations |
Production Features
| Feature | Description |
|---|---|
| ๐ Security | Input validation, prompt injection detection, PII redaction, audit logging |
| โป๏ธ Reliability | Retry policies, circuit breakers, fallback models, timeouts |
| ๐ฐ Cost Control | Budget tracking, cost-aware routing, spend ledgers |
| ๐ Learning | Model routing, tool workflow, and retrieval learning loops |
| ๐ State | Persistent state with SQLite and PostgreSQL backends |
| โก Scaling | Horizontal scaling with load balancing and session affinity |
| โ Self-QA | Self-verification with assertions and retries |
| ๐ฌ Events | Event bus with subscriptions and agent-to-agent communication |
๐ฆ Installation
pip install logos-adk
Optional Extras
pip install logos-adk[all]
pip install logos-adk[anthropic]
pip install logos-adk[openai]
pip install logos-adk[mcp]
pip install logos-adk[serve]
pip install logos-adk[cli]
pip install logos-adk[rag-pdf]
pip install logos-adk[rag-chroma]
The examples below use current provider model names as of March 26, 2026. These names can change, so check provider docs before copying them into production config.
๐ Quick Start
1. Basic Agent
import asyncio
from logos_adk import Agent
async def main():
agent = Agent(
"assistant",
model="claude-sonnet-4-6",
system="Answer clearly and keep responses short.",
)
response = await agent.run("What can you do?")
print(response.content)
asyncio.run(main())
2. Agent with Tools
import asyncio
from logos_adk import Agent, tool
@tool
async def get_weather(city: str) -> str:
"""Return a stub weather report."""
return f"Weather for {city}: clear, 22C"
@tool
async def search_docs(query: str) -> str:
"""Return a stub search result."""
return f"Results for {query}"
async def main():
agent = Agent("assistant", model="gpt-5.4").tools([get_weather, search_docs])
response = await agent.run("Find the weather in Berlin")
print(response.content)
asyncio.run(main())
3. Multi-Agent Team
import asyncio
from logos_adk import Agent, Team
async def main():
researcher = Agent(
"researcher",
model="claude-sonnet-4-6",
system="Collect the facts and keep notes concise.",
)
writer = Agent(
"writer",
model="gpt-5.4",
system="Turn the research into a readable draft.",
)
team = Team(
"content-team",
agents=[researcher, writer],
orchestrator="researcher",
topology="mesh",
)
response = await team.run("Write a short explainer about vector databases")
print(response.content)
asyncio.run(main())
4. Graph Workflow
from logos_adk import AgentStep, Graph
graph = Graph("review-workflow", max_visits=10)
graph.node(AgentStep("draft", writer_agent))
graph.node(AgentStep("review", reviewer_agent))
graph.node(AgentStep("approve", approval_agent))
graph.edge("draft", "review", label="draft_ready")
graph.edge("review", "approve", when=lambda ctx: ctx["approved"], label="approved")
graph.edge("review", "draft", when=lambda ctx: not ctx["approved"], label="needs_revision")
graph.entrypoint("draft")
graph.terminal("approve")
5. YAML Config
agent.yaml:
name: assistant
model: claude-sonnet-4-6
system_prompt: |
You help users and keep answers practical.
security:
input_validation_enabled: true
prompt_shield_enabled: true
reliability:
timeout_seconds: 60.0
retry_max_attempts: 3
Load and run:
from logos_adk import Agent
agent = Agent.from_config("agent.yaml")
response = await agent.run("Hello")
๐๏ธ Core API
from logos_adk import Agent, SessionMemory
from logos_adk.guardrails import ContentFilter, MaxLengthGuard
from logos_adk.observe import ConsoleExporter
from logos_adk.reliability import RetryPolicy
from logos_adk.security import InputValidator, PromptShield
agent = (
Agent("assistant", model="gpt-5.4")
.system("Be precise.")
.tools([tool1, tool2])
.memory(SessionMemory(strategy="sliding_window", max_messages=20))
.input_guardrail(ContentFilter(blocked=["spam"]))
.output_guardrail(MaxLengthGuard(max_chars=500))
.observe(ConsoleExporter())
.security(
input_validator=InputValidator(max_length=5000),
prompt_shield=PromptShield(threshold=0.5),
)
.reliability(
retry_policy=RetryPolicy(max_attempts=3),
provider_timeout=60.0,
)
)
Common Methods:
| Method | Purpose |
|---|---|
.model(model) |
Set the model name or provider |
.system(prompt) |
Set the system prompt |
.role(role, goal, backstory) |
Set crew-style role metadata |
.tools(tools) |
Attach tools |
.memory(*memories) |
Attach memory strategies |
.mcp(source) |
Connect to an MCP server |
.observe(*exporters) |
Attach exporters |
.input_guardrail(guard) |
Validate input |
.output_guardrail(guard) |
Validate output |
.security(...) |
Configure security controls |
.reliability(...) |
Configure retries and timeouts |
.budget(...) |
Set task budget |
.self_qa(...) |
Enable self-checks |
.state_backend(store) |
Attach persistent state |
.knowledge(kb, mode, limit) |
Attach a knowledge base |
Tools
Tools are async functions with automatic schema generation:
from logos_adk import tool, Toolkit
@tool
async def search(query: str, limit: int = 10) -> str:
"""Search for information.
Args:
query: Search query
limit: Maximum results (default: 10)
"""
return f"Results for: {query}"
# Create toolkit
class SearchToolkit(Toolkit):
def get_tools(self):
return [search, analyze, summarize]
agent.tools([search])
# or
agent.tools(SearchToolkit())
Memory
Built-in memory types:
from logos_adk import SessionMemory, LongTermMemory, SharedMemory
from logos_adk.memory import SQLiteBackend
# Session memory (short-term)
session_mem = SessionMemory(
strategy="sliding_window", # or "summarize", "token_limit"
max_messages=20,
max_tokens=16000
)
# Long-term memory (persistent)
long_term = LongTermMemory(
backend=SQLiteBackend("memory.db"),
retrieval="hybrid", # or "keyword", "semantic"
limit=5
)
# Shared memory (cross-agent)
shared = SharedMemory(backend=SQLiteBackend("shared.db"))
agent.memory(session_mem, long_term, shared)
Guardrails
Input and output guards:
from logos_adk.guardrails import (
ContentFilter, # Block words/phrases
RegexGuard, # Pattern matching
MaxLengthGuard, # Length limits
KeywordGuard, # Keyword detection
ToxicityGuard, # Toxic language
ContentModerationGuard, # Content moderation
HallucinationGuard # Fact checking
)
agent = (
Agent("bot", model="gpt-5.4")
.input_guardrail(
ContentFilter(blocked=["spam", "abuse"]),
MaxLengthGuard(max_chars=5000)
)
.output_guardrail(
ToxicityGuard(threshold=2),
ContentFilter(blocked=["competitor"])
)
)
RAG (Retrieval-Augmented Generation)
Add knowledge base capabilities:
from logos_adk import KnowledgeBase, rag_tool
from logos_adk.rag import (
TextLoader, MarkdownLoader,
RecursiveCharacterSplitter,
SQLiteVectorStore
)
# Load documents
loader = MarkdownLoader("docs/")
documents = loader.load()
# Create vector store
splitter = RecursiveCharacterSplitter(chunk_size=500, chunk_overlap=50)
vector_store = SQLiteVectorStore("rag.db")
vector_store.add_documents(documents, splitter)
# Create knowledge base
kb = KnowledgeBase(
store=vector_store,
embed_fn=your_embedding_function,
splitter=splitter
)
# Option 1: Auto-inject context
agent.knowledge(kb, mode="memory", limit=5)
# Option 2: Add as tool
agent.tools([rag_tool(kb, limit=5)])
Workflows
Graph Workflow
Stateful graph with conditional routing:
from logos_adk import Graph, AgentStep, FunctionStep
graph = Graph("workflow", max_visits=10)
graph.node(AgentStep("analyze", analyst))
graph.node(AgentStep("write", writer))
graph.node(FunctionStep("save", save_function))
graph.edge("analyze", "write", label="ready")
graph.edge("write", "save", when=lambda ctx: ctx["approved"])
graph.edge("write", "analyze", when=lambda ctx: not ctx["approved"])
graph.entrypoint("analyze")
graph.terminal("save")
result = await graph.run("Write an article")
Pipeline Workflow
Linear workflow with step composition:
from logos_adk import Pipeline
pipeline = Pipeline("pipeline", timeout=120.0)
pipeline.step(agent1, name="step1")
pipeline.function(process_fn, name="step2")
pipeline.parallel(agent2, agent3, name="parallel")
pipeline.conditional(
lambda ctx: ctx["score"] > 0.8,
then=agent_yes,
else_=agent_no
)
pipeline.loop(agent, until=lambda ctx: ctx["done"], max_iterations=5)
pipeline.approval(name="approval", message="Approve?")
result = await pipeline.run("prompt")
Crew Process
CrewAI-style task orchestration:
from logos_adk import CrewProcess, CrewTask, Team
tasks = [
CrewTask(
name="research",
description="Research the topic",
role="researcher",
depends_on=[],
async_execution=False
),
CrewTask(
name="write",
description="Write article",
role="writer",
depends_on=["research"]
),
CrewTask(
name="approve",
description="Approve content",
role="manager",
task_type="approval",
depends_on=["write"]
)
]
crew = CrewProcess(
name="content_crew",
team=team,
tasks=tasks,
process="sequential" # or "hierarchical"
)
result = await crew.run("kickoff prompt")
Swarm (Event-Driven)
Async event-driven orchestration with EventBus:
from logos_adk.swarm import Swarm
from logos_adk.event_bus import InMemoryEventBus
bus = InMemoryEventBus()
swarm = Swarm("seo-swarm", event_bus=bus)
# Subscribe agents to topics
swarm.subscribe("need_seo", agent1, publish_to="need_copy")
swarm.subscribe("need_copy", agent2, publish_to="done")
# Dispatch and process
response = await swarm.dispatch(
prompt="Optimize listing",
request_topic="need_seo",
response_topic="done"
)
Swarm patterns:
- Event-driven async processing
- Topic-based pub/sub
- Chain of handlers
- Fan-out/fan-in
See docs/SWARM.md for complete documentation.
Security
Security primitives:
from logos_adk.security import (
InputValidator,
PromptShield,
PIIDetector,
AuditLogger
)
agent.security(
input_validator=InputValidator(
min_length=1,
max_length=20000,
reject_null_bytes=True
),
prompt_shield=PromptShield(
patterns=["inject", "ignore"],
threshold=0.5
),
pii_detector=PIIDetector(
blocked_types=["ssn", "credit_card", "email"]
),
audit_logger=AuditLogger(
redact_pii=True,
retention_days=30
)
)
Reliability
Reliability controls:
from logos_adk.reliability import RetryPolicy, CircuitBreaker
agent.reliability(
retry_policy=RetryPolicy(
max_attempts=3,
base_delay=0.25,
backoff="exponential"
),
provider_timeout=60.0,
fallback_models=["gpt-5.4", "claude-sonnet-4-6"]
)
# Circuit breaker auto-configured with:
# - failure_threshold: 5
# - recovery_timeout: 30s
Observability
Tracing exporters:
from logos_adk.observe import (
ConsoleExporter,
OpenTelemetryExporter,
LangfuseExporter
)
agent.observe(
ConsoleExporter(), # Debug
OpenTelemetryExporter(
endpoint="http://localhost:4318/v1/traces",
compression="gzip"
),
LangfuseExporter(
base_url="https://cloud.langfuse.com",
public_key="pk-...",
secret_key="sk-..."
)
)
YAML Configuration
Agent Configuration
name: assistant
model: claude-sonnet-4-6
system_prompt: |
You are a helpful assistant.
provider:
type: openai-compatible
base_url: http://localhost:11434/v1
model: local-model
tools:
- name: search
description: Search for information
parameters:
type: object
properties:
query:
type: string
required: [query]
memories:
session:
strategy: sliding_window
max_messages: 20
long_term:
backend:
type: sqlite
path: .logos_adk/memory.db
retrieval: hybrid
limit: 5
security:
input_validation_enabled: true
prompt_shield_enabled: true
pii_detection_enabled: true
output_max_length: 20000
reliability:
timeout_seconds: 60.0
retry_max_attempts: 3
circuit_breaker_failure_threshold: 5
guardrails:
input:
- type: max_length
max_chars: 5000
output:
- type: content_filter
blocked: ["spam"]
knowledge:
backend: sqlite
path: .logos_adk/rag.db
mode: tool
limit: 5
splitter:
chunk_size: 500
chunk_overlap: 50
observe:
exporter: console
Graph Configuration
name: workflow
max_visits: 10
entrypoint: "step1"
terminal_nodes: ["step3"]
nodes:
- name: "step1"
agent: "agent1"
metadata:
ui: {x: 100, y: 100}
description: "First step"
- name: "step2"
approval:
message: "Approve?"
- name: "step3"
function: "my_function"
edges:
- from: "step1"
to: "step2"
label: "ready"
- from: "step2"
to: "step3"
when: "approval.status == 'approved'"
label: "approved"
- from: "step2"
to: "step1"
when: "approval.status == 'rejected'"
label: "rejected"
Team Configuration
name: content_team
agents:
- name: researcher
role: researcher
goal: Gather facts
model: claude-sonnet-4-6
- name: writer
role: writer
goal: Create content
model: gpt-5.4
orchestrator: researcher
topology: mesh
max_rounds: 10
process: sequential
manager_role: manager
budget:
team_budget_usd: 10.0
task_budget_usd: 0.50
Swarm Configuration
name: seo_swarm
kind: swarm
event_bus:
backend: sqlite
path: .logos_adk/events.db
subscriptions:
- agent_name: seo_expert
topic: need_seo
publish_to: need_copy
- agent_name: copywriter
topic: need_copy
publish_to: need_quality
- agent_name: quality_analyst
topic: need_quality
publish_to: publish_ready
# Usage in Python:
# swarm = Swarm.from_config("swarm.yaml", agents=agents, event_bus=bus)
# response = await swarm.dispatch(
# prompt="Optimize listing",
# request_topic="need_seo",
# response_topic="publish_ready"
# )
CLI Usage
# Interactive chat
logos-adk chat agent.yaml
# Single prompt
logos-adk run agent.yaml "What is AI?"
# Streaming response
logos-adk run agent.yaml "Tell a story" --stream
# Validate config
logos-adk validate agent.yaml
# Test agent
logos-adk test agent.yaml
# Start HTTP server
logos-adk serve --agents agent.yaml --port 8000
# Inspect project and release helpers
logos-adk project --help
logos-adk upgrade --help
# State management
logos-adk storage upgrade-check --kind state --backend sqlite --path .logos_adk/state.db
logos-adk storage migrate --kind state --backend sqlite --path .logos_adk/state.db
Learning And Operator Storage
Learning/operator CLI commands now support both SQLite and PostgreSQL.
Use SQLite paths when you want local files:
logos-adk evaluation scorecard --db-path .logos_adk/learning.db --workspace-id acme
logos-adk retrieval summary --db-path .logos_adk/retrieval_learning.db --workspace-id acme
Use DSNs when the same data lives in PostgreSQL:
logos-adk evaluation scorecard --dsn postgresql://user:pass@localhost/learning --workspace-id acme
logos-adk model-routing leaderboard --dsn postgresql://user:pass@localhost/routing --workspace-id acme
logos-adk retrieval summary --dsn postgresql://user:pass@localhost/retrieval --workspace-id acme
logos-adk tool-workflow tool-scores --dsn postgresql://user:pass@localhost/tool_workflow --workspace-id acme
For multi-store commands, pass component-specific DSNs:
logos-adk improvement policy \
--dsn postgresql://user:pass@localhost/learning \
--model-routing-dsn postgresql://user:pass@localhost/routing \
--retrieval-dsn postgresql://user:pass@localhost/retrieval \
--tool-workflow-dsn postgresql://user:pass@localhost/tool_workflow \
--workspace-id acme
logos-adk transfer artifacts \
--dsn postgresql://user:pass@localhost/learning \
--reflection-dsn postgresql://user:pass@localhost/reflection \
--prompt-registry-dsn postgresql://user:pass@localhost/prompts \
--retrieval-dsn postgresql://user:pass@localhost/retrieval \
--tool-workflow-dsn postgresql://user:pass@localhost/tool_workflow \
--model-routing-dsn postgresql://user:pass@localhost/routing \
--source-agent-name support-bot
Examples
The public repository ships its runnable examples as documentation-first examples in docs/examples.md. The quickest production-oriented walkthroughs are:
- docs/examples.md for copy-paste examples
- docs/production.md for deployment and storage guidance
- docs/http-api.md for the HTTP surface
Project Structure
logos_adk/
โโโ agent/ # Agent core and execution helpers
โโโ team/ # Multi-agent orchestration
โโโ cli/ # Command-line interface
โโโ serve_routes/ # HTTP route handlers and schemas
โโโ learning/ # Evaluation and self-improvement modules
โโโ workflow/
โ โโโ graph.py # Graph workflow
โ โโโ pipeline.py # Pipeline workflow
โ โโโ config.py # YAML parsing
โ โโโ context.py # Execution context
โโโ tools/ # Tool system
โโโ memory/ # Memory backends
โโโ guardrails/ # Input/output validation
โโโ rag/ # RAG components
โโโ mcp/ # MCP integration
โโโ observe/ # Observability exporters
โโโ cache/ # Response caching
โโโ providers/ # LLM providers
โโโ security.py # Security primitives
โโโ reliability.py # Retry, circuit breaker
โโโ serve.py # FastAPI application factory
Providers
Supported provider integrations:
| Provider | Notes | Installation |
|---|---|---|
| Anthropic | Current examples: claude-sonnet-4-6, claude-opus-4-6 |
pip install logos-adk[anthropic] |
| OpenAI | Current examples: gpt-5.4, gpt-5-mini, gpt-5-nano |
pip install logos-adk[openai] |
| Google Gemini | Current examples: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite |
Built-in |
| OpenAI-compatible APIs | Ollama, LM Studio, vLLM, and similar endpoints | Built-in |
Provider auto-registration is based on the model name pattern. If you want full control, pass a provider instance directly instead of a string.
Publishing
PyPI publishing is automated with GitHub Actions via .github/workflows/publish-pypi.yml.
Recommended setup:
- Create the public GitHub repository.
- Create the
logos-adkproject on PyPI. - In PyPI, add a Trusted Publisher for:
- repository owner: your GitHub user or org
- repository name:
logos-adk - workflow file:
.github/workflows/publish-pypi.yml - environment:
pypi
- Create a GitHub release. The workflow will build the package and publish it to PyPI.
Documentation
- Production Guide โ MVP baseline for production
- Examples โ Working code examples
- HTTP API โ Public server routes and schemas
- Quality Testing โ Public quality baseline and operator workflows
Contributing
Contributions are welcome. Before opening a PR:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
pytest - Run linters:
ruff check . && mypy . - Submit a PR
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logos_adk-0.3.1.tar.gz.
File metadata
- Download URL: logos_adk-0.3.1.tar.gz
- Upload date:
- Size: 675.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dab97238831751b7b6fbaffd00a216c9f359e201f6f144a68ddbc34e6e8aef54
|
|
| MD5 |
98e7cbff66105aa94216cf3b83fe681b
|
|
| BLAKE2b-256 |
07d5a83ad0cac87a2a15338e734cfd9891b1eb4fdd58f7efb575d83cfc085972
|
Provenance
The following attestation bundles were made for logos_adk-0.3.1.tar.gz:
Publisher:
publish-pypi.yml on das-nibelung/LogosADK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logos_adk-0.3.1.tar.gz -
Subject digest:
dab97238831751b7b6fbaffd00a216c9f359e201f6f144a68ddbc34e6e8aef54 - Sigstore transparency entry: 1186525036
- Sigstore integration time:
-
Permalink:
das-nibelung/LogosADK@eac2125ded9fda8e47b8f94bea5298a9d13e94be -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/das-nibelung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@eac2125ded9fda8e47b8f94bea5298a9d13e94be -
Trigger Event:
release
-
Statement type:
File details
Details for the file logos_adk-0.3.1-py3-none-any.whl.
File metadata
- Download URL: logos_adk-0.3.1-py3-none-any.whl
- Upload date:
- Size: 520.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0f619b71f27ebbf3a53ef5fc4b06e0ccccb0a7f34720c824f2c23f1a339cae9
|
|
| MD5 |
c758eed3dc6f5d1420bc1a207d4c61b5
|
|
| BLAKE2b-256 |
150ccc3bd875e763ed1ef5235ccb6dc1f42b3d3e937307f2b7ae998793e9b2a6
|
Provenance
The following attestation bundles were made for logos_adk-0.3.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on das-nibelung/LogosADK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logos_adk-0.3.1-py3-none-any.whl -
Subject digest:
d0f619b71f27ebbf3a53ef5fc4b06e0ccccb0a7f34720c824f2c23f1a339cae9 - Sigstore transparency entry: 1186525042
- Sigstore integration time:
-
Permalink:
das-nibelung/LogosADK@eac2125ded9fda8e47b8f94bea5298a9d13e94be -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/das-nibelung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@eac2125ded9fda8e47b8f94bea5298a9d13e94be -
Trigger Event:
release
-
Statement type: