Skip to main content
Since v0.5.0, Octo ships a clean embeddable engine at octo.core. It has no environment variable reading, no CLI dependencies, and no side effects at import time — making it safe to embed in web services, workers, or test harnesses.

Quick Start

import asyncio
from octo.core import OctoEngine, OctoConfig
from octo.core.storage import FilesystemStorage

config = OctoConfig(
    llm_provider="anthropic",
    llm_credentials={"api_key": "sk-ant-..."},
    default_model="claude-sonnet-4-5-20250929",
    storage=FilesystemStorage(root="/path/to/.octo"),
)

engine = OctoEngine(config)

async def main():
    response = await engine.invoke("Hello!", thread_id="conv-123")
    print(response.content)
    await engine.close()

asyncio.run(main())

OctoConfig

The configuration dataclass. Caller provides everything — no env var reading.

Required Fields

FieldTypeDescription
llm_providerstr"anthropic", "openai", "bedrock", "azure", "github", "gemini", or "local"
llm_credentialsdictProvider-specific credentials (see below)

Credential Keys by Provider

ProviderRequired KeysOptional Keys
Anthropicapi_key
OpenAIapi_key
Bedrockregion, access_key_id, secret_access_key
Azureapi_key, endpointapi_version
GitHubapi_keybase_url, anthropic_base_url
Geminiapi_key
Localbase_url, api_key

Optional Fields

FieldDefaultDescription
default_modelclaude-sonnet-4-5-20250929Model for general routing and chat
high_tier_model(same as default)Model for complex reasoning
low_tier_model(same as default)Model for summarization and cheap tasks
model_profile"balanced""quality", "balanced", or "budget"
storageNoneStorageBackend instance for files, memory, skills
checkpoint_backend"sqlite""sqlite" or "postgres"
checkpoint_config{}Backend-specific config (see below)
context_limit200000Max context window tokens
tool_result_limit40000Max chars for a single tool result
summarization_trigger_tokens40000Token count to trigger auto-summarization
summarization_keep_tokens8000Tokens of recent history to keep after summarization
supervisor_msg_char_limit30000Per-message char limit for supervisor
preloaded_tools[]Pre-created LangChain tools (skip MCP loading)
agent_configs[]List of AgentConfig for custom agents
system_prompt""Custom system prompt override

Validation

Config is validated automatically by OctoEngine on construction. Call config.validate() manually for early checks:
from octo.core.config import OctoConfigError

try:
    config.validate()
except OctoConfigError as e:
    print(e)  # Lists all validation errors

OctoEngine

The main entry point. Build once per configuration, invoke per message.

Methods

MethodDescription
await engine.invoke(message, thread_id=...)Process one message. Returns OctoResponse.
async for event in engine.stream(message, thread_id=...)Stream response events (tokens, tool calls).
await engine.close()Clean up resources (DB connections, etc.)
engine.is_builtWhether the graph has been lazily built yet.

OctoResponse

@dataclass
class OctoResponse:
    content: str                      # The assistant's reply
    thread_id: str                    # Conversation identifier
    context_tokens_used: int = 0      # Tokens consumed
    context_tokens_limit: int = 200000
    agent_name: str = ""              # Which agent produced the response
    error: str | None = None          # Non-None if invocation failed
    error_traceback: str | None = None
Errors are captured in the response (not raised), so callers can always inspect the result.

StorageBackend

The StorageBackend protocol defines async file operations for memory, skills, and workspace files.

Built-in Backends

Local filesystem. No extra dependencies.
from octo.core.storage import FilesystemStorage

storage = FilesystemStorage(root="/path/to/.octo")

Protocol

Any object implementing these async methods can be used as a storage backend:
class StorageBackend(Protocol):
    async def read(self, path: str) -> str: ...
    async def write(self, path: str, content: str) -> None: ...
    async def exists(self, path: str) -> bool: ...
    async def glob(self, pattern: str) -> list[str]: ...

Checkpointing

Conversation state is persisted via LangGraph checkpointers.
No extra dependencies. Path defaults to <workspace>/.octo/octo.db.
config = OctoConfig(
    checkpoint_backend="sqlite",
    checkpoint_config={"path": "/path/to/octo.db"},
    ...
)

Thread Safety

OctoEngine is not thread-safe. Each instance mutates global module state during graph build. Do not share engine instances across threads, and do not create multiple engines with different configs in the same process simultaneously.For multi-tenant scenarios, use one engine per process/worker.

Installation

The core engine is included in the base package:
pip install octo-agent           # Core engine only
pip install "octo-agent[cli]"    # Core + CLI (Rich terminal)
pip install "octo-agent[all]"    # Everything