Skip to main content

Brown Octopus

Brown Octopus is a Python library for dynamic capability-context management for tool-using AI agents. It determines which capability definitions should be available to an agent on each interaction. It does not execute tools, manage credentials, or replace the host agent framework.

Install

pip install brown-octopus
brown-octopus setup-models

setup-models explicitly prepares en_core_web_trf and Qwen/Qwen3-Embedding-0.6B in Brown Octopus-managed persistent storage. Normal initialization does not download models.

Quick start

from brown_octopus import Octopus


async def main():
    octopus = Octopus()
    await octopus.initialize()

    result = octopus.retrieve_result(
        "Reply to Tom's email",
        session_id="conversation-123",
    )

    # Final active capability context for the host agent.
    for capability in result.tools:
        print(capability["name"])

Use await octopus.update() when the host deliberately wants to discover capabilities and build an updated index. initialize() loads existing local models and index state; it does not discover or download implicitly.

Build or update an index

The repository includes a runnable example for building the persisted index from an MCP catalog:

brown-octopus setup-models
python examples/setup_index.py

By default it reads data/mcps.json and writes data/indexes/default. Use a different catalog or output directory when needed:

python examples/setup_index.py \
  --catalog path/to/my-mcps.json \
  --index path/to/my-index

The host can perform the same operation in application code:

from brown_octopus import Octopus

octopus = Octopus(
    catalog_path="path/to/my-mcps.json",
    index_path="path/to/my-index",
)
report = await octopus.update()
print(report.tool_count)

An update is not a blind append and it is not an unconditional reset. Brown Octopus compares capabilities by stable capability_id:

new capability       -> added
same ID, new metadata -> changed/replaced
same ID, unchanged    -> retained
missing from an authoritative source snapshot -> removed
temporarily failed source -> previous capabilities preserved

So if you add a new MCP entry to the catalog and run the update, its capabilities are added to the existing universe. If you remove an MCP from an authoritative catalog, its capabilities are removed. A source failure is not treated as deletion.

For a standalone capabilities JSON file, implement a CapabilitySource that reads that file and returns a CapabilityDiscoveryResult; update() uses the source snapshot and does not automatically scan arbitrary files placed beside the index.

Frozen V3 pipeline

user request
    -> deterministic spaCy operational-intent analysis
    -> capability-oriented retrieval text
    -> Qwen dense retrieval
    -> Min-4 + Bounded Max Gap selection
    -> merge and deduplicate
    -> session capability state
    -> final active capability context
    -> host agent
Embedding:        Qwen/Qwen3-Embedding-0.6B
Analyzer:         en_core_web_trf
Representation:   capability name + description
MIN_TOOLS:        4 per intent
MAX_TOOLS:        16 per intent
MIN_GAP_PERCENT:  2.0
TTL:              8 turns
Active cap:       30 capabilities

Brown Octopus is intentionally recall-oriented for its first production version. It prefers a bounded set of plausible capabilities over aggressively pruning and risking a missing required capability. It does not guarantee perfect recall.

Results and sessions

result = octopus.retrieve_result(query, session_id="conversation-123")
result.retrieved_tools  capabilities selected on this turn
result.tools            final active context after TTL/session management
result.tool_ids         IDs in result.tools
result.session_id       session identifier
result.turn             session turn number

Expose result.tools to the agent. Brown Octopus returns definitions and metadata only; the host binds and executes tools.

One engine can serve many isolated conversations. Models, indexes, and retrievers are shared; turn counters, TTL state, and active capabilities are session-specific.

octopus.reset_session("conversation-123")
octopus.delete_session("conversation-123")
snapshot = octopus.get_session("conversation-123")

The default InMemorySessionStore keeps serializable capability state in process. Applications needing persistence can inject a custom store:

octopus = Octopus(session_store=my_store)

Custom stores must make session mutation atomic across workers/processes. Brown Octopus stores capability state, not conversation history.

Building and updating the capability index

Brown Octopus separates model setup, capability discovery/indexing, and normal runtime initialization:

setup-models       prepare runtime models
    -> update()    discover capabilities and build/update the index
    -> initialize() load the existing index for runtime use

Prepare models first:

uv add brown-octopus
uv run brown-octopus setup-models
uv run brown-octopus doctor

The repository includes a runnable index setup example:

python examples/setup_index.py

By default it reads data/mcps.json and writes data/indexes/default. Paths can be changed explicitly:

python examples/setup_index.py \
  --catalog path/to/my-mcps.json \
  --index path/to/my-index

The same operation can be performed in application code:

from brown_octopus import Octopus


async def build_index():
    octopus = Octopus(
        catalog_path="data/mcps.json",
        index_path="data/indexes/default",
    )
    report = await octopus.update()
    print(report.tool_count)

update() synchronizes the configured capability source. It currently rediscovers all configured sources and rebuilds embeddings for the complete resulting universe before atomically publishing the new snapshot. It does not yet provide a separate additive-only or incremental-embedding operation.

Capabilities are compared by stable identity:

new capability       -> added
same ID, new metadata -> changed/replaced
same ID, unchanged    -> retained
missing from an authoritative snapshot -> removed
temporarily failed source -> previous capabilities preserved

Therefore, to add an MCP while preserving the existing universe, add it to the existing catalog and run update() again:

data/mcps.json
├── existing MCP servers
└── new MCP server

Passing a separate file containing only the new MCP makes that file the configured source snapshot; it does not automatically append to the previous catalog. An arbitrary capabilities JSON file is not scanned automatically. For that case, implement a CapabilitySource that reads the file and returns a CapabilityDiscoveryResult.

The default source is MCP-backed, but the abstraction is provider-neutral:

octopus = Octopus(capability_source=my_source)
report = await octopus.update()

Capability identity fields are:

capability_id  stable globally unique capability identity
source_id      discovery provenance
mcp_url        execution endpoint when applicable

The host controls when discovery occurs. Brown Octopus does not run a scheduler or rediscover capabilities during initialize().

Model storage and diagnostics

Override the managed model directory for containers or shared volumes with BROWN_OCTOPUS_MODEL_DIR. Model setup remains explicit:

brown-octopus setup-models
brown-octopus doctor
brown-octopus inspect
brown-octopus inspect --json

doctor checks package, model, and index readiness. inspect reports the active index and frozen configuration without exposing credentials.

Architecture boundary

Brown Octopus owns intent analysis, capability retrieval/selection, index construction, active capability context, session capability state, and explicit capability updates.

The host owns the LLM, conversation history, tool binding/execution, credentials, authentication, authorization, user identity, refresh timing, and session lifecycle policy.

Brown Octopus is harness-agnostic. A LangGraph integration example is available at examples/langgraph_app; LangGraph is not a runtime dependency.

Development

uv sync
brown-octopus setup-models
uv run pytest -m "not external"
uv build

Historical evaluation infrastructure remains under evals/, benchmark data under data/evals/, and research outputs under results/. These are separate from the installable brown_octopus package.

See LICENSE for licensing information.

Metadata

Release files for brown-octopus 0.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brown-octopus 0.4.5
File Size Uploaded
brown_octopus-0.4.5.tar.gz 31.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for brown-octopus 0.4.5
File Interpreter ABI Platform
brown_octopus-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 70.7 kB

Release files / brown_octopus-0.4.5.tar.gz

Download URL brown_octopus-0.4.5.tar.gz
Size 31.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cb416ecb151ccd487d027a22f666e49173544d4d9c617d2881960f82edb75363
BLAKE2b-256 checksum
How to use checksums
01a49800c7ce465b3bdb48cbc2885d752e1ee61f9efd8389a3ed4a2509e10ec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / brown_octopus-0.4.5-py3-none-any.whl

Download URL brown_octopus-0.4.5-py3-none-any.whl
Size 39.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fb3118852a62f5c82e3e7ad97b0fbd08f7e415f0cfd66fd9e2301f543931a01
BLAKE2b-256 checksum
How to use checksums
25547c31949b463c2bc1b8e2a98bfa66667ce95d1c077e9060838ad07cada53b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

This release

0.4.5 This release

2 release files

0.4.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page