Skip to main content

coactra

Component-based composition library for agentic systems. Coactra is Team-first: Team owns agent registration, policy, and model resolution, while Agent remains a thin runtime shell over pydantic-ai.

pip install "coactra[agent]"

Common extras:

pip install "coactra[agent-gateway,oauth]"  # MCP gateway and OAuth
pip install "coactra[graphiti]"
pip install "coactra[mem0]"

Small Surface

from coactra import Team, Scope, Policy, Skill

Submodule helpers when wiring backends:

from coactra.agent import MCPServer

Use the root surface for application code. Use lower-level modules only for backends and host runtime wiring:

  • coactra.agent for event/runtime types and outbound A2A transport (coactra.agent.backends)
  • coactra.team.directory for org/member/seat persistence
  • coactra.memory and coactra.workspace for backend integration

Threads

A Thread is one conversation: a Scope-keyed message log that any agent in the same tenant can continue. Pass it to send()/run() — each finished run replaces the thread's messages with the full history, so handoffs keep context.

from coactra import InMemoryThreadStore, Scope, Thread

store = InMemoryThreadStore()
scope = Scope(tenant_id="local", session_id="chat-42")
thread = await store.load(scope) or Thread(scope=scope)

await agent.run("Where did we leave off?", thread=thread)
await reviewer.run("Continue the plan.", thread=thread)  # same history, other agent

await store.save(thread)  # persistence is explicit; hosts implement ThreadStore

Thread messages are opaque runtime objects. For JSON persistence with the default pydantic-ai runtime, use dump_messages / load_messages from coactra.agent.runtime. Threads are the verbatim conversation log; memory stays the long-term extracted store — the two are independent.

Governance

Gate dangerous tools behind human approval, cap usage per run, and cancel runs:

from coactra import AgentSpec, Limits, Scope, Thread

spec = AgentSpec(
    name="coder",
    model="openai:gpt-5",
    tools=[shell, read_file],
    require_approval=("shell",),          # these tools pause for a human
    limits=Limits(total_tokens=200_000),  # per-run cap; send(limits=...) overrides
)

thread = Thread(scope=Scope(tenant_id="local", session_id="job-7"))
result = await (await agent.send("fix the build", thread=thread)).wait()
if result.status == "paused":
    # show result.pending (tool name + args) to a human, then:
    approvals = {p.id: True for p in result.pending}  # False denies
    result = await (await agent.resume(approvals, thread=thread)).wait()

run = await agent.send("long job", thread=thread)
run.cancel()  # interrupts wait(); streams stop at the next event boundary

A Policy also governs tools: when policy.check returns requires_approval for action="tool:call", that tool is gated; deny removes it from the agent. The pause lives entirely in the thread's messages, so any same-tenant agent can resume it — even after a process restart, via your ThreadStore.

Bring Existing Pieces

import asyncio
import os

from coactra import Team
from coactra.agent import MCPServer


async def main() -> None:
    team = Team.local(
        tenant_id="local",
        namespace="default",
        capability="existing-stack",
        model="openai/qwen3.6-plus",
        api_base="https://opencode.ai/zen/go/v1",
        api_key=os.environ["OC_KEY"],
    )
    agent = await team.add_agent(
        name="existing-stack-agent",
        tools=[MCPServer(url="https://tools.example/mcp", name="tools")],
        memory="inprocess",
        workspace="./desk",
    )
    try:
        print(await agent.run("Use my existing stack"))
    finally:
        await agent.aclose()


asyncio.run(main())

See examples/acceptance/ for the checked examples that define the alpha acceptance path.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coactra-0.6.0.tar.gz (140.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coactra-0.6.0-py3-none-any.whl (123.4 kB view details)

Uploaded Python 3

File details

Details for the file coactra-0.6.0.tar.gz.

File metadata

  • Download URL: coactra-0.6.0.tar.gz
  • Upload date:
  • Size: 140.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for coactra-0.6.0.tar.gz
Algorithm Hash digest
SHA256 98a143cd3d7062ec9898591306e6dc69ea54c7ff2ba9bf96d2d547d683568309
MD5 cc92f99077cc5ed339c93950e5740612
BLAKE2b-256 83681c9a862ba8862b45b79bacce8491ce57f86b784c98cfbc951bcd21f2feef

See more details on using hashes here.

Provenance

The following attestation bundles were made for coactra-0.6.0.tar.gz:

Publisher: release.yml on DataOpsFusion/coactra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coactra-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: coactra-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 123.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for coactra-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c07332971a2039866807338b4daac6f3590e125cb1658139fee9d4900c8a714f
MD5 bd568ce6b16630067944ced82f91cfa6
BLAKE2b-256 667da839a7425a02a9959b96c1b69ccd15fd0accdc3a6c52fe78be2106949fac

See more details on using hashes here.

Provenance

The following attestation bundles were made for coactra-0.6.0-py3-none-any.whl:

Publisher: release.yml on DataOpsFusion/coactra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.7.0

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.1.0

2 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