> built 2026-11-23 07:47 UTC from df1ee7c (main) · coact 0.0.4. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# coact

**Reuse your “AI stuff” across the layers of the modern agent stack.** `coact` (“co-act” — skills and agents acting as one reusable substrate) turns the skills you already have into agent definitions, and turns those definitions into agents that actually run.

```default
python functions/scripts  →  .claude/skills/  →  .claude/agents/  →  running agents
        (py2mcp, aw)            (skill pkg)        COMPLETE (coact)    REALIZE (coact)
```

`coact` owns the two transitions the rest of the ecosystem doesn’t:

- **COMPLETE** — start from a `.claude/skills/` skill and *complete* it into a `.claude/agents/` definition: add the agent-only extras (persona, return contract, tool allowlist, model, memory) that a skill doesn’t carry.
- **REALIZE** — take a completed definition and produce something that runs, choosing the right backend (the host agent, the Claude Agent SDK, or MCP-exposed tools for a foreign host).

It is glue, not a new framework: it builds on [`skill`](https://github.com/thorwhalen/skill) (skill data model + registries), [`aw`](https://github.com/thorwhalen/aw) (the `AgenticStep` runtime), and [`py2mcp`](https://github.com/i2mint/py2mcp) (Python → MCP). See [`misc/docs/REUSE.md`]().

## Install

```bash
pip install coact            # core: COMPLETE + host realize + analysis (no LLM needed)
pip install coact[sdk]       # + the Claude Agent SDK realize backend (and aw)
pip install coact[mcp]       # + the py2mcp/FastMCP realize backend
pip install coact[litellm]   # + the provider-agnostic LiteLLM realize backend
pip install coact[langgraph] # + the LangGraph realize backend (langchain+langgraph >= 1.0; bundles langchain-openai)
pip install coact[crewai]    # + the CrewAI realize backend
```

## Quick start

<!-- wads-docs: skip needs a skill in the reader project or an LLM key -->
```python
from coact import complete, emit_agent, realize

# 1. Complete a skill into an agent definition (mechanical — no LLM).
agent = complete(".claude/skills/ux-analyst")

# 2. See it: a valid .claude/agents/ markdown file.
print(emit_agent(agent, "claude-agents-md"))

# 3. Realize it the cheap way: materialize files so Claude Code runs it.
realize(agent, backend="host")
```

Prefer to look before you leap? Everything has a dry-run:

<!-- wads-docs: skip needs a skill in the reader project or an LLM key -->
```python
from coact import plan_completion

plan = plan_completion(".claude/skills/ux-analyst")
print(plan.render())   # every synthesized field + WHERE it came from + warnings
```

That extends to the one backend that touches disk: `realize(agent, backend="host", dry_run=True)` returns the agent files and skill links it *would* write — without creating any of them.

A complete, runnable walk through all of this — a real skill → `complete` → `emit` → `realize(host)` → `realize(sdk)` → `estimate`/`inventory` — lives in [`examples/`]() (no LLM, no API key needed):

```bash
python examples/walkthrough.py
```

### CLI

```bash
coact plan      .claude/skills/ux-analyst                 # dry-run with provenance
coact complete  .claude/skills/ux-analyst --dest .claude/agents
coact emit      .claude/skills/ux-analyst --target sdk-agent-dict   # a non-default emit target
coact realize   .claude/skills/ux-analyst --backend host
coact realize   .claude/skills/ux-analyst --backend host --dry-run   # preview; writes nothing
coact diff      .claude/skills/ux-analyst .claude/agents/ux-analyst.md
coact estimate  .claude/agents/a.md .claude/agents/b.md   # the cost gate
coact inventory .                                         # skills + agents + MCP tools
coact back      .claude/agents/ux-analyst.md              # lossy agent → skill stub
coact scaffold  .claude/agents/a.md .claude/agents/b.md   # a starter fleet shim (you own it)
coact publish   mypkg.tools:summarize --name my-tools --dry-run   # → a Claude .mcpb (preview)
coact describe  "a tool that looks up the weather for a city"     # NL → a draft IntegrationSpec
```

## Publish — ship a capability to a chatbot host

Beyond COMPLETE/REALIZE, the **PUBLISH** axis packages a capability (Python tools) as a deployable chatbot integration. The first target, `claude-local-mcpb`, builds a **Claude Desktop `.mcpb` Desktop Extension** — a one-click *local* (stdio) MCP server, built by [`py2mcp`](https://github.com/i2mint/py2mcp):

```python
from coact import publish

publish(["mypkg.tools:summarize", "mypkg.tools:translate"],
        name="text-tools", dest="dist")          # → dist/text-tools.mcpb
```

Sources can be `module:function` refs, live callables, or a skill carrying a `coact: mcp:` block. `dry_run=True` (or `--dry-run`) previews the bundle without writing it. This is the **local** surface (stdio, no OAuth). Install: `pip install coact[mcpb]`.

For the **remote** surface — a claude.ai *custom connector* (a hosted Streamable-HTTP MCP server reached from Anthropic’s cloud over HTTPS + OAuth 2.1) — use the `claude-remote-connector` target, which scaffolds a deployable service:

```python
from coact import publish_remote
publish_remote(["mypkg.tools:summarize"], name="my-conn", dest="out",
               connector_url="https://my-conn.example.com",   # this server's public URL
               idp_issuer="https://my-idp.example.com")        # your managed IdP
# → out/my-conn-connector/  (server/app.py + connector_config.json + DEPLOY.md + …)
```

The scaffold is an OAuth 2.1 **resource server** (validates a managed IdP’s audience-bound JWTs; never issues tokens) built by [`py2mcp`](https://github.com/i2mint/py2mcp)’s `http.mk_http_app`; coact writes the deploy packaging, py2mcp/FastMCP serves the MCP. Follow the generated `DEPLOY.md`. Claude Code plugins, ChatGPT Apps, and Gemini are further planned targets on the same open-closed registry. Background: [`misc/docs/CHATBOT_INTEGRATION_LANDSCAPE.md`]().

There are two ways to get an `IntegrationSpec`. The **mechanical** ingress above (refs / callables / skills) uses **no LLM**. The **opt-in** ingress refines a natural-language description into a *draft* spec — proposed tools with inferred input schemas — routing generation through [`aix`](https://github.com/thorwhalen/aix) (multi-provider) via [`oa`](https://github.com/thorwhalen/oa):

```python
from coact import integration_spec_from_description

# This routes through aix/oa — it makes a real LLM call (needs a configured
# provider). Inject `llm=<callable>` to run it offline (e.g. in tests).
spec = integration_spec_from_description("expose os.path.basename as a tool")
print(spec.render())   # a DRAFT: a tool becomes a runnable ref only if the model
                       # binds it to module:function code — else it stays proposed
```

The draft is a **design artifact**: tools without a `module:function` handler are *proposed* (won’t run until you bind them to real code). The LLM touches **only** this path — the code → `.mcpb` path stays LLM-free (`DECISIONS.md` D10/D18). Install: `pip install coact[nl]`.

## The model in one minute

A `SKILL.md` is *procedural knowledge injected into the caller’s turn*; a subagent is *a separate worker with its own context, persona, tools, model, and a defined return value*. They overlap heavily — **an agent is mostly a skill plus a thin “extras” envelope.** COMPLETE synthesizes that envelope; the two extras that actually matter are:

1. the **persona** (system prompt / identity), and
2. the **return contract** (a schema so a manager can consume the agent’s output).

`coact` keeps the **skill on disk as the single source of truth** and makes the agent *reference* it by name — it never copies a skill body into an agent. One `AgentDefinition` object serializes to both the filesystem `.claude/agents/*.md` and the Agent SDK form.

### The `coact:` frontmatter (optional)

To make the lift reproducible, a skill may carry an additive `coact:` block (ignored by every other tool). When present it wins over policy; when absent `coact` infers + reports what it guessed.

```yaml
---
name: ux-analyst
description: Analyze a captured UX evidence bundle for usability issues.
coact:
  tools: [Read, Grep, Glob]
  model: sonnet
  memory: project
  returns:
    schema_ref: ov.schemas:UxFindings
  mcp:
    - module: ov.analyzers
      functions: [score_contrast, find_tap_targets]
---
```

## Realization backends

| backend          | what “running” means                                                                                                                                                                                               | cost                  |
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| `host` (default) | materialize `.claude/agents/*.md` + link skills; the **host agent** (Claude Code) executes                                                                                                                         | cheapest — no fan-out |
| `sdk`            | a `RunnableAgent` backed by the Claude Agent SDK that **satisfies `aw.AgenticStep`** (`execute(input, context) -> (artifact, info)`), so it drops into `aw` workflows                                              | in-process            |
| `mcp`            | expose a skill’s declared Python tools as a FastMCP server (via `py2mcp`) for any MCP client                                                                                                                       | tool server           |
| `litellm`        | a `RunnableLLMAgent` (also `aw.AgenticStep`) backed by **LiteLLM** — realize the *same* definition against any provider (OpenAI, Gemini, Mistral, Ollama, …); proof the definition isn’t Anthropic-specific        | in-process            |
| `langgraph`      | a `RunnableLLMGraphAgent` (also `aw.AgenticStep`) backed by a LangGraph `CompiledStateGraph` (`langchain.agents.create_agent`); the graph is **exposed** (`.agent`) to drop as a node into *your own* `StateGraph` | in-process            |
| `crewai`         | a `RunnableCrewAIAgent` (also `aw.AgenticStep`) backed by a single `crewai.Agent` (`Agent.kickoff`); the `Agent` is **exposed** (`.agent`) for *your own* `Crew`                                                   | in-process            |
<!-- wads-docs: skip needs a skill in the reader project or an LLM key -->
```python
agent_step = realize(agent, backend="sdk")          # aw-compatible runnable
artifact, info = agent_step.execute(task, context={})

server = realize(".claude/skills/ux-analyst", backend="mcp")   # FastMCP handle

# same definition, a different provider — map model selectors however you like
llm_step = realize(agent, backend="litellm", model_map={"sonnet": "openai/gpt-4o"})
artifact, info = llm_step.execute(task)             # info["backend"] == "litellm"

# one definition → a LangGraph node / CrewAI Agent you compose into your own topology
graph_step = realize(agent, backend="langgraph")    # graph_step.agent is a CompiledStateGraph
crew_step  = realize(agent, backend="crewai")       # crew_step.agent is a crewai.Agent
```

## Two boundaries to know

- **Topology is out of scope.** A subagent definition can’t express graphs, conditional edges, or cycles, and subagents can’t spawn subagents. `coact` emits *definitions + tool/MCP wiring* and stops. Multi-agent orchestration is left to the host’s manager or a thin shim you own (against the Agent SDK or `aw`’s workflow chaining) — `coact` is not LangGraph. It *can* realize a single definition **into** a LangGraph node or a CrewAI `Agent` (the `langgraph`/`crewai` backends above), but it builds no graph or crew of its own — you compose the exposed `.agent` into *your* topology.
- **A running fleet is an optimization, not a default.** Multi-agent fan-out costs roughly an order of magnitude more tokens, and the premium is worst on *interdependent* tasks. So `backend="host"` (one agent runs the skills) is the default, and `coact estimate` shows the tradeoff before you spawn a fleet:

<!-- wads-docs: skip needs a skill in the reader project or an LLM key -->
```python
from coact import estimate
print(estimate([agent_a, agent_b]).render())
```

If you do decide to fan out, `scaffold_fleet` emits a **starter** Python shim wiring the realized agents under an `aw` coordinator — a sequential hand-off you then reshape. It’s the one topology-adjacent thing `coact` writes, and only a starter: `coact` emits it once and never runs it (the topology stays yours).

<!-- wads-docs: skip needs a skill in the reader project or an LLM key -->
```python
from coact import scaffold_fleet
scaffold_fleet([agent_a, agent_b], dest="fleet.py")   # a runnable starter you own
```

## Design notes

- No LLM on any mechanical path; persona drafting is *optional* and injected (`complete(skill, llm=...)`), never a hard provider dependency.
- Open-closed registries for emit targets (`claude-agents-md`, `sdk-agent-dict`, plus `crewai` / `openai-tools` auto-registered when [`aw`](https://github.com/thorwhalen/aw) is installed) and realization backends — register your own without touching core.
- Decisions are recorded in [`misc/docs/DECISIONS.md`](); the build brief is [`misc/docs/COACT_SPEC.md`]().

## Skills

This package ships agent skills you can install into any agent host with [`gh skill`](https://cli.github.com/manual/gh_skill) (don’t have it? [install gh](https://cli.github.com/)):

```bash
gh skill install thorwhalen/coact coact --agent claude-code
gh skill install thorwhalen/coact coact-complete --agent claude-code
gh skill install thorwhalen/coact coact-realize --agent claude-code
gh skill install thorwhalen/coact coact-analyze --agent claude-code
gh skill install thorwhalen/coact coact-publish --agent claude-code
gh skill install thorwhalen/coact coact-dev --agent claude-code
gh skill install thorwhalen/coact ai-assistant-architect --agent claude-code
gh skill install thorwhalen/coact ai-assistant-chat-ui --agent claude-code
gh skill install thorwhalen/coact ai-assistant-prompts-skills --agent claude-code
gh skill install thorwhalen/coact ai-assistant-command-mcp --agent claude-code
gh skill install thorwhalen/coact ai-assistant-agent-runtime --agent claude-code
```

| Skill                         | Use it when…                                                                                                                                       |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| `coact`                       | starting with coact — routing to the right capability (turn skills into agents, reuse AI assets across the stack)                                  |
| `coact-complete`              | turning a `.claude/skills/` skill into a `.claude/agents/` agent definition (COMPLETE)                                                             |
| `coact-realize`               | turning an agent definition (or skill) into something that runs — host / Agent SDK / LiteLLM / LangGraph / CrewAI / MCP backends (REALIZE)         |
| `coact-analyze`               | inspecting or moving between skill/agent layers — diff, fleet cost estimate, inventory, or harvesting an agent back into a skill                   |
| `coact-publish`               | packaging a Python capability or skill into a Claude Desktop `.mcpb` extension or remote claude.ai connector                                       |
| `coact-dev` (developer)       | developing, debugging, or extending the coact package itself — emit targets, realize backends, COMPLETE/REALIZE internals                          |
| `ai-assistant-architect`      | adding, auditing, or maintaining an embedded AI assistant (chat + agentic) in your own app — the entry point that routes to the focused sub-skills |
| `ai-assistant-chat-ui`        | building or auditing the chat UI / streaming / wire-protocol layer (React + Vite + shadcn, SSE, assistant-ui, Vercel AI SDK)                       |
| `ai-assistant-prompts-skills` | managing system prompts, user-editable prompts, or Anthropic-style skills (prompt registry, versioning, evals)                                     |
| `ai-assistant-command-mcp`    | exposing application operations to an assistant via tools / function-calling / MCP (command dispatch → MCP, approval flow, scoping)                |
| `ai-assistant-agent-runtime`  | adding or refactoring the agent runtime — the multi-step tool-using loop, optionally with durable execution                                        |
<p class="epythet-aggregates">This documentation as a single file: <a href="coact.md">coact.md</a> (Markdown, for agents).</p>


# _autosummary/coact.analysis.html.md

# coact.analysis

Analysis utilities — small tools to *see and move between* the layers.

COACT_SPEC §7. Thin tooling around the two transforms:

- [`diff()`](_autosummary/coact.analysis.html.md#coact.analysis.diff) — what extras an agent adds over its source skill (audit drift
  between the SSOT skill and a derived agent).
- [`estimate()`](_autosummary/coact.analysis.html.md#coact.analysis.estimate) — the §3.5 / DECISIONS-D9 cost gate: the implied fan-out token
  multiplier of an agent set, flagging interdependent sets where multi-agent is a
  poor fit.
- [`inventory()`](_autosummary/coact.analysis.html.md#coact.analysis.inventory) — enumerate a project’s reusable AI assets: skills, derived
  agents, and MCP-exposed tools (reuses `skill` discovery; adds the agent + MCP
  dimensions).
- [`back()`](_autosummary/coact.analysis.html.md#coact.analysis.back) — best-effort, **lossy** agent→skill extraction (harvest an ad-hoc
  agent back into reusable procedural knowledge).

### Functions

| [`back`](_autosummary/coact.analysis.html.md#coact.analysis.back)(agent)          | Best-effort, **lossy** agent→skill extraction (harvest an agent into a skill).   |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [`diff`](_autosummary/coact.analysis.html.md#coact.analysis.diff)(skill, agent)   | Show what extras `agent` adds over its source `skill`.                           |
| [`estimate`](_autosummary/coact.analysis.html.md#coact.analysis.estimate)(agents)     | Surface the fan-out cost tradeoff for an agent set (DECISIONS D9).               |
| [`inventory`](_autosummary/coact.analysis.html.md#coact.analysis.inventory)([project]) | Enumerate skills, derived agents, and MCP-exposed tools in a project.            |

### Classes

| [`AgentDiff`](_autosummary/coact.analysis.html.md#coact.analysis.AgentDiff)(skill_name, agent_name[, rows])       | What a derived agent adds over its source skill.                        |
|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
| [`Estimate`](_autosummary/coact.analysis.html.md#coact.analysis.Estimate)(n_agents, interdependent, ...)         | The implied cost tradeoff of realizing an agent set as a running fleet. |
| [`Inventory`](_autosummary/coact.analysis.html.md#coact.analysis.Inventory)(project[, skills, agents, mcp_tools]) | One picture of a project's reusable AI assets.                          |

### *class* coact.analysis.AgentDiff(skill_name, agent_name, rows=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

What a derived agent adds over its source skill.

#### render()

Render the extras table for terminal display.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* coact.analysis.Estimate(n_agents, interdependent, shared_skills, token_multiplier_vs_chat, recommendation)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The implied cost tradeoff of realizing an agent set as a running fleet.

#### render()

Render the cost gate for terminal display.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* coact.analysis.Inventory(project, skills=list(), agents=list(), mcp_tools=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One picture of a project’s reusable AI assets.

#### render()

Render the inventory for terminal display.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.analysis.back(agent)

Best-effort, **lossy** agent→skill extraction (harvest an agent into a skill).

Strips the persona/return-contract envelope down to a reusable skill stub
(name + description + a pointer to the skills it referenced). The actual
procedure usually lives in those referenced skills, so this cannot recover
it — the result is a starting point the user fleshes out, not a faithful
inverse of COMPLETE.

```pycon
>>> from coact import AgentDefinition
>>> sk = back(AgentDefinition(name='ux', description='Analyze.', skills=['ux', 'shared']))
>>> sk.meta.name
'ux'
>>> 'lossy' in sk.body.lower()
True
```

* **Return type:**
  `Skill`

### coact.analysis.diff(skill, agent)

Show what extras `agent` adds over its source `skill`.

`skill` is any skill source; `agent` is an `AgentDefinition`, an
agent `*.md` path, or a skill source (which is completed first).

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='ux', description='Analyze bundles.'), body='steps')
>>> from coact import complete
>>> d = diff(s, complete(s))
>>> any(f == 'prompt' and cls.startswith('extra') for f, cls, _ in d.rows)
True
```

* **Return type:**
  [`AgentDiff`](_autosummary/coact.analysis.html.md#coact.analysis.AgentDiff)

### coact.analysis.estimate(agents)

Surface the fan-out cost tradeoff for an agent set (DECISIONS D9).

```pycon
>>> from coact import AgentDefinition
>>> a = AgentDefinition(name='a', description='x', skills=['shared'])
>>> b = AgentDefinition(name='b', description='y', skills=['shared'])
>>> est = estimate([a, b])
>>> est.interdependent, est.shared_skills
(True, ['shared'])
```

* **Return type:**
  [`Estimate`](_autosummary/coact.analysis.html.md#coact.analysis.Estimate)

### coact.analysis.inventory(project=None)

Enumerate skills, derived agents, and MCP-exposed tools in a project.

```pycon
>>> import tempfile
>>> inv = inventory(tempfile.mkdtemp())
>>> inv.skills, inv.agents
([], [])
```

* **Return type:**
  [`Inventory`](_autosummary/coact.analysis.html.md#coact.analysis.Inventory)


# _autosummary/coact.base.html.md

# coact.base

Core data model for coact — the single in-memory representation of an agent.

This module is the spine described in COACT_SPEC §3.1/§5.2: an
[`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) is *one* object that can serialize to **both** the
filesystem `.claude/agents/*.md` format and the Claude Agent SDK form (see
[`coact.emit`](_autosummary/coact.emit.html.md#module-coact.emit)). It is a lossless **superset** of the host subagent schema,
kept independent of the SDK type (DECISIONS D2) so coact’s core carries no SDK
or LLM import.

Three dataclasses live here:

- [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract) — the agent’s final-message schema (so a manager can
  deterministically consume its output); the single most important “extra”.
- [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) — the SSOT object.
- [`AgentPlan`](_autosummary/coact.base.html.md#coact.base.AgentPlan) / [`FieldProvenance`](_autosummary/coact.base.html.md#coact.base.FieldProvenance) — the inspectable dry-run result
  of COMPLETE, recording where every synthesized field came from.

### Module Attributes

| [`ModelName`](_autosummary/coact.base.html.md#coact.base.ModelName)        | Host model selector values (the Agent SDK `model` literal).            |
|-------------------------------------------------------------------|------------------------------------------------------------------------|
| [`MemoryScope`](_autosummary/coact.base.html.md#coact.base.MemoryScope)      | Subagent memory scope.                                                 |
| [`ProvenanceSource`](_autosummary/coact.base.html.md#coact.base.ProvenanceSource) | Provenance source tags — where a synthesized field's value originated. |

### Classes

| [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)(name, description[, prompt, ...])   | The SSOT: one object, two serializations (filesystem md + SDK form).                                                |
|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [`AgentPlan`](_autosummary/coact.base.html.md#coact.base.AgentPlan)(agent[, provenance, warnings])            | The inspectable result of `plan_completion`: the agent + its provenance.                                            |
| [`FieldProvenance`](_autosummary/coact.base.html.md#coact.base.FieldProvenance)(field, value, source[, note])       | Where one [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) field's value came from (dry-run audit). |
| [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract)([json_schema, ref, description])     | The agent's return contract: its final-message schema + a human summary.                                            |

### *class* coact.base.AgentDefinition(name, description, prompt='', tools=None, disallowed_tools=list(), model=None, skills=list(), memory=None, mcp_servers=list(), permission_mode=None, returns=ReturnContract(), consumes=None, source_skill=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The SSOT: one object, two serializations (filesystem md + SDK form).

Fields mirror the host subagent schema (snake_case here; coact owns the
mapping to the host’s camelCase frontmatter names in [`coact.emit`](_autosummary/coact.emit.html.md#module-coact.emit)),
plus the coact-specific `returns` / `consumes`. `tools=None`
means *inherit all tools*; an empty list means *no tools* — the distinction
is preserved.

```pycon
>>> ad = AgentDefinition(name='ux-analyst', description='Analyze UX bundles.')
>>> ad.name, ad.tools, ad.returns.is_empty()
('ux-analyst', None, True)
```

#### source_skill *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]* *= None*

Canonical key/name of the source skill this agent was completed from.

### *class* coact.base.AgentPlan(agent, provenance=list(), warnings=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The inspectable result of `plan_completion`: the agent + its provenance.

Shows the proposed [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) and, for each field, *why* it has
its value — so a user can review before any file is written or agent spawned
(progressive disclosure: dry-run first).

#### render()

Render a human-readable provenance table for terminal display.

```pycon
>>> plan = AgentPlan(
...     agent=AgentDefinition(name='x', description='y'),
...     provenance=[FieldProvenance('model', 'sonnet', 'policy', 'worker')],
... )
>>> 'model' in plan.render() and 'policy' in plan.render()
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* coact.base.FieldProvenance(field, value, source, note='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Where one [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) field’s value came from (dry-run audit).

```pycon
>>> FieldProvenance('model', 'sonnet', 'policy', 'default worker').source
'policy'
```

### coact.base.MemoryScope

Subagent memory scope.

alias of [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[‘user’, ‘project’, ‘local’]

### coact.base.ModelName

Host model selector values (the Agent SDK `model` literal).

alias of [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[‘sonnet’, ‘opus’, ‘haiku’, ‘inherit’]

### coact.base.ProvenanceSource

Provenance source tags — where a synthesized field’s value originated.

alias of [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[‘skill’, ‘coact-frontmatter’, ‘policy’, ‘inferred’, ‘synthesized-template’, ‘synthesized-llm’, ‘default’]

### *class* coact.base.ReturnContract(json_schema=dict(), ref=None, description='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The agent’s return contract: its final-message schema + a human summary.

Skills return nothing; agents must define a consumable output. The canonical
form is a JSON Schema dict (portable across realization backends, DECISIONS
D6). `ref` records a `'module:Name'` source if the schema was resolved
from a Pydantic model / dataclass / TypedDict.

```pycon
>>> rc = ReturnContract(json_schema={'type': 'object'}, description='findings')
>>> rc.is_empty()
False
>>> ReturnContract().is_empty()
True
```

#### *classmethod* from_dict(d)

Parse from a `coact: returns` mapping (accepts `schema_ref` or `json_schema`).

```pycon
>>> ReturnContract.from_dict({'schema_ref': 'ov.schemas:UxFindings'}).ref
'ov.schemas:UxFindings'
```

* **Return type:**
  [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract)

#### is_empty()

True when no schema (inline or ref) has been set.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### schema()

Return the canonical JSON Schema, resolving `ref` if needed (else `{}`).

Honors DECISIONS D6 (“JSON Schema is canonical; refs resolve to it”): an
inline `json_schema` wins; otherwise a `module:Name` `ref` is
resolved best-effort to a schema. Returns `{}` when neither is available.

```pycon
>>> ReturnContract(json_schema={'type': 'object'}).schema()
{'type': 'object'}
>>> 'properties' in ReturnContract(ref='coact.base:ReturnContract').schema()
True
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### to_dict()

Serialize to a plain dict (for the agent-md `coact:` block), omitting empties.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)


# _autosummary/coact.emit.html.md

# coact.emit

Emitters: one [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) → many serializations.

COACT_SPEC §5.3. Emit targets are an open-closed `skill`-style
`Registry` (register, don’t hardcode). Two ship by
default:

- `claude-agents-md` — the filesystem `.claude/agents/<name>.md` (host
  frontmatter using the host’s exact camelCase field names + the persona body).
  coact-specific fields (the return contract, `consumes`, `source_skill`) are
  carried in an additive `coact:` frontmatter sub-block so the round-trip is
  lossless and the host still ignores them. Reuses `skill.base` frontmatter
  helpers — coact writes no YAML by hand.
- `sdk-agent-dict` — kwargs for `claude_agent_sdk.AgentDefinition` plus the
  leftover `query()` options, built by **introspecting** the installed SDK
  dataclass so it degrades gracefully across SDK versions (DECISIONS D2). The
  SDK is imported lazily here only; core stays SDK-free.

Future emitters (CrewAI / OpenAI via the `aw` adapter) register without
touching this module. Topology is never emitted (DECISIONS D8).

### Module Attributes

| [`emitters`](_autosummary/coact.emit.html.md#coact.emit.emitters)   | `AgentDefinition -> serialized form` (str or dict).   |
|-------------------------------------------------------------|-------------------------------------------------------|

### Functions

| [`agent_to_frontmatter`](_autosummary/coact.emit.html.md#coact.emit.agent_to_frontmatter)(ad)       | Build the host frontmatter dict for an agent (omitting empty fields).           |
|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [`emit_agent`](_autosummary/coact.emit.html.md#coact.emit.emit_agent)(ad[, target, dest]) | Emit an agent to a registered target; optionally write a file target to `dest`. |
| [`from_claude_agent_md`](_autosummary/coact.emit.html.md#coact.emit.from_claude_agent_md)(text)     | Parse `.claude/agents/*.md` content back into an `AgentDefinition`.             |
| [`to_aw_agent_spec`](_autosummary/coact.emit.html.md#coact.emit.to_aw_agent_spec)(ad)           | Adapt an `AgentDefinition` to an `aw.translators.AgentSpec`.                    |
| [`to_claude_agent_md`](_autosummary/coact.emit.html.md#coact.emit.to_claude_agent_md)(ad)         | Serialize an agent to `.claude/agents/<name>.md` content.                       |
| [`to_sdk_agent_dict`](_autosummary/coact.emit.html.md#coact.emit.to_sdk_agent_dict)(ad)          | Build Agent-SDK kwargs + leftover query options for one agent.                  |

### coact.emit.agent_to_frontmatter(ad)

Build the host frontmatter dict for an agent (omitting empty fields).

```pycon
>>> ad = AgentDefinition(name='x', description='y', tools=['Read'], model='haiku')
>>> fm = agent_to_frontmatter(ad)
>>> fm['name'], fm['tools'], fm['model']
('x', ['Read'], 'haiku')
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### coact.emit.emit_agent(ad, target='claude-agents-md', , dest=None)

Emit an agent to a registered target; optionally write a file target to `dest`.

For string targets (e.g. `claude-agents-md`) with `dest` given, writes
`<dest>/<name>.md` and returns the [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path). Otherwise
returns the emitter’s value (str or dict).

```pycon
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...')
>>> emit_agent(ad).splitlines()[0]
'---'
```

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

### coact.emit.emitters *: Registry[[Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[AgentDefinition](_autosummary/coact.base.html.md#coact.base.AgentDefinition)], [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]* *= Registry('emitters', keys=['claude-agents-md', 'sdk-agent-dict'])*

`AgentDefinition -> serialized form` (str or dict).

* **Type:**
  Registry of emit targets

### coact.emit.from_claude_agent_md(text)

Parse `.claude/agents/*.md` content back into an `AgentDefinition`.

The inverse of [`to_claude_agent_md()`](_autosummary/coact.emit.html.md#coact.emit.to_claude_agent_md): lossless for every **structured**
field; the `prompt` body is whitespace-trimmed on both ends (personas are
not whitespace-sensitive).

```pycon
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are an analyst.',
...     tools=['Read', 'Grep'], model='sonnet',
...     returns=ReturnContract(json_schema={'type': 'object'}, description='out'))
>>> back = from_claude_agent_md(to_claude_agent_md(ad))
>>> (back.name, back.tools, back.model, back.prompt) == (ad.name, ad.tools, ad.model, ad.prompt)
True
>>> back.returns.json_schema
{'type': 'object'}
```

* **Return type:**
  [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)

### coact.emit.to_aw_agent_spec(ad)

Adapt an `AgentDefinition` to an `aw.translators.AgentSpec`.

Lets coact reuse `aw`’s CrewAI / OpenAI / SKILL.md renderers (the
`*_from_spec` cores) instead of reimplementing them — the ecosystem
coordination point. Requires `aw`.

### coact.emit.to_claude_agent_md(ad)

Serialize an agent to `.claude/agents/<name>.md` content.

```pycon
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...')
>>> md = to_claude_agent_md(ad)
>>> md.startswith('---') and 'name: ux' in md and 'You are...' in md
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.emit.to_sdk_agent_dict(ad)

Build Agent-SDK kwargs + leftover query options for one agent.

Returns `{'name', 'agent_kwargs', 'options'}` where `agent_kwargs` are
accepted by the *installed* `claude_agent_sdk.AgentDefinition` and
`options` holds fields that version cannot express (to be wired into
`query()` by the `sdk` realize backend). Requires the Agent SDK.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)


# _autosummary/coact.frontmatter.html.md

# coact.frontmatter

The additive `coact:` SKILL.md frontmatter convention and its validator.

COACT_SPEC §4 / DECISIONS D1. The standard SKILL.md frontmatter (`name`,
`description`) does not carry what COMPLETE needs to derive tools, model, MCP,
or a return contract. `coact` defines an **optional, additive** `coact:`
block (snake_case interior) that a skill author — or coact itself — fills in so
the skill→agent lift is mechanical and reproducible (SSOT for the extras):

```default
coact:
  tools: [Read, Grep, Glob]
  model: sonnet
  memory: project
  mcp:
    - module: ov.analyzers
      functions: [score_contrast, find_tap_targets]
  returns:
    schema_ref: ov.schemas:UxFindings
    description: Usability findings for the captured bundle
  consumes: evidence_bundle
  persona: |
    You are a meticulous UX analyst...
```

The block is ignored by other tools (a skill carrying it is still a valid plain
SKILL.md). The Agent Skills spec keeps custom keys under `metadata:`, so a
spec-clean skill may nest the block there instead (`metadata: {coact: {...}}`);
coact reads either, and a top-level block wins when both exist. coact reads it from the **raw** frontmatter because
`skill.SkillMeta` only retains the standard keys — so this module parses the
SKILL.md text directly rather than going through `Skill.meta`.

The validator is registered into `skill.create.validators` (additive) and also
exposed via a `skill.validators` entry point, so `skill validate` checks the
block without coact having to be the entry point.

### Module Attributes

| [`COACT_KEY`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.COACT_KEY)    | The single namespaced frontmatter key coact reads/writes.          |
|---------------------------------------------------------------|--------------------------------------------------------------------|
| [`METADATA_KEY`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.METADATA_KEY) | `metadata.coact` is read when there is no top-level `coact` block. |

### Functions

| [`coact_block_location`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.coact_block_location)(meta)          | Return `(block, path)`: the frontmatter's coact block and where it was found.                                          |
|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| [`parse_coact_meta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.parse_coact_meta)(source)            | Parse a [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta) from a SKILL.md path/text/`Skill`/frontmatter dict. |
| [`register_validator`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.register_validator)()                | Register the coact-block validator into `skill.create.validators` (idempotent).                                        |
| [`validate_coact_block`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.validate_coact_block)(skill_or_meta) | Validate a `coact:` block, returning issue strings (empty = valid/absent).                                             |

### Classes

| [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta)([tools, disallowed_tools, model, ...])   | The parsed `coact:` block (every field optional; all default to absent).   |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|

### coact.frontmatter.COACT_KEY *= 'coact'*

The single namespaced frontmatter key coact reads/writes.

### *class* coact.frontmatter.CoactMeta(tools=None, disallowed_tools=list(), model=None, memory=None, permission_mode=None, skills=list(), mcp=list(), returns=None, consumes=None, persona=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The parsed `coact:` block (every field optional; all default to absent).

```pycon
>>> m = CoactMeta.from_frontmatter({'coact': {'model': 'opus', 'tools': ['Read']}})
>>> m.model, m.tools, m.is_empty()
('opus', ['Read'], False)
>>> CoactMeta.from_frontmatter({'name': 'x'}).is_empty()
True
>>> CoactMeta.from_frontmatter({'metadata': {'coact': {'model': 'haiku'}}}).model
'haiku'
```

#### *classmethod* from_frontmatter(meta)

Build from a full frontmatter dict (reads the `coact` sub-mapping).

The block is the top-level `coact` key, else `metadata.coact`.

* **Return type:**
  [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta)

#### is_empty()

True when the block carries no author-provided information.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### return_contract()

The author-pinned [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract), if any.

* **Return type:**
  [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract)

### coact.frontmatter.METADATA_KEY *= 'metadata'*

`metadata.coact` is read when there is no
top-level `coact` block.

* **Type:**
  The spec’s home for custom keys

### coact.frontmatter.coact_block_location(meta)

Return `(block, path)`: the frontmatter’s coact block and where it was found.

`path` is `"coact"` (top level, which wins when both exist),
`"metadata.coact"` (the Agent Skills spec’s home for custom keys), or
`"coact"` with a `None` block when there is none, so writers default to
the top level.

```pycon
>>> coact_block_location({'metadata': {'coact': {'model': 'opus'}}})
({'model': 'opus'}, 'metadata.coact')
>>> coact_block_location({'coact': {'model': 'haiku'}, 'metadata': {'coact': {}}})
({'model': 'haiku'}, 'coact')
>>> coact_block_location({'name': 'x'})
(None, 'coact')
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### coact.frontmatter.parse_coact_meta(source)

Parse a [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta) from a SKILL.md path/text/`Skill`/frontmatter dict.

Accepts the several shapes coact callers have on hand:

- a `Skill` (uses its `source_path` to re-read the raw
  frontmatter, since `Skill.meta` drops the `coact` key);
- a filesystem path to a skill directory or a SKILL.md file;
- raw SKILL.md text;
- an already-parsed frontmatter dict.

```pycon
>>> parse_coact_meta("---\nname: x\ncoact:\n  model: haiku\n---\nbody").model
'haiku'
```

* **Return type:**
  [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta)

### coact.frontmatter.register_validator()

Register the coact-block validator into `skill.create.validators` (idempotent).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### coact.frontmatter.validate_coact_block(skill_or_meta)

Validate a `coact:` block, returning issue strings (empty = valid/absent).

Additive: a skill with no `coact:` block passes trivially. The block is read
from the top level or from `metadata.coact` (see [`coact_block_location()`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.coact_block_location)),
and issues are prefixed with where it was found. Checks key
spelling, `model`/`memory` enums, `mcp` entry shape, and that
`returns` carries exactly one of `schema_ref`/`json_schema`.

```pycon
>>> validate_coact_block({'coact': {'model': 'gpt-4'}})
["coact.model: 'gpt-4' is not one of sonnet, opus, haiku, inherit"]
>>> validate_coact_block({'coact': {'mcp': [{'functions': ['f']}]}})
["coact.mcp[0]: missing required 'module'"]
>>> validate_coact_block({'name': 'ok'})
[]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]


# _autosummary/coact.html.md

# coact

coact — reuse your AI stuff across the layers of the modern agent stack.

`coact` (“co-act”: skills and agents acting as one reusable substrate) owns the
two transitions the rest of the ecosystem doesn’t:

```default
python functions/scripts  →  .claude/skills/  →  .claude/agents/  →  running agents
        (py2mcp, aw)            (skill pkg)         COMPLETE (coact)    REALIZE (coact)
```

- **COMPLETE** lifts `.claude/skills/` into `.claude/agents/` definitions,
  adding the agent-only “extras” (persona, return contract, tool allowlist,
  model, memory).
- **REALIZE** turns a completed definition into an actually running agent,
  picking an execution backend (host agent / Agent SDK / MCP-exposed).

It is glue over `skill` (foundation), `aw` (runtime substrate), and
`py2mcp` (tool exposure) — see `misc/docs/REUSE.md`.

Simple usage:

```default
from coact import complete, emit_agent, realize

agent = complete('.claude/skills/ux-analyst')      # Skill -> AgentDefinition
emit_agent(agent, 'claude-agents-md', dest='.claude/agents/')
realize(agent, backend='host')                     # materialize for Claude Code
```

### Functions

| [`complete`](_autosummary/coact.html.md#coact.complete)(source, \*[, policy, llm, ceiling])       | Complete a skill into an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) (the plan's agent).                   |
|-----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| [`plan_completion`](_autosummary/coact.html.md#coact.plan_completion)(source, \*[, policy, llm, ...])    | Plan the skill→agent completion, recording the provenance of every field.                                                       |
| [`realize`](_autosummary/coact.html.md#coact.realize)(target, \*[, backend])                     | Realize an agent (or skill, or list) via the named backend.                                                                     |
| [`realize_host`](_autosummary/coact.html.md#coact.realize_host)(target, \*[, scope, dest, ...])       | Materialize agents (+ linked skills) so the host agent runs them.                                                               |
| [`realize_sdk`](_autosummary/coact.html.md#coact.realize_sdk)(target, \*[, llm, runner, ...])        | Realize a single agent as a runnable [`RunnableAgent`](_autosummary/coact.html.md#coact.RunnableAgent) (aw-compatible).            |
| [`realize_mcp`](_autosummary/coact.html.md#coact.realize_mcp)(target, \*[, name, input_trans])       | Expose a skill's declared Python tools as a FastMCP server (foreign-host).                                                      |
| [`realize_litellm`](_autosummary/coact.html.md#coact.realize_litellm)(target, \*[, model_map, ...])      | Realize one agent as a provider-agnostic [`RunnableLLMAgent`](_autosummary/coact.html.md#coact.RunnableLLMAgent) (via LiteLLM).       |
| [`realize_langgraph`](_autosummary/coact.html.md#coact.realize_langgraph)(target, \*[, model_map, ...])    | Realize one agent as a LangGraph-backed [`RunnableLLMGraphAgent`](_autosummary/coact.html.md#coact.RunnableLLMGraphAgent) (aw-compatible). |
| [`realize_crewai`](_autosummary/coact.html.md#coact.realize_crewai)(target, \*[, model_map, ...])       | Realize one agent as a CrewAI-backed [`RunnableCrewAIAgent`](_autosummary/coact.html.md#coact.RunnableCrewAIAgent) (aw-compatible).      |
| [`integration_spec_from`](_autosummary/coact.html.md#coact.integration_spec_from)(source, \*[, name, ...])     | Coerce a capability source into an [`IntegrationSpec`](_autosummary/coact.html.md#coact.IntegrationSpec).                            |
| [`integration_spec_from_description`](_autosummary/coact.html.md#coact.integration_spec_from_description)(description, \*) | Refine a natural-language `description` into a **draft** IntegrationSpec.                                                       |
| [`publish`](_autosummary/coact.html.md#coact.publish)(source, \*[, target, dry_run])             | Publish a capability to a chatbot host via the named target.                                                                    |
| [`publish_targets`](_autosummary/coact.html.md#coact.publish_targets)()                                  | The names of all registered publish targets.                                                                                    |
| [`publish_mcpb`](_autosummary/coact.html.md#coact.publish_mcpb)(source, \*[, dest, dry_run, ...])     | Bundle `source` into a Claude Desktop `.mcpb` extension.                                                                        |
| [`publish_remote`](_autosummary/coact.html.md#coact.publish_remote)(source, \*[, dest, dry_run, ...])   | Scaffold a remote Claude connector (Streamable-HTTP MCP server + OAuth 2.1).                                                    |
| [`scaffold_fleet`](_autosummary/coact.html.md#coact.scaffold_fleet)(target, \*[, dest, ...])            | Emit a starter shim wiring the target agents as a runnable `sdk` fleet.                                                         |
| [`synthesize_persona`](_autosummary/coact.html.md#coact.synthesize_persona)(skill, \*, return_contract)     | Synthesize the system prompt (persona) for an agent derived from `skill`.                                                       |
| [`synthesize_return_contract`](_autosummary/coact.html.md#coact.synthesize_return_contract)(skill, \*, coact_meta)  | Choose the agent's return contract: author-pinned, else a template default.                                                     |
| [`resolve_llm`](_autosummary/coact.html.md#coact.resolve_llm)([llm])                                 | Resolve `llm` to a `callable(str) -> str`, or `None` if unavailable.                                                            |
| [`structured`](_autosummary/coact.html.md#coact.structured)(prompt, schema, \*[, llm, retries])     | Best-effort schema-conforming dict from an LLM, or `None` if unavailable.                                                       |
| [`emit_agent`](_autosummary/coact.html.md#coact.emit_agent)(ad[, target, dest])                     | Emit an agent to a registered target; optionally write a file target to `dest`.                                                 |
| [`to_claude_agent_md`](_autosummary/coact.html.md#coact.to_claude_agent_md)(ad)                             | Serialize an agent to `.claude/agents/<name>.md` content.                                                                       |
| [`from_claude_agent_md`](_autosummary/coact.html.md#coact.from_claude_agent_md)(text)                         | Parse `.claude/agents/*.md` content back into an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition).              |
| [`to_aw_agent_spec`](_autosummary/coact.html.md#coact.to_aw_agent_spec)(ad)                               | Adapt an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) to an `aw.translators.AgentSpec`.                     |
| [`diff`](_autosummary/coact.html.md#coact.diff)(skill, agent)                                 | Show what extras `agent` adds over its source `skill`.                                                                          |
| [`estimate`](_autosummary/coact.html.md#coact.estimate)(agents)                                   | Surface the fan-out cost tradeoff for an agent set (DECISIONS D9).                                                              |
| [`inventory`](_autosummary/coact.html.md#coact.inventory)([project])                               | Enumerate skills, derived agents, and MCP-exposed tools in a project.                                                           |
| [`back`](_autosummary/coact.html.md#coact.back)(agent)                                        | Best-effort, **lossy** agent→skill extraction (harvest an agent into a skill).                                                  |
| [`parse_coact_meta`](_autosummary/coact.html.md#coact.parse_coact_meta)(source)                           | Parse a [`CoactMeta`](_autosummary/coact.html.md#coact.CoactMeta) from a SKILL.md path/text/`Skill`/frontmatter dict.          |
| [`validate_coact_block`](_autosummary/coact.html.md#coact.validate_coact_block)(skill_or_meta)                | Validate a `coact:` block, returning issue strings (empty = valid/absent).                                                      |
| [`register_validator`](_autosummary/coact.html.md#coact.register_validator)()                               | Register the coact-block validator into `skill.create.validators` (idempotent).                                                 |
| [`agents_dir`](_autosummary/coact.html.md#coact.agents_dir)(\*[, scope, project_dir])               | Resolve the `.claude/agents` directory for the given scope.                                                                     |

### Classes

| [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition)(name, description[, prompt, ...])   | The SSOT: one object, two serializations (filesystem md + SDK form).                                                     |
|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| [`AgentPlan`](_autosummary/coact.html.md#coact.AgentPlan)(agent[, provenance, warnings])            | The inspectable result of `plan_completion`: the agent + its provenance.                                                 |
| [`FieldProvenance`](_autosummary/coact.html.md#coact.FieldProvenance)(field, value, source[, note])       | Where one [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) field's value came from (dry-run audit).      |
| [`ReturnContract`](_autosummary/coact.html.md#coact.ReturnContract)([json_schema, ref, description])     | The agent's return contract: its final-message schema + a human summary.                                                 |
| [`CompletionPolicy`](_autosummary/coact.html.md#coact.CompletionPolicy)([default_model, ...])              | Injectable defaults for the §3.2 extras COMPLETE must stamp on a skill.                                                  |
| [`RealizedHost`](_autosummary/coact.html.md#coact.RealizedHost)([agents, skills, agents_dir, ...])     | The materialized result of host realization (files the host will discover).                                              |
| [`RunnableAgent`](_autosummary/coact.html.md#coact.RunnableAgent)(agent_def[, llm, runner, ...])        | An `aw.AgenticStep`-compatible runnable backed by the Claude Agent SDK.                                                  |
| [`RunnableLLMAgent`](_autosummary/coact.html.md#coact.RunnableLLMAgent)(agent_def[, model_map, ...])       | An `aw.AgenticStep`-compatible runnable backed by LiteLLM (any provider).                                                |
| [`RunnableLLMGraphAgent`](_autosummary/coact.html.md#coact.RunnableLLMGraphAgent)(agent_def[, ...])             | An `aw.AgenticStep`-compatible runnable backed by a LangGraph graph.                                                     |
| [`RunnableCrewAIAgent`](_autosummary/coact.html.md#coact.RunnableCrewAIAgent)(agent_def[, model_map, ...])    | An `aw.AgenticStep`-compatible runnable backed by a single `crewai.Agent`.                                               |
| [`IntegrationSpec`](_autosummary/coact.html.md#coact.IntegrationSpec)(name[, description, ...])           | Target-neutral description of an integration to publish.                                                                 |
| [`ToolSpec`](_autosummary/coact.html.md#coact.ToolSpec)(name[, description, input_schema, ...])    | A richer, target-neutral description of one tool in an [`IntegrationSpec`](_autosummary/coact.html.md#coact.IntegrationSpec). |
| [`PublishResult`](_autosummary/coact.html.md#coact.PublishResult)(target[, dry_run, artifact, ...])     | The outcome of [`publish()`](_autosummary/coact.html.md#coact.publish) — what was (or *would be*) produced.           |
| [`CoactMeta`](_autosummary/coact.html.md#coact.CoactMeta)([tools, disallowed_tools, model, ...])    | The parsed `coact:` block (every field optional; all default to absent).                                                 |
| [`AgentStore`](_autosummary/coact.html.md#coact.AgentStore)([root, scope, project_dir])              | A `MutableMapping[str, AgentDefinition]` over a `.claude/agents/` dir.                                                   |

### Exceptions

| [`ToolCeilingError`](_autosummary/coact.html.md#coact.ToolCeilingError)(tools, ceiling)   | A completed agent would hold tools outside the permissions ceiling.   |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------|

### *class* coact.AgentDefinition(name, description, prompt='', tools=None, disallowed_tools=list(), model=None, skills=list(), memory=None, mcp_servers=list(), permission_mode=None, returns=ReturnContract(), consumes=None, source_skill=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The SSOT: one object, two serializations (filesystem md + SDK form).

Fields mirror the host subagent schema (snake_case here; coact owns the
mapping to the host’s camelCase frontmatter names in [`coact.emit`](_autosummary/coact.emit.html.md#module-coact.emit)),
plus the coact-specific `returns` / `consumes`. `tools=None`
means *inherit all tools*; an empty list means *no tools* — the distinction
is preserved.

```pycon
>>> ad = AgentDefinition(name='ux-analyst', description='Analyze UX bundles.')
>>> ad.name, ad.tools, ad.returns.is_empty()
('ux-analyst', None, True)
```

#### source_skill *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]* *= None*

Canonical key/name of the source skill this agent was completed from.

### *class* coact.AgentPlan(agent, provenance=list(), warnings=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The inspectable result of `plan_completion`: the agent + its provenance.

Shows the proposed [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) and, for each field, *why* it has
its value — so a user can review before any file is written or agent spawned
(progressive disclosure: dry-run first).

#### render()

Render a human-readable provenance table for terminal display.

```pycon
>>> plan = AgentPlan(
...     agent=AgentDefinition(name='x', description='y'),
...     provenance=[FieldProvenance('model', 'sonnet', 'policy', 'worker')],
... )
>>> 'model' in plan.render() and 'policy' in plan.render()
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* coact.AgentStore(root=None, , scope='project', project_dir=None)

Bases: [`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)]

A `MutableMapping[str, AgentDefinition]` over a `.claude/agents/` dir.

Keys are agent names; each agent is one `<name>.md` file.

```pycon
>>> import tempfile
>>> from coact.base import AgentDefinition
>>> store = AgentStore(root=tempfile.mkdtemp())
>>> store['ux'] = AgentDefinition(name='ux', description='Analyze.', prompt='You are...')
>>> list(store)
['ux']
>>> store['ux'].description
'Analyze.'
>>> del store['ux']
>>> len(store)
0
```

### *class* coact.CoactMeta(tools=None, disallowed_tools=list(), model=None, memory=None, permission_mode=None, skills=list(), mcp=list(), returns=None, consumes=None, persona=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The parsed `coact:` block (every field optional; all default to absent).

```pycon
>>> m = CoactMeta.from_frontmatter({'coact': {'model': 'opus', 'tools': ['Read']}})
>>> m.model, m.tools, m.is_empty()
('opus', ['Read'], False)
>>> CoactMeta.from_frontmatter({'name': 'x'}).is_empty()
True
>>> CoactMeta.from_frontmatter({'metadata': {'coact': {'model': 'haiku'}}}).model
'haiku'
```

#### *classmethod* from_frontmatter(meta)

Build from a full frontmatter dict (reads the `coact` sub-mapping).

The block is the top-level `coact` key, else `metadata.coact`.

* **Return type:**
  [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta)

#### is_empty()

True when the block carries no author-provided information.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### return_contract()

The author-pinned [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract), if any.

* **Return type:**
  [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract)

### *class* coact.CompletionPolicy(default_model='sonnet', default_memory=None, default_tools=('Read', 'Grep', 'Glob'), read_only_tools=frozenset({'Glob', 'Grep', 'NotebookRead', 'Read', 'WebFetch', 'WebSearch'}), opus_keywords=('orchestrat\\\\w\*', 'architect\\\\w\*', 'coordinat\\\\w\*', '\\\\bplan(?:ning|s|ned)?\\\\b', '\\\\bdesign(?:s|ing|ed)?\\\\b', 'review\\\\w\*'), opus_skill_threshold=3, write_keywords=('write', 'edit', 'create file', 'modify', 'generate', 'refactor'))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Injectable defaults for the §3.2 extras COMPLETE must stamp on a skill.

```pycon
>>> p = CompletionPolicy()
>>> p.choose_model(tools=['Read', 'Grep'], description='Audit the bundle.', n_skills=1)
('haiku', 'read-only/explore: tools ⊆ read-only set')
>>> p.choose_model(tools=['Read', 'Write'], description='Implement the fix.', n_skills=1)[0]
'sonnet'
>>> p.choose_model(tools=['Read'], description='Orchestrate the review.', n_skills=1)[0]
'opus'
```

#### choose_memory()

The default memory scope (opt-in; None = no memory).

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'user'`, `'project'`, `'local'`]], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### choose_model(, tools, description, n_skills)

Route to a model from the effective tools / description / skill count.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'sonnet'`, `'opus'`, `'haiku'`, `'inherit'`], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### infer_tools(skill, coact_meta)

Derive the tool allowlist (declared-or-heuristic + report; DECISIONS D3).

Precedence: an explicit `coact: tools` wins; otherwise a conservative
heuristic from the skill’s resources/body. Never silently guesses — the
reason is returned for provenance.

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='x', description='y'), body='Write the report.')
>>> tools, why = CompletionPolicy().infer_tools(s, CoactMeta())
>>> 'Write' in tools and 'Read' in tools
True
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### opus_keywords *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), ...]* *= ('orchestrat\\\\w\*', 'architect\\\\w\*', 'coordinat\\\\w\*', '\\\\bplan(?:ning|s|ned)?\\\\b', '\\\\bdesign(?:s|ing|ed)?\\\\b', 'review\\\\w\*')*

Regex patterns (matched case-insensitively against the description) that
route to opus. Word-bounded so ‘plan.’ matches but ‘designer’/’designate’
don’t. Data, not code — extend or replace per policy.

#### override(\*\*kwargs)

Return a new policy with overridden fields (cascading defaults).

```pycon
>>> CompletionPolicy().override(default_model='opus').default_model
'opus'
```

* **Return type:**
  [`CompletionPolicy`](_autosummary/coact.policy.html.md#coact.policy.CompletionPolicy)

#### write_keywords *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), ...]* *= ('write', 'edit', 'create file', 'modify', 'generate', 'refactor')*

body substrings that imply the agent writes/edits files.

### *class* coact.FieldProvenance(field, value, source, note='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Where one [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) field’s value came from (dry-run audit).

```pycon
>>> FieldProvenance('model', 'sonnet', 'policy', 'default worker').source
'policy'
```

### *class* coact.IntegrationSpec(name, description='', version='0.1.0', tools=list(), resources=list(), prompts=list(), tool_specs=list(), instructions=None, auth='none', deployment='local-stdio', author=None, source=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Target-neutral description of an integration to publish.

The connectivity core maps onto MCP’s three primitives. Tools come in two
shapes that coexist: bare `'module:function'` refs in `tools` (the
mechanical/code ingress) and richer [`ToolSpec`](_autosummary/coact.html.md#coact.ToolSpec) descriptors in
`tool_specs` (the NL ingress, landscape-doc §9.1). `resources`/`prompts`
and the `auth`/`deployment` hints are declared now (open-closed) for the
remote connector and other targets to come.

```pycon
>>> spec = IntegrationSpec(name='paths', tools=['os.path:basename'])
>>> spec.name, spec.tools, spec.deployment
('paths', ['os.path:basename'], 'local-stdio')
>>> IntegrationSpec(name='empty').is_empty()
True
>>> draft = IntegrationSpec(name='wx', tool_specs=[ToolSpec(name='get')])
>>> draft.is_empty(), draft.runnable_refs()
(False, [])
```

#### is_empty()

True when there is nothing to publish (no tools/tool_specs/resources/prompts).

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### render()

A terminal-friendly summary of the (possibly draft) integration.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### runnable_refs()

The importable `'module:function'` refs that back *runnable* tools.

Bare refs in `tools` plus the `handler` of every *bound* ToolSpec,
de-duplicated preserving order. A draft whose tools are all *proposed*
(unbound) returns `[]` — it has nothing a server can actually run yet.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### *class* coact.PublishResult(target, dry_run=False, artifact=None, files=dict(), instructions='', warnings=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The outcome of [`publish()`](_autosummary/coact.html.md#coact.publish) — what was (or *would be*) produced.

`dry_run` mirrors `realize(backend='host', dry_run=True)`: in a dry run
`artifact` is `None` and `files` holds the would-write bundle members
(relpath → short preview), so you can look before you leap.

```pycon
>>> PublishResult(target='claude-local-mcpb', dry_run=True).render().splitlines()[0]
"Would publish (target='claude-local-mcpb', dry-run)"
```

#### render()

A terminal-friendly summary (used by the CLI).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* coact.RealizedHost(agents=dict(), skills=dict(), agents_dir=None, skills_dir=None, warnings=list(), dry_run=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The materialized result of host realization (files the host will discover).

When produced by a `dry_run` the paths are what *would* be written/linked
(`dry_run=True` is recorded so the caller / CLI can label the preview);
nothing on disk is touched.

### *class* coact.ReturnContract(json_schema=dict(), ref=None, description='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The agent’s return contract: its final-message schema + a human summary.

Skills return nothing; agents must define a consumable output. The canonical
form is a JSON Schema dict (portable across realization backends, DECISIONS
D6). `ref` records a `'module:Name'` source if the schema was resolved
from a Pydantic model / dataclass / TypedDict.

```pycon
>>> rc = ReturnContract(json_schema={'type': 'object'}, description='findings')
>>> rc.is_empty()
False
>>> ReturnContract().is_empty()
True
```

#### *classmethod* from_dict(d)

Parse from a `coact: returns` mapping (accepts `schema_ref` or `json_schema`).

```pycon
>>> ReturnContract.from_dict({'schema_ref': 'ov.schemas:UxFindings'}).ref
'ov.schemas:UxFindings'
```

* **Return type:**
  [`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract)

#### is_empty()

True when no schema (inline or ref) has been set.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### schema()

Return the canonical JSON Schema, resolving `ref` if needed (else `{}`).

Honors DECISIONS D6 (“JSON Schema is canonical; refs resolve to it”): an
inline `json_schema` wins; otherwise a `module:Name` `ref` is
resolved best-effort to a schema. Returns `{}` when neither is available.

```pycon
>>> ReturnContract(json_schema={'type': 'object'}).schema()
{'type': 'object'}
>>> 'properties' in ReturnContract(ref='coact.base:ReturnContract').schema()
True
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### to_dict()

Serialize to a plain dict (for the agent-md `coact:` block), omitting empties.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### *class* coact.RunnableAgent(agent_def, llm=None, runner=None, default_tools=('Read', 'Grep', 'Glob'), return_mode='auto')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

An `aw.AgenticStep`-compatible runnable backed by the Claude Agent SDK.

Satisfies `execute(input_data, context) -> (artifact, info_dict)` so it
drops into `aw` workflows and reuses `aw`’s retry/validation/human-in-loop.
The SDK is imported lazily; `runner` is injectable so the agent can be
constructed and unit-tested without a live API call (dependency injection).

#### build_options()

Construct `ClaudeAgentOptions` from the agent definition (no API call).

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

#### execute(input_data, context=None)

Run the agent over `input_data`; return `(artifact, info)` (aw protocol).

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]

#### return_mode *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)* *= 'auto'*

`'auto'` (native output_format when
the SDK supports it, else the forced return tool), `'output_format'`, or
`'tool'` (force the return_result tool — for older SDKs / extended
thinking that cannot honor output_format). See DECISIONS D6.

* **Type:**
  How the return contract is realized

### *class* coact.RunnableCrewAIAgent(agent_def, model_map=<factory>, default_model='openai/gpt-4o-mini', runner=None, tools_map=None, use_response_format=True)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

An `aw.AgenticStep`-compatible runnable backed by a single `crewai.Agent`.

The `Agent` is built lazily and cached; `runner` is injectable so the agent
runs in tests with no API key and no `crewai` install (dependency injection).
The `Agent` is exposed via [`build_agent()`](_autosummary/coact.html.md#coact.RunnableCrewAIAgent.build_agent) / the [`agent`](_autosummary/coact.html.md#coact.RunnableCrewAIAgent.agent) property.

```pycon
>>> from coact import AgentDefinition
>>> ad = AgentDefinition(name='x', description='d', prompt='You are X.', model='sonnet')
>>> RunnableCrewAIAgent(ad).resolve_model()
'anthropic/claude-sonnet-4-5'
```

#### *property* agent *: [Any](https://docs.python.org/3/library/typing.html#typing.Any)*

The native `crewai.Agent` — add it to your own `Crew(agents=[...])`.

#### build_agent()

Build (once) and return the framework-native `crewai.Agent`.

Pure with respect to API calls — constructing the `Agent` does not invoke a
model. Imports `crewai` lazily (checked first); only ever called on the
default (non-injected) run path.

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

#### build_backstory()

The CrewAI `backstory` (persona + the D6 return-contract instruction).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### build_goal()

The CrewAI `goal` (required, non-empty).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### build_response_model()

Synthesize the pydantic class for `kickoff(response_format=)`, or `None`.

`None` when there is no schema, `use_response_format` is off, or the schema
is not flat enough to represent (then coact relies on the prompt instruction).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`type`](https://docs.python.org/3/builtins/functions.html#type)]

#### build_role()

The CrewAI `role` (required, non-empty) — the agent’s name.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### execute(input_data, context=None)

Run the agent over `input_data`; return `(artifact, info)` (aw protocol).

`context` is accepted for `aw.AgenticStep` compatibility and ignored. Uses
the native `.pydantic` result when present; otherwise JSON-parses `.raw`
(graceful, like litellm). An injected `runner` keeps `crewai` unimported.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]

#### resolve_model()

Map the definition’s model selector to a LiteLLM model string (slash form).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### runner *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[..., [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]* *= None*

`runner(*, agent, input_text, response_format) -> output` (`.raw` / `.pydantic`);
defaults to `_default_crewai_runner()`. The DI seam (mirrors litellm `completion=`).

#### tools_map *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[dict](https://docs.python.org/3/builtins/stdtypes.html#dict)]* *= None*

`{tool_name: callable | crewai BaseTool}` — opt-in tool binding (D12); names with
no entry are reported in `info['warnings']` and never passed on.

#### use_response_format *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= True*

Also request native structured output (synthesized pydantic class) when possible.

### *class* coact.RunnableLLMAgent(agent_def, model_map=<factory>, default_model='openai/gpt-4o-mini', completion=None, use_response_format=True)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

An `aw.AgenticStep`-compatible runnable backed by LiteLLM (any provider).

The return contract is realized two ways at once (belt-and-suspenders, since
provider support for structured output varies): the JSON Schema is passed as
LiteLLM’s `response_format` *and* embedded as an instruction in the system
message. `completion` is injectable so the agent runs in tests with no API
key; LiteLLM is imported lazily only on the default path.

```pycon
>>> from coact import AgentDefinition, ReturnContract
>>> ad = AgentDefinition(name='x', description='d', prompt='You are X.', model='sonnet')
>>> RunnableLLMAgent(ad).resolve_model()
'anthropic/claude-sonnet-4-5'
```

#### build_kwargs(input_data)

Build the `litellm.completion` kwargs (model, messages, response_format).

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### build_messages(input_data)

Build the chat messages: persona (+ return-contract instruction) then input.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]

#### completion *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[..., [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]* *= None*

`completion(**kwargs) -> response`; defaults to `litellm.completion`.

#### execute(input_data, context=None)

Run the agent over `input_data`; return `(artifact, info)` (aw protocol).

`context` is accepted for `aw.AgenticStep` compatibility and ignored by
this backend. If a provider rejects the structured `response_format`, the
call is retried once **without** it — the schema is still requested via the
system-prompt instruction (the belt-and-suspenders fallback made functional).

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]

#### resolve_model()

Map the definition’s model selector to a LiteLLM model string.

A mapped selector wins; an explicit LiteLLM string in `model` is used
verbatim; otherwise `default_model`. The lookup covers any hashable
selector (so a `model_map` entry always applies if present).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### use_response_format *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= True*

Also pass the schema as LiteLLM `response_format` (in addition to the prompt).

### *class* coact.RunnableLLMGraphAgent(agent_def, model_map=<factory>, default_model='openai:gpt-4o-mini', factory=None, runner=None, tools_map=None, use_response_format=True, structured_strategy='auto')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

An `aw.AgenticStep`-compatible runnable backed by a LangGraph graph.

The compiled graph is built lazily and cached; `factory` is injectable so the
agent can be constructed and unit-tested without a live API call or a
`langchain`/`langgraph` install (dependency injection). The graph itself is
exposed via [`build_agent()`](_autosummary/coact.html.md#coact.RunnableLLMGraphAgent.build_agent) / the [`agent`](_autosummary/coact.html.md#coact.RunnableLLMGraphAgent.agent) property for composition.

```pycon
>>> from coact import AgentDefinition
>>> ad = AgentDefinition(name='x', description='d', prompt='You are X.', model='sonnet')
>>> RunnableLLMGraphAgent(ad).resolve_model()
'anthropic:claude-sonnet-4-5'
```

#### *property* agent *: [Any](https://docs.python.org/3/library/typing.html#typing.Any)*

The native `CompiledStateGraph` — add it as a node to your own `StateGraph`.

#### build_agent()

Build (once) and return the framework-native `CompiledStateGraph`.

Pure with respect to API calls — constructing the graph does not invoke a
model. The default path imports `langchain`/`langgraph` lazily and
checks they are installed; an injected `factory` bypasses both.

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

#### build_response_format()

Build the `create_agent` `response_format` for the return contract, or None.

Wraps the canonical JSON-Schema dict in `ToolStrategy` (default) or
`ProviderStrategy` — both accept the raw dict. When `langchain` is not
importable (an injected factory in tests, or the `create_react_agent`
fallback, which accepts a bare dict), the raw schema dict is returned so the
offline path needs no framework.

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

#### build_state(input_data)

Build the LangGraph input state (a single user message).

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

#### build_system_prompt()

Persona (+ the D6 return-contract instruction when a schema is declared).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### execute(input_data, context=None)

Run the agent over `input_data`; return `(artifact, info)` (aw protocol).

`context` is accepted for `aw.AgenticStep` compatibility and ignored.
Uses the native `structured_response` when the graph returns one; otherwise
falls back to JSON-parsing the final message text (graceful, like litellm) —
langchain may omit `structured_response` even when a schema was requested.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]

#### factory *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[..., [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]* *= None*

`factory(*, model, tools, system_prompt, response_format, name) -> graph`;
defaults to `_default_langgraph_factory()`. The primary DI seam.

#### resolve_model()

Map the definition’s model selector to a langchain `provider:model` string.

A mapped selector wins; an explicit provider string in `model` is used
verbatim; otherwise `default_model`.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### runner *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[Any](https://docs.python.org/3/library/typing.html#typing.Any), [Any](https://docs.python.org/3/library/typing.html#typing.Any)], [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]* *= None*

`runner(graph, state) -> result`.

* **Type:**
  Optional test-only bypass of `graph.invoke`

#### structured_strategy *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)* *= 'auto'*

`'auto'` / `'tool'` -> `ToolStrategy` (safest cross-provider); `'provider'`
-> `ProviderStrategy` (native provider structured output).

#### tools_map *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[dict](https://docs.python.org/3/builtins/stdtypes.html#dict)]* *= None*

`{tool_name: callable | BaseTool}` — opt-in tool binding (D12); names with
no entry here are reported in `info['unbound_tools']` and never passed on.

#### use_response_format *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= True*

Also request native structured output (in addition to the prompt instruction).

### *exception* coact.ToolCeilingError(tools, ceiling)

Bases: [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

A completed agent would hold tools outside the permissions ceiling.

### *class* coact.ToolSpec(name, description='', input_schema=None, handler=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A richer, target-neutral description of one tool in an [`IntegrationSpec`](_autosummary/coact.html.md#coact.IntegrationSpec).

The *mechanical* ingress represents tools as bare `'module:function'` ref
strings (`IntegrationSpec.tools`). The *NL* ingress ([`coact.nl_ingress`](_autosummary/coact.nl_ingress.html.md#module-coact.nl_ingress))
and the landscape-doc §9.1 model need more — a name, a description, an input
JSON Schema, and an **optional** handler ref:

- A ToolSpec **with** a `handler` is *bound* (runnable): its ref joins the
  spec’s runnable set and the published server can import and call it.
- A ToolSpec **without** a handler is a *proposed* tool — a design draft to
  bind to real code (or supply a ref for) before it can run.

```pycon
>>> ToolSpec(name='get_weather', handler='wx.api:current').is_bound()
True
>>> ToolSpec(name='get_weather').is_bound()
False
```

#### is_bound()

True when a `module:function` handler backs this tool (so it can run).

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### coact.agents_dir(, scope='project', project_dir=None)

Resolve the `.claude/agents` directory for the given scope.

`scope='project'` resolves against the detected project root (or
`project_dir`); `scope='global'` resolves against `~/.claude`.

```pycon
>>> agents_dir(scope='global').as_posix().endswith('.claude/agents')
True
```

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### coact.back(agent)

Best-effort, **lossy** agent→skill extraction (harvest an agent into a skill).

Strips the persona/return-contract envelope down to a reusable skill stub
(name + description + a pointer to the skills it referenced). The actual
procedure usually lives in those referenced skills, so this cannot recover
it — the result is a starting point the user fleshes out, not a faithful
inverse of COMPLETE.

```pycon
>>> from coact import AgentDefinition
>>> sk = back(AgentDefinition(name='ux', description='Analyze.', skills=['ux', 'shared']))
>>> sk.meta.name
'ux'
>>> 'lossy' in sk.body.lower()
True
```

* **Return type:**
  `Skill`

### coact.complete(source, , policy=None, llm=None, ceiling=None)

Complete a skill into an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) (the plan’s agent).

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='ux', description='Analyze bundles.'), body='steps')
>>> ad = complete(s)
>>> ad.name, ad.skills, ('Return contract' in ad.prompt)
('ux', ['ux'], True)
```

* **Return type:**
  [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)

### coact.diff(skill, agent)

Show what extras `agent` adds over its source `skill`.

`skill` is any skill source; `agent` is an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition), an
agent `*.md` path, or a skill source (which is completed first).

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='ux', description='Analyze bundles.'), body='steps')
>>> from coact import complete
>>> d = diff(s, complete(s))
>>> any(f == 'prompt' and cls.startswith('extra') for f, cls, _ in d.rows)
True
```

* **Return type:**
  [`AgentDiff`](_autosummary/coact.analysis.html.md#coact.analysis.AgentDiff)

### coact.emit_agent(ad, target='claude-agents-md', , dest=None)

Emit an agent to a registered target; optionally write a file target to `dest`.

For string targets (e.g. `claude-agents-md`) with `dest` given, writes
`<dest>/<name>.md` and returns the [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path). Otherwise
returns the emitter’s value (str or dict).

```pycon
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...')
>>> emit_agent(ad).splitlines()[0]
'---'
```

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

### coact.estimate(agents)

Surface the fan-out cost tradeoff for an agent set (DECISIONS D9).

```pycon
>>> from coact import AgentDefinition
>>> a = AgentDefinition(name='a', description='x', skills=['shared'])
>>> b = AgentDefinition(name='b', description='y', skills=['shared'])
>>> est = estimate([a, b])
>>> est.interdependent, est.shared_skills
(True, ['shared'])
```

* **Return type:**
  [`Estimate`](_autosummary/coact.analysis.html.md#coact.analysis.Estimate)

### coact.from_claude_agent_md(text)

Parse `.claude/agents/*.md` content back into an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition).

The inverse of [`to_claude_agent_md()`](_autosummary/coact.html.md#coact.to_claude_agent_md): lossless for every **structured**
field; the `prompt` body is whitespace-trimmed on both ends (personas are
not whitespace-sensitive).

```pycon
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are an analyst.',
...     tools=['Read', 'Grep'], model='sonnet',
...     returns=ReturnContract(json_schema={'type': 'object'}, description='out'))
>>> back = from_claude_agent_md(to_claude_agent_md(ad))
>>> (back.name, back.tools, back.model, back.prompt) == (ad.name, ad.tools, ad.model, ad.prompt)
True
>>> back.returns.json_schema
{'type': 'object'}
```

* **Return type:**
  [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)

### coact.integration_spec_from(source, , name=None, description='', version='0.1.0', author=None)

Coerce a capability source into an [`IntegrationSpec`](_autosummary/coact.html.md#coact.IntegrationSpec).

Accepts (and flattens lists of): a prebuilt [`IntegrationSpec`](_autosummary/coact.html.md#coact.IntegrationSpec), a
`'module:function'` ref string, a live callable (its
`__module__:__qualname__` becomes the ref), or a skill source carrying a
`coact: mcp:` block. The resulting `name` is kebab-cased so it is a safe,
machine-readable bundle identifier.

```pycon
>>> integration_spec_from(['os.path:basename'], name='paths').tools
['os.path:basename']
>>> integration_spec_from('os.path:basename', name='My Tools').name
'my-tools'
```

* **Return type:**
  [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec)

### coact.integration_spec_from_description(description, , llm=None, model=None, name=None, version='0.1.0', author=None, prompt_template=None, infer_tool_schemas=True)

Refine a natural-language `description` into a **draft** IntegrationSpec.

The opt-in LLM ingress (DECISIONS D10): generation is routed through `aix`
(provider-agnostic) by default, via `oa`’s prompt-as-function machinery.

* **Parameters:**
  * **description** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – What the integration should do, in plain language.
  * **llm** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – The LLM backend. `None` → `aix.chat` (the default, multi-provider);
    a `callable(prompt, **kwargs) -> str` is used as-is (handy for tests);
    a `str` is treated as a model name passed to `aix.chat`.
  * **model** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Explicit model id (overrides a model-name `llm`); `None` lets the
    backend resolve its own configured default.
  * **name** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Force the integration name (else the model proposes one). Kebab-cased.
  * **version** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Spec version string.
  * **author** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional author name recorded on the spec.
  * **prompt_template** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Override the authoring prompt (e.g. one managed in
    `pyrompt`). Must contain a single `{description}` placeholder.
  * **infer_tool_schemas** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – When a proposed tool lacks an `input_schema`, infer
    one from its description via `oa.infer_schema_from_verbal_description`
    (aix-backed). Best-effort — failures leave the schema `None`.
* **Return type:**
  [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec)
* **Returns:**
  An [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec) whose `tool_specs` hold the
  proposed tools. Tools the description bound to existing code become runnable
  refs (`spec.runnable_refs()`); the rest are design drafts to bind later.

Example (offline, with an injected backend):

```pycon
>>> reply = (
...     '{"name": "wx", "description": "weather",'
...     ' "tools": [{"name": "get_weather", "description": "lookup",'
...     ' "input_schema": {"type": "object", "properties": {"city":'
...     ' {"type": "string"}}}, "handler": null}]}'
... )
>>> spec = integration_spec_from_description("a weather tool", llm=lambda p, **k: reply)
>>> spec.name, [t.name for t in spec.tool_specs], spec.runnable_refs()
('wx', ['get_weather'], [])
```

### coact.inventory(project=None)

Enumerate skills, derived agents, and MCP-exposed tools in a project.

```pycon
>>> import tempfile
>>> inv = inventory(tempfile.mkdtemp())
>>> inv.skills, inv.agents
([], [])
```

* **Return type:**
  [`Inventory`](_autosummary/coact.analysis.html.md#coact.analysis.Inventory)

### coact.parse_coact_meta(source)

Parse a [`CoactMeta`](_autosummary/coact.html.md#coact.CoactMeta) from a SKILL.md path/text/`Skill`/frontmatter dict.

Accepts the several shapes coact callers have on hand:

- a `Skill` (uses its `source_path` to re-read the raw
  frontmatter, since `Skill.meta` drops the `coact` key);
- a filesystem path to a skill directory or a SKILL.md file;
- raw SKILL.md text;
- an already-parsed frontmatter dict.

```pycon
>>> parse_coact_meta("---\nname: x\ncoact:\n  model: haiku\n---\nbody").model
'haiku'
```

* **Return type:**
  [`CoactMeta`](_autosummary/coact.frontmatter.html.md#coact.frontmatter.CoactMeta)

### coact.plan_completion(source, , policy=None, llm=None, ceiling=None)

Plan the skill→agent completion, recording the provenance of every field.

Accepts a `Skill`, a path to a skill directory / SKILL.md,
or a skill key/name resolvable in the local store or project skills. Pass an
optional `llm` (any `callable(str)->str`, an `aw` `StepConfig`, or a
model name) to *draft* a richer persona — the mechanical path needs none.

`ceiling` (a list, or `'Read,Grep'`) is a permissions ceiling: the agent’s
tool allowlist must be a subset of it, else [`ToolCeilingError`](_autosummary/coact.html.md#coact.ToolCeilingError) names
the offending tools (never silently dropped).

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='auditor', description='Audit a bundle for issues.'), body='steps')
>>> plan = plan_completion(s)
>>> plan.agent.name
'auditor'
>>> plan.agent.model  # read-only description with default tools -> haiku
'haiku'
>>> any(p.field == 'prompt' for p in plan.provenance)
True
```

* **Return type:**
  [`AgentPlan`](_autosummary/coact.base.html.md#coact.base.AgentPlan)

### coact.publish(source, , target='claude-local-mcpb', dry_run=False, \*\*kwargs)

Publish a capability to a chatbot host via the named target.

`source` is anything [`coact.integration.integration_spec_from()`](_autosummary/coact.integration.html.md#coact.integration.integration_spec_from)
accepts: `'module:function'` refs, live callables, a skill carrying a
`coact: mcp:` block, or a prebuilt [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec).
Target-specific options (`dest`, `name`, `author`, …) pass through as
keyword arguments.

* **Return type:**
  [`PublishResult`](_autosummary/coact.html.md#coact.PublishResult)

### coact.publish_mcpb(source, , dest=None, dry_run=False, name=None, author=None, version='0.1.0', description='', python_command='python', manifest_version='0.3')

Bundle `source` into a Claude Desktop `.mcpb` extension.

```pycon
>>> res = publish_mcpb(['os.path:basename'], name='paths', dry_run=True)
>>> res.dry_run, res.artifact, sorted(res.files)
(True, None, ['manifest.json', 'server/main.py', 'server/py2mcp_config.json'])
```

* **Return type:**
  [`PublishResult`](_autosummary/coact.html.md#coact.PublishResult)

### coact.publish_remote(source, , dest=None, dry_run=False, name=None, author=None, version='0.1.0', description='', connector_url=None, idp_issuer=None, jwks_uri=None, audience=None, required_scopes=None, host='127.0.0.1', port=8000, transport='streamable-http', include_dockerfile=True)

Scaffold a remote Claude connector (Streamable-HTTP MCP server + OAuth 2.1).

`source` is anything [`coact.integration.integration_spec_from()`](_autosummary/coact.integration.html.md#coact.integration.integration_spec_from) accepts.
The OAuth parameters describe the **managed IdP** that issues tokens and *this*
server’s public identity; when omitted, placeholder values + a loud warning are
emitted so the scaffold is still useful (fill them in before going public).

```pycon
>>> res = publish_remote(['os.path:basename'], name='paths', dry_run=True)
>>> res.dry_run, sorted(res.files)
(True, ['DEPLOY.md', 'Dockerfile', 'requirements.txt', 'server/app.py',
        'server/connector_config.json'])
```

* **Return type:**
  [`PublishResult`](_autosummary/coact.html.md#coact.PublishResult)

### coact.publish_targets()

The names of all registered publish targets.

```pycon
>>> isinstance(publish_targets(), list)
True
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### coact.realize(target, , backend='host', \*\*kwargs)

Realize an agent (or skill, or list) via the named backend.

```pycon
>>> from coact import AgentDefinition
>>> import tempfile
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...', skills=['ux'])
>>> res = realize(ad, backend='host', dest=tempfile.mkdtemp(), link=False)
>>> res.agents['ux'].name
'ux.md'
```

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

### coact.realize_crewai(target, , model_map=None, default_model='openai/gpt-4o-mini', runner=None, tools_map=None, use_response_format=True, policy=None)

Realize one agent as a CrewAI-backed [`RunnableCrewAIAgent`](_autosummary/coact.html.md#coact.RunnableCrewAIAgent) (aw-compatible).

`model_map` overrides how coact selectors map to LiteLLM model strings;
`tools_map` opt-in binds host-resolved tool *names* to callables/tools (D12);
`runner` injects the run call for testing. Raises if asked to realize more than
one agent (topology is out of scope — D8).

* **Return type:**
  [`RunnableCrewAIAgent`](_autosummary/coact.html.md#coact.RunnableCrewAIAgent)

### coact.realize_host(target, , scope='project', dest=None, project_dir=None, link=True, skills_source=None, force=False, dry_run=False, policy=None)

Materialize agents (+ linked skills) so the host agent runs them.

Writes `<dest>/<name>.md` for each agent and (when `link`) symlinks each
**referenced** skill into the sibling `.claude/skills/` so Claude Code
discovers both. `skills_source` (a dir or list of dirs each holding
`<name>/SKILL.md`) is searched first; otherwise skills are resolved by name
via the local store / project. Verifies discovery and reports anything missing.

Pass `dry_run=True` to *preview* — the returned [`RealizedHost`](_autosummary/coact.html.md#coact.RealizedHost) lists
the agent files that would be written and the skills that would link (with the
same unresolvable-skill warnings), but **no file or symlink is created**. This
mirrors `coact.complete.plan_completion()`’s look-before-you-leap contract
for the one backend that mutates the filesystem (progressive disclosure).

* **Return type:**
  [`RealizedHost`](_autosummary/coact.html.md#coact.RealizedHost)

### coact.realize_langgraph(target, , model_map=None, default_model='openai:gpt-4o-mini', factory=None, runner=None, tools_map=None, structured_strategy='auto', use_response_format=True, policy=None)

Realize one agent as a LangGraph-backed [`RunnableLLMGraphAgent`](_autosummary/coact.html.md#coact.RunnableLLMGraphAgent) (aw-compatible).

`model_map` overrides how coact selectors (`sonnet`/`opus`/`haiku`) map to
langchain `provider:model` strings. `tools_map` opt-in binds host-resolved tool
*names* to Python callables (D12). `factory` injects the graph builder for
testing. Raises if asked to realize more than one agent (topology is out — D8).

* **Return type:**
  [`RunnableLLMGraphAgent`](_autosummary/coact.html.md#coact.RunnableLLMGraphAgent)

### coact.realize_litellm(target, , model_map=None, default_model='openai/gpt-4o-mini', completion=None, use_response_format=True, policy=None)

Realize one agent as a provider-agnostic [`RunnableLLMAgent`](_autosummary/coact.html.md#coact.RunnableLLMAgent) (via LiteLLM).

`model_map` overrides how coact model selectors (`sonnet`/`opus`/`haiku`)
map to LiteLLM model strings — point them at any provider to prove portability.

* **Return type:**
  [`RunnableLLMAgent`](_autosummary/coact.html.md#coact.RunnableLLMAgent)

### coact.realize_mcp(target, , name=None, input_trans=None)

Expose a skill’s declared Python tools as a FastMCP server (foreign-host).

Reads the `coact: mcp:` block (`module` + `functions`) of the source
skill(s) and delegates to `py2mcp.mk_mcp_from_refs` — coact writes no MCP
plumbing (DECISIONS §6.1.3). `target` may be a skill source or an
[`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) (whose `source_skill` is resolved back to the
skill that carries the declaration).

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

### coact.realize_sdk(target, , llm=None, runner=None, return_mode='auto', policy=None)

Realize a single agent as a runnable [`RunnableAgent`](_autosummary/coact.html.md#coact.RunnableAgent) (aw-compatible).

`return_mode` selects how the return contract reaches the SDK (DECISIONS
D6): `'auto'` uses native `output_format` when the installed SDK supports
it and otherwise falls back to a forced `return_result` tool; pass
`'tool'` to force that fallback (e.g. for models / extended-thinking modes
that cannot honor `output_format`).

* **Return type:**
  [`RunnableAgent`](_autosummary/coact.html.md#coact.RunnableAgent)

### coact.register_validator()

Register the coact-block validator into `skill.create.validators` (idempotent).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### coact.resolve_llm(llm=None)

Resolve `llm` to a `callable(str) -> str`, or `None` if unavailable.

```pycon
>>> resolve_llm(lambda p: 'hi')('x')
'hi'
>>> resolve_llm('no-such-thing') is None or callable(resolve_llm('no-such-thing'))
True
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

### coact.scaffold_fleet(target, , dest=None, agents_dir='.claude/agents', policy=None)

Emit a starter shim wiring the target agents as a runnable `sdk` fleet.

`target` is anything [`coact.realize()`](_autosummary/coact.html.md#coact.realize) accepts (an
[`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition), a skill source, an agent `*.md` path,
or a list of these). Returns the shim **source string**; if `dest` is given
(a file path, or a directory in which `fleet.py` is written) the file is
written and its [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) returned instead.

The shim references each agent by name under `agents_dir` and chains them
**sequentially** — a deliberately thin starting point. It is the *only*
topology-adjacent artifact coact produces (DECISIONS D8): coact writes it once
and never runs it; you own the control flow from there.

```pycon
>>> from coact import AgentDefinition
>>> shim = scaffold_fleet([AgentDefinition(name='collector', description='x'),
...                         AgentDefinition(name='summarizer', description='y')])
>>> 'AGENTS = ["collector", "summarizer"]' in shim
True
>>> 'backend="sdk"' in shim and 'YOU OWN THIS FILE' in shim
True
```

* **Return type:**
  [`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]

### coact.structured(prompt, schema, , llm=None, retries=1)

Best-effort schema-conforming dict from an LLM, or `None` if unavailable.

Native structured output is provider-specific; this facade stays portable by
instructing JSON-only output that conforms to `schema` and parsing it,
retrying once on a parse miss. Returns `None` when no LLM is resolvable —
callers fall back to a template (DECISIONS D10).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]

### coact.synthesize_persona(skill, , return_contract, tools=None, extra_skills=None, llm=None)

Synthesize the system prompt (persona) for an agent derived from `skill`.

Wraps the skill’s intent as an identity, states operating invariants, and
appends the return contract — while **pointing at** the source skill rather
than inlining it (§3.3). The identity paragraph is template-generated by
default; when an `llm` is resolvable it is *drafted* by the LLM instead
(richer, but the invariants and the return contract stay deterministic so the
machine-facing contract is never at the mercy of generation). The LLM is
optional — absent one, the template path is a sound default (DECISIONS D10).

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='ux-analyst', description='Analyze UX bundles.'), body='steps')
>>> rc = ReturnContract(json_schema={'type': 'object'}, description='findings')
>>> persona, src = synthesize_persona(s, return_contract=rc, tools=['Read', 'Grep'])
>>> 'ux-analyst' in persona and 'Return contract' in persona and src == 'synthesized-template'
True
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'skill'`, `'coact-frontmatter'`, `'policy'`, `'inferred'`, `'synthesized-template'`, `'synthesized-llm'`, `'default'`]]

### coact.synthesize_return_contract(skill, , coact_meta)

Choose the agent’s return contract: author-pinned, else a template default.

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='x', description='y'), body='z')
>>> rc, src = synthesize_return_contract(s, coact_meta=CoactMeta())
>>> rc.json_schema['type'], src
('object', 'synthesized-template')
>>> rc2, src2 = synthesize_return_contract(s, coact_meta=CoactMeta(returns={'schema_ref': 'm:N'}))
>>> rc2.ref, src2
('m:N', 'coact-frontmatter')
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract), [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'skill'`, `'coact-frontmatter'`, `'policy'`, `'inferred'`, `'synthesized-template'`, `'synthesized-llm'`, `'default'`]]

### coact.to_aw_agent_spec(ad)

Adapt an [`AgentDefinition`](_autosummary/coact.html.md#coact.AgentDefinition) to an `aw.translators.AgentSpec`.

Lets coact reuse `aw`’s CrewAI / OpenAI / SKILL.md renderers (the
`*_from_spec` cores) instead of reimplementing them — the ecosystem
coordination point. Requires `aw`.

### coact.to_claude_agent_md(ad)

Serialize an agent to `.claude/agents/<name>.md` content.

```pycon
>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...')
>>> md = to_claude_agent_md(ad)
>>> md.startswith('---') and 'name: ux' in md and 'You are...' in md
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.validate_coact_block(skill_or_meta)

Validate a `coact:` block, returning issue strings (empty = valid/absent).

Additive: a skill with no `coact:` block passes trivially. The block is read
from the top level or from `metadata.coact` (see `coact_block_location()`),
and issues are prefixed with where it was found. Checks key
spelling, `model`/`memory` enums, `mcp` entry shape, and that
`returns` carries exactly one of `schema_ref`/`json_schema`.

```pycon
>>> validate_coact_block({'coact': {'model': 'gpt-4'}})
["coact.model: 'gpt-4' is not one of sonnet, opus, haiku, inherit"]
>>> validate_coact_block({'coact': {'mcp': [{'functions': ['f']}]}})
["coact.mcp[0]: missing required 'module'"]
>>> validate_coact_block({'name': 'ok'})
[]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### Modules

| [`analysis`](_autosummary/coact.analysis.html.md#module-coact.analysis)               | Analysis utilities — small tools to *see and move between* the layers.                                                           |
|-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| [`base`](_autosummary/coact.base.html.md#module-coact.base)                       | Core data model for coact — the single in-memory representation of an agent.                                                     |
| [`emit`](_autosummary/coact.emit.html.md#module-coact.emit)                       | Emitters: one [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition) → many serializations. |
| [`frontmatter`](_autosummary/coact.frontmatter.html.md#module-coact.frontmatter)         | The additive `coact:` SKILL.md frontmatter convention and its validator.                                                         |
| [`integration`](_autosummary/coact.integration.html.md#module-coact.integration)         | IntegrationSpec — the target-neutral SSOT for a *published* integration.                                                         |
| [`llm`](_autosummary/coact.llm.html.md#module-coact.llm)                         | Provider-agnostic LLM facade — thin, injected, never a hard dependency.                                                          |
| [`nl_ingress`](_autosummary/coact.nl_ingress.html.md#module-coact.nl_ingress)           | NL-description → IntegrationSpec — the **opt-in LLM ingress** for PUBLISH.                                                       |
| [`policy`](_autosummary/coact.policy.html.md#module-coact.policy)                   | Completion policy — the injectable model / memory / tool choices COMPLETE stamps.                                                |
| [`return_contract`](_autosummary/coact.return_contract.html.md#module-coact.return_contract) | Realizing a return contract — the backend-agnostic part of DECISIONS D6.                                                         |
| [`scaffold`](_autosummary/coact.scaffold.html.md#module-coact.scaffold)               | Scaffold a *starter* multi-agent shim — the one topology-adjacent thing coact emits.                                             |
| [`schema`](_autosummary/coact.schema.html.md#module-coact.schema)                   | JSON Schema resolution — turn a `module:Name` ref into a canonical schema.                                                       |
| [`stores`](_autosummary/coact.stores.html.md#module-coact.stores)                   | Mapping facades over agent definitions on disk.                                                                                  |
| [`synthesis`](_autosummary/coact.synthesis.html.md#module-coact.synthesis)             | Persona & return-contract synthesis — the two real "extras" of a skill→agent lift.                                               |
| [`util`](_autosummary/coact.util.html.md#module-coact.util)                       | Pure helpers for coact with no internal coact imports.                                                                           |


# _autosummary/coact.integration.html.md

# coact.integration

IntegrationSpec — the target-neutral SSOT for a *published* integration.

coact’s COMPLETE/REALIZE axes turn skills into agent definitions and run them.
The **PUBLISH** axis (this module + [`coact.publish`](_autosummary/coact.html.md#coact.publish)) is orthogonal: it takes
a *capability* — a set of Python tools given as `'module:function'` refs, live
callables, or a skill’s `coact: mcp:` block — and ships it to a chatbot host as
a deployable integration (a Claude Desktop `.mcpb` bundle today; remote
connectors / skills / plugins / other hosts later).

The spec is deliberately **separate from** [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)
(which is agent-persona-centric): an integration is MCP-server-shaped
(tools/resources/prompts + auth + deployment), per the chatbot-integration
landscape research (`misc/docs/CHATBOT_INTEGRATION_LANDSCAPE.md`). The canonical
artifact is an MCP server, built by `py2mcp` — coact owns the spec, the
packaging, and the target registry, **not** the MCP plumbing (mirrors the `mcp`
realize backend, DECISIONS §6.1.3 / D17).

### Module Attributes

| [`IntegrationSource`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSource)   | a built spec, a `module:function` ref, a skill source (path/`Skill`), a live callable, or an iterable of those.   |
|----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|

### Functions

| [`integration_spec_from`](_autosummary/coact.integration.html.md#coact.integration.integration_spec_from)(source, \*[, name, ...])   | Coerce a capability source into an [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec).   |
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|

### Classes

| [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec)(name[, description, ...])        | Target-neutral description of an integration to publish.                                                                 |
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| [`ToolSpec`](_autosummary/coact.integration.html.md#coact.integration.ToolSpec)(name[, description, input_schema, ...]) | A richer, target-neutral description of one tool in an [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec). |

### coact.integration.IntegrationSource

a built spec, a `module:function`
ref, a skill source (path/`Skill`), a live callable, or an iterable of those.

* **Type:**
  What [`integration_spec_from()`](_autosummary/coact.integration.html.md#coact.integration.integration_spec_from) accepts

alias of [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec) | [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) | `Callable`[[…], [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)] | [`Iterable`](https://docs.python.org/3/library/typing.html#typing.Iterable)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

### *class* coact.integration.IntegrationSpec(name, description='', version='0.1.0', tools=list(), resources=list(), prompts=list(), tool_specs=list(), instructions=None, auth='none', deployment='local-stdio', author=None, source=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Target-neutral description of an integration to publish.

The connectivity core maps onto MCP’s three primitives. Tools come in two
shapes that coexist: bare `'module:function'` refs in `tools` (the
mechanical/code ingress) and richer [`ToolSpec`](_autosummary/coact.integration.html.md#coact.integration.ToolSpec) descriptors in
`tool_specs` (the NL ingress, landscape-doc §9.1). `resources`/`prompts`
and the `auth`/`deployment` hints are declared now (open-closed) for the
remote connector and other targets to come.

```pycon
>>> spec = IntegrationSpec(name='paths', tools=['os.path:basename'])
>>> spec.name, spec.tools, spec.deployment
('paths', ['os.path:basename'], 'local-stdio')
>>> IntegrationSpec(name='empty').is_empty()
True
>>> draft = IntegrationSpec(name='wx', tool_specs=[ToolSpec(name='get')])
>>> draft.is_empty(), draft.runnable_refs()
(False, [])
```

#### is_empty()

True when there is nothing to publish (no tools/tool_specs/resources/prompts).

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### render()

A terminal-friendly summary of the (possibly draft) integration.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### runnable_refs()

The importable `'module:function'` refs that back *runnable* tools.

Bare refs in `tools` plus the `handler` of every *bound* ToolSpec,
de-duplicated preserving order. A draft whose tools are all *proposed*
(unbound) returns `[]` — it has nothing a server can actually run yet.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### *class* coact.integration.ToolSpec(name, description='', input_schema=None, handler=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A richer, target-neutral description of one tool in an [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec).

The *mechanical* ingress represents tools as bare `'module:function'` ref
strings (`IntegrationSpec.tools`). The *NL* ingress ([`coact.nl_ingress`](_autosummary/coact.nl_ingress.html.md#module-coact.nl_ingress))
and the landscape-doc §9.1 model need more — a name, a description, an input
JSON Schema, and an **optional** handler ref:

- A ToolSpec **with** a `handler` is *bound* (runnable): its ref joins the
  spec’s runnable set and the published server can import and call it.
- A ToolSpec **without** a handler is a *proposed* tool — a design draft to
  bind to real code (or supply a ref for) before it can run.

```pycon
>>> ToolSpec(name='get_weather', handler='wx.api:current').is_bound()
True
>>> ToolSpec(name='get_weather').is_bound()
False
```

#### is_bound()

True when a `module:function` handler backs this tool (so it can run).

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### coact.integration.integration_spec_from(source, , name=None, description='', version='0.1.0', author=None)

Coerce a capability source into an [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec).

Accepts (and flattens lists of): a prebuilt [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec), a
`'module:function'` ref string, a live callable (its
`__module__:__qualname__` becomes the ref), or a skill source carrying a
`coact: mcp:` block. The resulting `name` is kebab-cased so it is a safe,
machine-readable bundle identifier.

```pycon
>>> integration_spec_from(['os.path:basename'], name='paths').tools
['os.path:basename']
>>> integration_spec_from('os.path:basename', name='My Tools').name
'my-tools'
```

* **Return type:**
  [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec)


# _autosummary/coact.llm.html.md

# coact.llm

Provider-agnostic LLM facade — thin, injected, never a hard dependency.

COACT_SPEC §5.5 / §8 / DECISIONS D10. Any LLM use in coact goes through this
facade, and **every mechanical path runs with no LLM at all**. The facade
resolves an injected `llm` to a `callable(str) -> str` from, in order:

1. an explicit `callable` (use as-is);
2. an `aw` `StepConfig` (use its `resolve_llm()` — reuse aw’s injection);
3. a model-name `str` (wrap `skill.ai.chat` with that model);
4. `None` → `skill.ai.chat` if any provider is configured, else `None`.

When nothing is available, [`resolve_llm()`](_autosummary/coact.llm.html.md#coact.llm.resolve_llm) returns `None` and callers fall
back to their template path — no provider lock-in, no crash. [`structured()`](_autosummary/coact.llm.html.md#coact.llm.structured)
adds a best-effort `(prompt, schema) -> dict` on top (instruct-JSON + parse +
one retry), used only for *optional* return-contract drafting.

### Functions

| [`resolve_llm`](_autosummary/coact.llm.html.md#coact.llm.resolve_llm)([llm])                             | Resolve `llm` to a `callable(str) -> str`, or `None` if unavailable.      |
|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [`structured`](_autosummary/coact.llm.html.md#coact.llm.structured)(prompt, schema, \*[, llm, retries]) | Best-effort schema-conforming dict from an LLM, or `None` if unavailable. |

### coact.llm.resolve_llm(llm=None)

Resolve `llm` to a `callable(str) -> str`, or `None` if unavailable.

```pycon
>>> resolve_llm(lambda p: 'hi')('x')
'hi'
>>> resolve_llm('no-such-thing') is None or callable(resolve_llm('no-such-thing'))
True
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

### coact.llm.structured(prompt, schema, , llm=None, retries=1)

Best-effort schema-conforming dict from an LLM, or `None` if unavailable.

Native structured output is provider-specific; this facade stays portable by
instructing JSON-only output that conforms to `schema` and parsing it,
retrying once on a parse miss. Returns `None` when no LLM is resolvable —
callers fall back to a template (DECISIONS D10).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]


# _autosummary/coact.nl_ingress.html.md

# coact.nl_ingress

NL-description → IntegrationSpec — the **opt-in LLM ingress** for PUBLISH.

[`coact.integration.integration_spec_from()`](_autosummary/coact.integration.html.md#coact.integration.integration_spec_from) is the *mechanical* ingress: it
turns `'module:function'` refs / callables / skills into an
[`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec) with **zero** LLM (DECISIONS D10).
This module is the *opt-in* LLM path — it refines a natural-language description
of a desired integration into a **draft** `IntegrationSpec` (name, description,
proposed tools with input JSON schemas), routing generation through `aix`
(provider-agnostic, per the route-through-aix policy) via `oa`’s
prompt-as-function machinery.

D10 is upheld two ways: (1) nothing on a mechanical path imports this module, and
(2) `oa`/`aix` are imported **lazily inside** the entry function, so
`import coact` pulls in neither and a missing backend raises an actionable
`ImportError` rather than imposing a hard dependency.

The result is a *draft*: each tool is *proposed* (no importable handler) unless
the description named existing code. Binding proposed tools to real
`module:function` handlers — or supplying them — is the user’s next step before
a runnable `.mcpb` can be built (coact writes the design; the user owns the
code, mirroring the D8/D13 scaffold philosophy).

### Module Attributes

| [`DFLT_AUTHORING_PROMPTS`](_autosummary/coact.nl_ingress.html.md#coact.nl_ingress.DFLT_AUTHORING_PROMPTS)   | Per-target authoring-prompt library.   |
|---------------------------------------------------------------------------|----------------------------------------|

### Functions

| [`integration_spec_from_description`](_autosummary/coact.nl_ingress.html.md#coact.nl_ingress.integration_spec_from_description)(description, \*)   | Refine a natural-language `description` into a **draft** IntegrationSpec.   |
|-------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|

### coact.nl_ingress.DFLT_AUTHORING_PROMPTS *: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)]* *= {'integration': 'You are an expert architect of AI-chatbot integrations (MCP servers).\\n\\nTurn the natural-language description below into a structured plan for an\\nintegration that exposes a small set of well-designed tools.\\n\\nRespond with ONLY a single JSON object (no prose, no markdown fences). The JSON\\nobject must have exactly these keys:\\n- "name": a short kebab-case name for the integration (string).\\n- "description": one sentence summarizing what the integration does (string).\\n- "tools": an array of tool objects. Each tool object has:\\n    - "name": a snake_case verb_noun tool name (for example get_weather), string.\\n    - "description": what the tool does, when to use it, and key boundaries or\\n      examples. Tool naming and description quality dominate reliability — make\\n      each one precise and unambiguous (string).\\n    - "input_schema": a JSON Schema (draft 2020-12) describing the tool\\'s input —\\n      type object, a properties map, and a required list where appropriate.\\n    - "handler": a "module:function" reference ONLY if the description explicitly\\n      names existing importable code for this tool; otherwise null.\\n- "resources": an array of short names for readable data resources (or empty).\\n- "prompts": an array of short names for templated workflows (or empty).\\n\\nDesign guidance:\\n- Prefer a few well-named, task-aligned tools over many overlapping ones.\\n- Keep input schemas minimal and typed; mark genuinely-required fields required.\\n\\nNatural-language description of the desired integration:\\n{description}\\n'}*

Per-target authoring-prompt library. coact owns these templates as the SSOT
(one entry per publish target — extend as targets land). `pyrompt` is the
recommended place to *manage and iterate* on authoring prompts; load one there
and pass it via `prompt_template=` to override the default used here.

### coact.nl_ingress.integration_spec_from_description(description, , llm=None, model=None, name=None, version='0.1.0', author=None, prompt_template=None, infer_tool_schemas=True)

Refine a natural-language `description` into a **draft** IntegrationSpec.

The opt-in LLM ingress (DECISIONS D10): generation is routed through `aix`
(provider-agnostic) by default, via `oa`’s prompt-as-function machinery.

* **Parameters:**
  * **description** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – What the integration should do, in plain language.
  * **llm** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – The LLM backend. `None` → `aix.chat` (the default, multi-provider);
    a `callable(prompt, **kwargs) -> str` is used as-is (handy for tests);
    a `str` is treated as a model name passed to `aix.chat`.
  * **model** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Explicit model id (overrides a model-name `llm`); `None` lets the
    backend resolve its own configured default.
  * **name** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Force the integration name (else the model proposes one). Kebab-cased.
  * **version** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Spec version string.
  * **author** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional author name recorded on the spec.
  * **prompt_template** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Override the authoring prompt (e.g. one managed in
    `pyrompt`). Must contain a single `{description}` placeholder.
  * **infer_tool_schemas** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – When a proposed tool lacks an `input_schema`, infer
    one from its description via `oa.infer_schema_from_verbal_description`
    (aix-backed). Best-effort — failures leave the schema `None`.
* **Return type:**
  [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec)
* **Returns:**
  An [`IntegrationSpec`](_autosummary/coact.integration.html.md#coact.integration.IntegrationSpec) whose `tool_specs` hold the
  proposed tools. Tools the description bound to existing code become runnable
  refs (`spec.runnable_refs()`); the rest are design drafts to bind later.

Example (offline, with an injected backend):

```pycon
>>> reply = (
...     '{"name": "wx", "description": "weather",'
...     ' "tools": [{"name": "get_weather", "description": "lookup",'
...     ' "input_schema": {"type": "object", "properties": {"city":'
...     ' {"type": "string"}}}, "handler": null}]}'
... )
>>> spec = integration_spec_from_description("a weather tool", llm=lambda p, **k: reply)
>>> spec.name, [t.name for t in spec.tool_specs], spec.runnable_refs()
('wx', ['get_weather'], [])
```


# _autosummary/coact.policy.html.md

# coact.policy

Completion policy — the injectable model / memory / tool choices COMPLETE stamps.

COACT_SPEC §5.4 / DECISIONS D4. The model, memory, and tool-narrowing choices
are **policy**: injected data, not hardcoded branches, with cascading defaults in
the spirit of `aw.GlobalConfig` (sensible defaults; override globally by
constructing a different [`CompletionPolicy`](_autosummary/coact.policy.html.md#coact.policy.CompletionPolicy), or per-skill via the
`coact:` block, which always wins over policy). This module imports no LLM and
no `aw` — it is a pure mechanical path (DECISIONS D10); the `aw` `StepConfig`
LLM injection used for *optional* persona synthesis lives behind that optional
path in [`coact.synthesis`](_autosummary/coact.synthesis.html.md#module-coact.synthesis).

The routing table is data on the dataclass, so users extend it without editing
code (open-closed).

### Module Attributes

| [`default_policy`](_autosummary/coact.policy.html.md#coact.policy.default_policy)   | The default policy instance (importable, mutable-by-override).   |
|-------------------------------------------------------------------|------------------------------------------------------------------|

### Classes

| [`CompletionPolicy`](_autosummary/coact.policy.html.md#coact.policy.CompletionPolicy)([default_model, ...])   | Injectable defaults for the §3.2 extras COMPLETE must stamp on a skill.   |
|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|

### *class* coact.policy.CompletionPolicy(default_model='sonnet', default_memory=None, default_tools=('Read', 'Grep', 'Glob'), read_only_tools=frozenset({'Glob', 'Grep', 'NotebookRead', 'Read', 'WebFetch', 'WebSearch'}), opus_keywords=('orchestrat\\\\w\*', 'architect\\\\w\*', 'coordinat\\\\w\*', '\\\\bplan(?:ning|s|ned)?\\\\b', '\\\\bdesign(?:s|ing|ed)?\\\\b', 'review\\\\w\*'), opus_skill_threshold=3, write_keywords=('write', 'edit', 'create file', 'modify', 'generate', 'refactor'))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Injectable defaults for the §3.2 extras COMPLETE must stamp on a skill.

```pycon
>>> p = CompletionPolicy()
>>> p.choose_model(tools=['Read', 'Grep'], description='Audit the bundle.', n_skills=1)
('haiku', 'read-only/explore: tools ⊆ read-only set')
>>> p.choose_model(tools=['Read', 'Write'], description='Implement the fix.', n_skills=1)[0]
'sonnet'
>>> p.choose_model(tools=['Read'], description='Orchestrate the review.', n_skills=1)[0]
'opus'
```

#### choose_memory()

The default memory scope (opt-in; None = no memory).

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'user'`, `'project'`, `'local'`]], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### choose_model(, tools, description, n_skills)

Route to a model from the effective tools / description / skill count.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'sonnet'`, `'opus'`, `'haiku'`, `'inherit'`], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### infer_tools(skill, coact_meta)

Derive the tool allowlist (declared-or-heuristic + report; DECISIONS D3).

Precedence: an explicit `coact: tools` wins; otherwise a conservative
heuristic from the skill’s resources/body. Never silently guesses — the
reason is returned for provenance.

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='x', description='y'), body='Write the report.')
>>> tools, why = CompletionPolicy().infer_tools(s, CoactMeta())
>>> 'Write' in tools and 'Read' in tools
True
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### opus_keywords *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), ...]* *= ('orchestrat\\\\w\*', 'architect\\\\w\*', 'coordinat\\\\w\*', '\\\\bplan(?:ning|s|ned)?\\\\b', '\\\\bdesign(?:s|ing|ed)?\\\\b', 'review\\\\w\*')*

Regex patterns (matched case-insensitively against the description) that
route to opus. Word-bounded so ‘plan.’ matches but ‘designer’/’designate’
don’t. Data, not code — extend or replace per policy.

#### override(\*\*kwargs)

Return a new policy with overridden fields (cascading defaults).

```pycon
>>> CompletionPolicy().override(default_model='opus').default_model
'opus'
```

* **Return type:**
  [`CompletionPolicy`](_autosummary/coact.policy.html.md#coact.policy.CompletionPolicy)

#### write_keywords *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), ...]* *= ('write', 'edit', 'create file', 'modify', 'generate', 'refactor')*

body substrings that imply the agent writes/edits files.

### coact.policy.default_policy *= CompletionPolicy(default_model='sonnet', default_memory=None, default_tools=('Read', 'Grep', 'Glob'), read_only_tools=frozenset({'NotebookRead', 'Read', 'Glob', 'Grep', 'WebFetch', 'WebSearch'}), opus_keywords=('orchestrat\\\\w\*', 'architect\\\\w\*', 'coordinat\\\\w\*', '\\\\bplan(?:ning|s|ned)?\\\\b', '\\\\bdesign(?:s|ing|ed)?\\\\b', 'review\\\\w\*'), opus_skill_threshold=3, write_keywords=('write', 'edit', 'create file', 'modify', 'generate', 'refactor'))*

The default policy instance (importable, mutable-by-override).


# _autosummary/coact.return_contract.html.md

# coact.return_contract

Realizing a return contract — the backend-agnostic part of DECISIONS D6.

The return contract (an agent’s final-message JSON Schema) reaches a runtime two
ways, and the *how* is a cohesive, independently testable subsystem extracted
here out of the (large) [`coact.realize`](_autosummary/coact.html.md#coact.realize):

- **tool** — a forced `return_result` MCP tool whose `input_schema` IS the
  schema, plus a system-prompt instruction to call it. The structured result is
  recovered from the tool-use block. Used by the `sdk` backend (older SDKs, or
  when `output_format` can’t be honored).
- **json** — ask for a single JSON value conforming to the schema in the system
  prompt. Used by the provider-agnostic `litellm` backend (where structured
  `response_format` support varies).

This module owns: the in-process return-tool naming, the `ReturnPlan` value,
mode selection, the object-schema coercion the SDK tool needs, the two
instruction renderers (sharing one schema-fence helper — DRY across backends),
and the tool-use extraction. The SDK-specific *wiring* (building the in-process
MCP server, `ClaudeAgentOptions`) stays in [`coact.realize`](_autosummary/coact.html.md#coact.realize); the
provider-specific response parsing stays in [`coact.realize_litellm`](_autosummary/coact.html.md#coact.realize_litellm).

### Module Attributes

| [`RETURN_TOOL_SERVER`](_autosummary/coact.return_contract.html.md#coact.return_contract.RETURN_TOOL_SERVER)   | In-process SDK MCP server + tool names for the forced return path.   |
|-----------------------------------------------------------------------|----------------------------------------------------------------------|
| [`RETURN_TOOL_FULLNAME`](_autosummary/coact.return_contract.html.md#coact.return_contract.RETURN_TOOL_FULLNAME) | How Claude references the tool (`mcp__<server>__<tool>`).            |

### Functions

| [`as_object_schema`](_autosummary/coact.return_contract.html.md#coact.return_contract.as_object_schema)(schema)                        | Coerce a return schema to a valid object `inputSchema` for the return tool.                |
|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [`auto_return_mode`](_autosummary/coact.return_contract.html.md#coact.return_contract.auto_return_mode)(option_field_names)            | Pick the return mode in `auto`: native `output_format` if the SDK has it.                  |
| [`extract_return_tool_input`](_autosummary/coact.return_contract.html.md#coact.return_contract.extract_return_tool_input)(messages, unwrap_key) | Recover the forced `return_result` tool-use input from SDK messages, or None.              |
| [`is_return_tool`](_autosummary/coact.return_contract.html.md#coact.return_contract.is_return_tool)(name)                            | True if `name` denotes coact's forced return tool (server-scoped).                         |
| [`render_json_return_instruction`](_autosummary/coact.return_contract.html.md#coact.return_contract.render_json_return_instruction)(schema)          | The portable structured-output instruction: ask for JSON conforming to a schema (litellm). |
| [`render_tool_return_instruction`](_autosummary/coact.return_contract.html.md#coact.return_contract.render_tool_return_instruction)(...)             | Append the "you MUST call return_result" instruction to a system prompt (sdk).             |

### Classes

| [`ReturnPlan`](_autosummary/coact.return_contract.html.md#coact.return_contract.ReturnPlan)(mode, schema[, unwrap_key, ...])   | How an agent's return contract is realized for the SDK (resolved once).   |
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|

### coact.return_contract.RETURN_TOOL_FULLNAME *= 'mcp_\_coact_return_\_return_result'*

How Claude references the tool (`mcp__<server>__<tool>`).

### coact.return_contract.RETURN_TOOL_SERVER *= 'coact_return'*

In-process SDK MCP server + tool names for the forced return path.

### *class* coact.return_contract.ReturnPlan(mode, schema, unwrap_key=None, tool_fullname='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

How an agent’s return contract is realized for the SDK (resolved once).

### coact.return_contract.as_object_schema(schema)

Coerce a return schema to a valid object `inputSchema` for the return tool.

The Agent SDK passes a dict `input_schema` through unchanged only when it is
an object schema with **both** `type: object` and `properties`; any other
dict is misread as a `{param: type}` map (and mangled). So:

- An object schema *with* `properties` → passed through, no wrapping.
- A free-form object schema (`type: object` but no `properties`) → given an
  empty `properties` key so the SDK passes it through verbatim. Crucially it
  is **not** wrapped: wrapping a free-form object under `result` would make a
  model’s own single-key `{result: ...}` output indistinguishable from the
  wrapper (a silent-collapse hazard).
- Any non-object schema (array / scalar) → wrapped under a `result` key, with
  that key returned so extraction can unwrap it.

```pycon
>>> as_object_schema({'type': 'object', 'properties': {'a': {}}})[1] is None
True
>>> as_object_schema({'type': 'object'})  # free-form object: passed through, not wrapped
({'type': 'object', 'properties': {}}, None)
>>> as_object_schema({'type': 'array', 'items': {'type': 'string'}})
({'type': 'object', 'properties': {'result': {'type': 'array', 'items': {'type': 'string'}}}, 'required': ['result']}, 'result')
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict), [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

### coact.return_contract.auto_return_mode(option_field_names)

Pick the return mode in `auto`: native `output_format` if the SDK has it.

```pycon
>>> auto_return_mode({'system_prompt', 'output_format'})
'output_format'
>>> auto_return_mode({'system_prompt'})  # older SDK without the field
'tool'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.return_contract.extract_return_tool_input(messages, unwrap_key)

Recover the forced `return_result` tool-use input from SDK messages, or None.

Scans assistant messages for a tool-use block calling the return tool and
returns its `input` (the last one wins). When the schema was wrapped (a
non-object return type), the single `result` key is unwrapped.

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

### coact.return_contract.is_return_tool(name)

True if `name` denotes coact’s forced return tool (server-scoped).

Matches the full MCP name, or any prefix variant scoped to coact’s own server
(`…__coact_return__return_result`). Deliberately does **not** match a bare
`return_result` or a `return_result` on a *different* MCP server, so a
user’s own same-named tool is never mistaken for the return contract.

```pycon
>>> is_return_tool('mcp__coact_return__return_result')
True
>>> is_return_tool('mcp__other_server__return_result')
False
>>> is_return_tool('Read')
False
```

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### coact.return_contract.render_json_return_instruction(schema)

The portable structured-output instruction: ask for JSON conforming to a schema (litellm).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.return_contract.render_tool_return_instruction(system_prompt, obj_schema, description)

Append the “you MUST call return_result” instruction to a system prompt (sdk).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)


# _autosummary/coact.scaffold.html.md

# coact.scaffold

Scaffold a *starter* multi-agent shim — the one topology-adjacent thing coact emits.

COACT_SPEC §6.4 / DECISIONS D8. coact emits agent *definitions* + tool/MCP wiring
and **stops at topology** — it is not LangGraph, and a subagent definition can’t
express graphs/edges/cycles. The single sanctioned exception is *scaffolding*: for
a multi-agent run, coact may emit a **starter Python file** that wires N realized
`sdk` agents under an `aw` coordinator, “clearly marked as a starting point the
user owns.” That file is data coact writes once, not a runtime coact operates.

[`scaffold_fleet()`](_autosummary/coact.scaffold.html.md#coact.scaffold.scaffold_fleet) is exactly that emitter: it takes the same targets
`realize` accepts (agents, skills, `*.md` files, or a list) and returns — or
writes — a runnable, heavily-commented sequential-pipeline starter the user then
reshapes. It runs **no LLM and stands up no runtime** (it only renders source);
the emitted shim defers all execution to `coact.realize(..., backend='sdk')` and
all topology to the human who owns it.

### Module Attributes

| [`DEFAULT_SHIM_NAME`](_autosummary/coact.scaffold.html.md#coact.scaffold.DEFAULT_SHIM_NAME)   | Default filename when `dest` is a directory.   |
|----------------------------------------------------------------------|------------------------------------------------|

### Functions

| [`scaffold_fleet`](_autosummary/coact.scaffold.html.md#coact.scaffold.scaffold_fleet)(target, \*[, dest, ...])   | Emit a starter shim wiring the target agents as a runnable `sdk` fleet.   |
|--------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|

### coact.scaffold.DEFAULT_SHIM_NAME *= 'fleet.py'*

Default filename when `dest` is a directory.

### coact.scaffold.scaffold_fleet(target, , dest=None, agents_dir='.claude/agents', policy=None)

Emit a starter shim wiring the target agents as a runnable `sdk` fleet.

`target` is anything [`coact.realize()`](_autosummary/coact.html.md#coact.realize) accepts (an
[`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition), a skill source, an agent `*.md` path,
or a list of these). Returns the shim **source string**; if `dest` is given
(a file path, or a directory in which `fleet.py` is written) the file is
written and its [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) returned instead.

The shim references each agent by name under `agents_dir` and chains them
**sequentially** — a deliberately thin starting point. It is the *only*
topology-adjacent artifact coact produces (DECISIONS D8): coact writes it once
and never runs it; you own the control flow from there.

```pycon
>>> from coact import AgentDefinition
>>> shim = scaffold_fleet([AgentDefinition(name='collector', description='x'),
...                         AgentDefinition(name='summarizer', description='y')])
>>> 'AGENTS = ["collector", "summarizer"]' in shim
True
>>> 'backend="sdk"' in shim and 'YOU OWN THIS FILE' in shim
True
```

* **Return type:**
  [`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]


# _autosummary/coact.schema.html.md

# coact.schema

JSON Schema resolution — turn a `module:Name` ref into a canonical schema.

Extracted from [`coact.base`](_autosummary/coact.base.html.md#module-coact.base) so that module stays a pure SSOT *data model*
and this one owns the (separable, independently testable) concern of mapping
Python types to JSON Schema (DECISIONS D6: “JSON Schema is canonical; refs
resolve to it”). The public entry point is [`resolve_schema_ref()`](_autosummary/coact.schema.html.md#coact.schema.resolve_schema_ref); the
annotation/structural helpers are module-private.

Everything here is **best-effort and provider-agnostic**: a ref that cannot be
imported or mapped yields `None` (or a permissive `{}` fragment) so callers
warn and fall back rather than crash — no hard pydantic dependency, no LLM
(DECISIONS D10).

### Functions

| [`resolve_schema_ref`](_autosummary/coact.schema.html.md#coact.schema.resolve_schema_ref)(ref)   | Best-effort resolve a `'module:Name'` ref to a JSON Schema dict, or `None`.   |
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------|

### coact.schema.resolve_schema_ref(ref)

Best-effort resolve a `'module:Name'` ref to a JSON Schema dict, or `None`.

Handles Pydantic models (`model_json_schema`/`schema`), dataclasses, and
TypedDicts (structural `{type: object, properties: {...}}`). Provider- and
pydantic-agnostic: returns `None` on any failure so callers can warn and
fall back rather than crash (DECISIONS D6/D10).

```pycon
>>> resolve_schema_ref('coact.base:ReturnContract')['type']
'object'
>>> resolve_schema_ref('definitely.not:Real') is None
True
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]


# _autosummary/coact.stores.html.md

# coact.stores

Mapping facades over agent definitions on disk.

COACT_SPEC §8 (“prefer Mapping/MutableMapping facades — a skills store, an
agents store”) mirroring `skill.stores.LocalSkillStore`. [`AgentStore`](_autosummary/coact.stores.html.md#coact.stores.AgentStore)
is a `MutableMapping[str, AgentDefinition]` over a `.claude/agents/`
directory (one `<name>.md` per agent). Because it is a plain mapping, it drops
straight into `py2mcp.mk_mcp_from_store` to expose a project’s agents as CRUD
over MCP, and into `coact.analysis.inventory`.

### Functions

| [`agents_dir`](_autosummary/coact.stores.html.md#coact.stores.agents_dir)(\*[, scope, project_dir])   | Resolve the `.claude/agents` directory for the given scope.   |
|-----------------------------------------------------------------------------------------|---------------------------------------------------------------|

### Classes

| [`AgentStore`](_autosummary/coact.stores.html.md#coact.stores.AgentStore)([root, scope, project_dir])   | A `MutableMapping[str, AgentDefinition]` over a `.claude/agents/` dir.   |
|-------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|

### *class* coact.stores.AgentStore(root=None, , scope='project', project_dir=None)

Bases: [`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)]

A `MutableMapping[str, AgentDefinition]` over a `.claude/agents/` dir.

Keys are agent names; each agent is one `<name>.md` file.

```pycon
>>> import tempfile
>>> from coact.base import AgentDefinition
>>> store = AgentStore(root=tempfile.mkdtemp())
>>> store['ux'] = AgentDefinition(name='ux', description='Analyze.', prompt='You are...')
>>> list(store)
['ux']
>>> store['ux'].description
'Analyze.'
>>> del store['ux']
>>> len(store)
0
```

### coact.stores.agents_dir(, scope='project', project_dir=None)

Resolve the `.claude/agents` directory for the given scope.

`scope='project'` resolves against the detected project root (or
`project_dir`); `scope='global'` resolves against `~/.claude`.

```pycon
>>> agents_dir(scope='global').as_posix().endswith('.claude/agents')
True
```

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)


# _autosummary/coact.synthesis.html.md

# coact.synthesis

Persona & return-contract synthesis — the two real “extras” of a skill→agent lift.

COACT_SPEC §5.5 / §3.2. A skill body is *procedural*, not a persona, and skills
return *nothing*. The two fields that actually turn a skill into an agent are the
**system prompt (persona/identity)** and the \*\*return contract (consumable
output)\*\*. This module synthesizes both.

This PR ships the **template** path (no LLM, always available, a sound default).
The optional **LLM-assisted** path (a richer persona drafted from the skill body
via an injected facade) is added on top in a later milestone — both paths obey
the same rules: author-pinned `coact: persona` / `coact: returns` always win
(inspectable, overridable, LLM-assisted-but-not-required, DECISIONS D10).

Crucially the persona **references** the skill by name and instructs the agent to
follow it — it never copies the skill body (point-don’t-copy / SSOT, §3.3).

### Module Attributes

| [`DEFAULT_RETURN_SCHEMA`](_autosummary/coact.synthesis.html.md#coact.synthesis.DEFAULT_RETURN_SCHEMA)   | A generic-but-useful default return schema (used when the author pins none).   |
|--------------------------------------------------------------------------|--------------------------------------------------------------------------------|

### Functions

| [`render_return_contract_section`](_autosummary/coact.synthesis.html.md#coact.synthesis.render_return_contract_section)(rc)                | Render the human/model-facing "Return contract" markdown for a persona body.   |
|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [`synthesize_persona`](_autosummary/coact.synthesis.html.md#coact.synthesis.synthesize_persona)(skill, \*, return_contract)    | Synthesize the system prompt (persona) for an agent derived from `skill`.      |
| [`synthesize_return_contract`](_autosummary/coact.synthesis.html.md#coact.synthesis.synthesize_return_contract)(skill, \*, coact_meta) | Choose the agent's return contract: author-pinned, else a template default.    |

### coact.synthesis.DEFAULT_RETURN_SCHEMA *= {'properties': {'result': {'description': 'The primary artifact or finding.'}, 'status': {'enum': ['ok', 'partial', 'failed'], 'type': 'string'}, 'summary': {'description': 'One-paragraph summary of what was done.', 'type': 'string'}}, 'required': ['summary', 'status'], 'type': 'object'}*

A generic-but-useful default return schema (used when the author pins none).

### coact.synthesis.render_return_contract_section(rc)

Render the human/model-facing “Return contract” markdown for a persona body.

```pycon
>>> rc = ReturnContract(json_schema={'type': 'object'}, description='findings')
>>> 'Return contract' in render_return_contract_section(rc)
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.synthesis.synthesize_persona(skill, , return_contract, tools=None, extra_skills=None, llm=None)

Synthesize the system prompt (persona) for an agent derived from `skill`.

Wraps the skill’s intent as an identity, states operating invariants, and
appends the return contract — while **pointing at** the source skill rather
than inlining it (§3.3). The identity paragraph is template-generated by
default; when an `llm` is resolvable it is *drafted* by the LLM instead
(richer, but the invariants and the return contract stay deterministic so the
machine-facing contract is never at the mercy of generation). The LLM is
optional — absent one, the template path is a sound default (DECISIONS D10).

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='ux-analyst', description='Analyze UX bundles.'), body='steps')
>>> rc = ReturnContract(json_schema={'type': 'object'}, description='findings')
>>> persona, src = synthesize_persona(s, return_contract=rc, tools=['Read', 'Grep'])
>>> 'ux-analyst' in persona and 'Return contract' in persona and src == 'synthesized-template'
True
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'skill'`, `'coact-frontmatter'`, `'policy'`, `'inferred'`, `'synthesized-template'`, `'synthesized-llm'`, `'default'`]]

### coact.synthesis.synthesize_return_contract(skill, , coact_meta)

Choose the agent’s return contract: author-pinned, else a template default.

```pycon
>>> from skill.base import Skill, SkillMeta
>>> s = Skill(meta=SkillMeta(name='x', description='y'), body='z')
>>> rc, src = synthesize_return_contract(s, coact_meta=CoactMeta())
>>> rc.json_schema['type'], src
('object', 'synthesized-template')
>>> rc2, src2 = synthesize_return_contract(s, coact_meta=CoactMeta(returns={'schema_ref': 'm:N'}))
>>> rc2.ref, src2
('m:N', 'coact-frontmatter')
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`ReturnContract`](_autosummary/coact.base.html.md#coact.base.ReturnContract), [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'skill'`, `'coact-frontmatter'`, `'policy'`, `'inferred'`, `'synthesized-template'`, `'synthesized-llm'`, `'default'`]]


# _autosummary/coact.util.html.md

# coact.util

Pure helpers for coact with no internal coact imports.

Small, reusable string/name utilities and a thin `check_requirements` helper
for the optional-dependency backends (Agent SDK, py2mcp/FastMCP, an LLM
provider). Kept dependency-free so every other coact module can import it.

### Functions

| [`agent_filename`](_autosummary/coact.util.html.md#coact.util.agent_filename)(name)                     | Return the safe `<name>.md` filename for an agent, rejecting unsafe names.   |
|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [`check_requirements`](_autosummary/coact.util.html.md#coact.util.check_requirements)(modules, \*, feature) | Verify optional dependencies are importable, else raise an actionable error. |
| [`first_balanced_span`](_autosummary/coact.util.html.md#coact.util.first_balanced_span)(s[, opener, closer]) | Return the first depth-balanced `opener…closer` substring of `s`.            |
| [`import_object`](_autosummary/coact.util.html.md#coact.util.import_object)(ref)                       | Resolve a `'module.path:attr'` or `'module.path.attr'` reference.            |
| [`safe_filename`](_autosummary/coact.util.html.md#coact.util.safe_filename)(name, \*[, suffix, kind])  | Return `f"{name}{suffix}"` after rejecting unsafe, path-bearing names.       |
| [`to_kebab_case`](_autosummary/coact.util.html.md#coact.util.to_kebab_case)(name)                      | Convert CamelCase / snake_case / spaces to kebab-case.                       |
| [`to_snake_case`](_autosummary/coact.util.html.md#coact.util.to_snake_case)(name)                      | Convert CamelCase / kebab-case / spaces to snake_case.                       |

### coact.util.agent_filename(name)

Return the safe `<name>.md` filename for an agent, rejecting unsafe names.

Agent names become files under `.claude/agents/`; a name carrying a path
separator or `..` could escape that directory (CWE-22 path traversal) on
write *or* read. Names must be a bare filename stem. Raises `ValueError` on
an empty, non-string, or path-bearing name — the check lives at the
filesystem boundary so in-memory [`AgentDefinition`](_autosummary/coact.base.html.md#coact.base.AgentDefinition)s stay
unconstrained.

```pycon
>>> agent_filename('ux-analyst')
'ux-analyst.md'
>>> agent_filename('../escape')
Traceback (most recent call last):
    ...
ValueError: unsafe agent name '../escape': ...
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.util.check_requirements(modules, , feature)

Verify optional dependencies are importable, else raise an actionable error.

`modules` maps an importable module name to the pip target that provides
it (e.g. `{'claude_agent_sdk': 'claude-agent-sdk'}`). Raises
`ImportError` listing the exact `pip install` line for whatever is
missing — and, when some requirements *are* present, which ones — the
package-UX convention for optional backends (informative, actionable errors).

```pycon
>>> check_requirements({'json': 'json'}, feature='noop')  # importable -> no raise
```

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### coact.util.first_balanced_span(s, opener='{', closer='}')

Return the first depth-balanced `opener…closer` substring of `s`.

Brackets inside double-quoted JSON strings are ignored, so a valid value
followed by prose that itself contains brackets is not over-captured (a
greedy `opener.*closer` would run to the *last* `closer` and fail to
parse). Returns `None` when no balanced span starts in `s`. Shared by the
LLM-reply JSON extractors ([`coact.llm`](_autosummary/coact.llm.html.md#module-coact.llm), [`coact.realize_litellm`](_autosummary/coact.html.md#coact.realize_litellm)).

```pycon
>>> first_balanced_span('Result: {"a": 1}. Note: {braces}.')
'{"a": 1}'
>>> first_balanced_span('see [1, [2, 3]] end', '[', ']')
'[1, [2, 3]]'
>>> first_balanced_span('no brackets here') is None
True
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### coact.util.import_object(ref)

Resolve a `'module.path:attr'` or `'module.path.attr'` reference.

Prefer the `module:attr` form (unambiguous). Falls back to splitting on the
last dot for the dotted form.

```pycon
>>> import_object('json:dumps')
<function dumps at ...>
>>> import_object('os.path.join')
<function join at ...>
```

* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)

### coact.util.safe_filename(name, , suffix='', kind='name')

Return `f"{name}{suffix}"` after rejecting unsafe, path-bearing names.

Names that become files must be bare filename stems; one carrying a path
separator or `..` could escape its directory (CWE-22) on write *or* read.
Raises `ValueError` on an empty, non-string, or path-bearing name. `kind`
customizes the error wording for the caller’s domain. Shared by
[`agent_filename()`](_autosummary/coact.util.html.md#coact.util.agent_filename) (`.md` agents) and the publish axis (`.mcpb` bundles).

```pycon
>>> safe_filename('paths', suffix='.mcpb')
'paths.mcpb'
>>> safe_filename('../x', suffix='.mcpb')
Traceback (most recent call last):
    ...
ValueError: unsafe name '../x': ...
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.util.to_kebab_case(name)

Convert CamelCase / snake_case / spaces to kebab-case.

```pycon
>>> to_kebab_case('UxAnalyst')
'ux-analyst'
>>> to_kebab_case('ux_analyst')
'ux-analyst'
>>> to_kebab_case('already-kebab')
'already-kebab'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### coact.util.to_snake_case(name)

Convert CamelCase / kebab-case / spaces to snake_case.

```pycon
>>> to_snake_case('UxAnalyst')
'ux_analyst'
>>> to_snake_case('ux-analyst')
'ux_analyst'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-23 07:47 UTC** from commit <a href="https://github.com/addaix/coact/commit/df1ee7cc675ddf12a28769ba8e08b506f15f8982"><code>df1ee7c</code></a> on branch <code>main</code>, for **coact 0.0.4** (from <code>pyproject.toml</code>).

#### NOTE
Nothing suggests a mismatch: the tree was clean at the commit above, and the documented version is the one on PyPI.

## Source

|                     |                                                                                                                                                     |
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/addaix/coact/commit/df1ee7cc675ddf12a28769ba8e08b506f15f8982"><code>df1ee7cc675ddf12a28769ba8e08b506f15f8982</code></a> |
| Branch              | <code>main</code>                                                                                                                                   |
| Tags at this commit | none                                                                                                                                                |
| Working tree        | clean                                                                                                                                               |
| Remote              | <code>https://github.com/addaix/coact</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>addaix/coact</code>                                                                  |
| Run          | <a href="https://github.com/addaix/coact/actions/runs/45133486189">45133486189</a>         |
| Ref          | <code>refs/heads/main</code>                                                               |
| Event commit | <code>df1ee7cc675ddf12a28769ba8e08b506f15f8982</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.24  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                   |
|---------------|-------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>sphinxawesome_theme</code>) |
| accent        | <code>#20691f</code>                                              |
| api_generator | <code>autosummary</code>                                          |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code>  |
| agent_outputs | <code>true</code>                                                 |
| aggregates    | <code>md</code>                                                   |
| ai_artifacts  | <code>true</code>                                                 |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/coact/0.0.4/">0.0.4</a>, the same as the documented version.

## Reproduce

```bash
git clone https://github.com/addaix/coact && cd coact
git checkout df1ee7cc675ddf12a28769ba8e08b506f15f8982
pip install "epythet==0.2.24"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# ai-agents.html.md

<!-- generated by epythet -->

# For AI agents

`coact` ships artifacts for coding agents alongside its code. This page lists
them, says where each lives in the repository, and points at the
machine-readable copies of this documentation.

## Skills

Skills are folders holding a `SKILL.md` (the [Agent Skills](https://agentskills.io) format): a description that tells an agent when to use it and a body with the procedure. Install one into your agent with `gh skill` (any host: `--agent claude-code`, `copilot`, `cursor`, `codex`, `gemini`), or use the copy bundled in the wheel.

### `ai-assistant-agent-runtime`

Use this skill whenever the user wants to add, refactor, or audit the agent runtime — the loop that drives multi-step tool-using LLM conversations, optionally with durable execution for long-running, resumable agents. Triggers include “add an agent loop”, “make my agent multi-step”, “stop the agent from looping forever”, “resume an agent after a crash”, “run an agent in the background”, “agent handoff to sub-agent”, “add Pydantic AI / LangGraph / OpenAI Agents SDK”, “wrap my agent in Temporal / DBOS / Inngest / Restate”, “stream agent state to the UI”, “cancel a running agent”, “human-in-the-loop approval mid-run”, or any task on the agent orchestration or durable execution layers. Read BEFORE writing a custom agent loop.

```bash
gh skill install addaix/coact ai-assistant-agent-runtime --agent claude-code
```

Source: [`skills/ai-assistant-agent-runtime`](https://github.com/addaix/coact/tree/HEAD/skills/ai-assistant-agent-runtime).

### `ai-assistant-architect`

Use this skill whenever the user wants to add, audit, refactor, or maintain an embedded AI assistant (chat + agentic) inside their own application. Triggers include phrases like “add an AI assistant to my app”, “wire up a chatbot”, “embed Claude/GPT into my UI”, “make my app operable by AI”, “audit my AI assistant integration”, “what should I add next for my AI assistant”, “let users bring their own AI API keys”, or any task that touches multiple of {chat UI, system prompts, skills, MCP tools, agent runtime, command dispatch → MCP, multi-tenancy, observability, billing} together. This is the entry-point skill — it audits the codebase, identifies the layer in question, and routes to the focused sub-skills (ai-assistant-chat-ui, ai-assistant-prompts-skills, ai-assistant-command-mcp, ai-assistant-agent-runtime).

```bash
gh skill install addaix/coact ai-assistant-architect --agent claude-code
```

Source: [`skills/ai-assistant-architect`](https://github.com/addaix/coact/tree/HEAD/skills/ai-assistant-architect).

### `ai-assistant-chat-ui`

Use this skill whenever the user wants to add, modify, or audit the chat UI / streaming / wire-protocol layer of an embedded AI assistant. Triggers include “build a chat UI”, “add streaming responses”, “render tool calls in the chat”, “add thread CRUD”, “show markdown in the assistant”, “branch conversations”, “make the AI response copyable”, “switch from polling to streaming”, “embed Claude into my React app”, “set up assistant-ui”, “use Vercel AI SDK in my app”, “expose chat over SSE from FastAPI”, or any task on the frontend chat layer of a React + Vite + shadcn application. Read this skill BEFORE writing any new chat component, runtime hook, or SSE endpoint.

```bash
gh skill install addaix/coact ai-assistant-chat-ui --agent claude-code
```

Source: [`skills/ai-assistant-chat-ui`](https://github.com/addaix/coact/tree/HEAD/skills/ai-assistant-chat-ui).

### `ai-assistant-command-mcp`

Use this skill whenever the user wants to expose application operations to an AI assistant via tools/function-calling/MCP. Triggers include “make my app operable by AI”, “expose my commands to Claude/GPT”, “build an MCP server for my app”, “bridge command dispatch to MCP”, “annotate tools for AI”, “add tool approval flow”, “scope tools per user”, “stop the AI from calling destructive operations without confirmation”, “compose multiple MCP servers”, “use py2mcp”, “use FastMCP”, “use the MCP TypeScript SDK”, or any task that wires application operations to the agent’s tool surface. Look for command dispatch (any of: @command decorator, CommandSpec, acture, wrapex, py2mcp, a registry of typed handlers). If absent, prefer adding one first.

```bash
gh skill install addaix/coact ai-assistant-command-mcp --agent claude-code
```

Source: [`skills/ai-assistant-command-mcp`](https://github.com/addaix/coact/tree/HEAD/skills/ai-assistant-command-mcp).

### `ai-assistant-prompts-skills`

Use this skill whenever the user wants to add, refactor, manage, or audit system prompts, user-editable prompts, or “skills” (Anthropic-style) in an AI assistant. Triggers include “set up a prompt registry”, “version my system prompts”, “add a skill to my assistant”, “make prompts editable by non-engineers”, “auto-select the right skill”, “write a SKILL.md”, “integrate Langfuse for prompt management”, “add prompt evals to CI”, “manage prompt versions”, “load context dynamically per request”, “store prompts in git”, or any task involving the SSOT for instructions an LLM consumes. Read this skill BEFORE creating any prompts/ or skills/ directory or wiring up a prompt store.

```bash
gh skill install addaix/coact ai-assistant-prompts-skills --agent claude-code
```

Source: [`skills/ai-assistant-prompts-skills`](https://github.com/addaix/coact/tree/HEAD/skills/ai-assistant-prompts-skills).

### `coact`

Start here for coact — the package that turns your .claude/skills/ into .claude/agents/ definitions (COMPLETE) and those into running agents (REALIZE), plus tooling to see and move between the layers (diff/estimate/inventory/back) and scaffold a starter fleet. Use when someone asks “how do I use coact”, “what can coact do”, “turn my skills into agents”, “reuse my AI stuff across the agent stack”, or isn’t sure which coact capability they need. Routes to the focused coact-complete / coact-realize / coact-analyze skills.

```bash
gh skill install addaix/coact coact --agent claude-code
```

Source: [`skills/coact`](https://github.com/addaix/coact/tree/HEAD/skills/coact).

### `coact-analyze`

Use when inspecting or moving between the skill/agent layers with coact — auditing what extras an agent adds over its skill, estimating the token cost of fanning out a fleet before you spend it, enumerating a project’s reusable AI assets, or harvesting an agent back into a skill. Triggers on “diff this skill and agent”, “what does this agent add”, “how much will a fleet cost”, “is multi-agent worth it here”, “list the skills/agents/tools in this project”, “inventory”, or “turn this agent back into a skill”.

```bash
gh skill install addaix/coact coact-analyze --agent claude-code
```

Source: [`skills/coact-analyze`](https://github.com/addaix/coact/tree/HEAD/skills/coact-analyze).

### `coact-complete`

Use when turning an existing .claude/skills/ skill into a .claude/agents/ agent definition with coact — i.e. COMPLETE. Triggers on “complete a skill into an agent”, “make an agent from this skill”, “what extras would coact add”, “fill in the coact frontmatter block”, or wanting a dry-run/provenance preview before generating an agent. Covers complete(), plan_completion(), the additive coact frontmatter, and the no-LLM default.

```bash
gh skill install addaix/coact coact-complete --agent claude-code
```

Source: [`skills/coact-complete`](https://github.com/addaix/coact/tree/HEAD/skills/coact-complete).

### `coact-dev`

Use when developing, debugging, reviewing, or extending the coact package itself (this repo) — adding emit targets or realize backends, touching COMPLETE/REALIZE, the additive coact frontmatter, the policy, or the LLM/synthesis paths. Covers the architecture, the invariants that must not be broken, the open-closed extension points, and the testing/tooling gotchas specific to this repo.

```bash
gh skill install addaix/coact coact-dev --agent claude-code
```

Source: [`skills/coact-dev`](https://github.com/addaix/coact/tree/HEAD/skills/coact-dev).

### `coact-publish`

Publish a Python capability as a deployable AI-chatbot integration with coact — package tools (module:function refs, live functions, or a skill’s coact: mcp block) into a Claude Desktop one-click .mcpb extension (a local stdio MCP server). Use when the user wants to create, build, package, or deploy a Claude connector / plugin / MCP server / .mcpb / Desktop Extension / “integration” from existing Python code or a skill — e.g. “make an mcpb”, “package these functions for Claude”, “turn this into a Claude extension/connector”, “publish a local MCP server”, “wrap my tools as a Claude Desktop extension”. Also use to draft an integration from a natural-language description (“describe an integration”, “I want a Claude connector that can…”) via `coact describe`. Also covers REMOTE claude.ai connectors (a hosted Streamable-HTTP MCP server + OAuth 2.1) via the `claude-remote-connector` target — use when the user wants a cloud-reachable connector, not a local install.

```bash
gh skill install addaix/coact coact-publish --agent claude-code
```

Source: [`skills/coact-publish`](https://github.com/addaix/coact/tree/HEAD/skills/coact-publish).

### `coact-realize`

Use when turning a coact agent definition (or a skill) into something that actually runs — i.e. REALIZE. Triggers on “realize this agent”, “run a coact agent”, “materialize an agent for Claude Code”, “make an aw/Agent-SDK runnable from a skill”, “run a definition through LiteLLM/LangGraph/CrewAI”, “expose a skill’s tools as an MCP server”, or choosing between the host/sdk/litellm/langgraph/crewai/mcp backends and their cost. Covers realize(), the backends, install extras, and the fan-out cost gate.

```bash
gh skill install addaix/coact coact-realize --agent claude-code
```

Source: [`skills/coact-realize`](https://github.com/addaix/coact/tree/HEAD/skills/coact-realize).

## Subagents

Subagents are Markdown files with a frontmatter (`name`, `description`, `tools`) and a system prompt as the body. Copy one into your project’s `.claude/agents/` (or your agent host’s equivalent) to delegate the task it describes.

### `coact-docs-checker`

Use to verify coact’s documentation still matches its code — before a release, after an API change, or when README/docstrings/DECISIONS may have drifted. Dispatch to cross-check the README’s Python snippets and CLI commands against real signatures, the install extras against pyproject.toml, DECISIONS.md against the implementation, and that every module has a complete top-level docstring. Returns a list of concrete drift findings, not edits.

Source: [`.claude/agents/coact-docs-checker.md`](https://github.com/addaix/coact/tree/HEAD/.claude/agents/coact-docs-checker.md); tools: `Read, Grep, Glob, Bash`.

### `coact-reviewer`

Use to review a change, diff, or PR to the coact package against its invariants before it lands. Dispatch when code under coact/ has changed and you want a focused correctness + invariant audit (no-LLM mechanical path, lazy SDK import, point-don’t-copy, JSON-Schema return contract, open-closed registries, keyword-only discipline, module docstrings). Returns a structured verdict with file:line findings, not a rewrite.

Source: [`.claude/agents/coact-reviewer.md`](https://github.com/addaix/coact/tree/HEAD/.claude/agents/coact-reviewer.md); tools: `Read, Grep, Glob, Bash`.

## Machine-readable documentation

This site publishes the same documentation in forms that fit an agent’s context window:

- [`llms.txt`](https://addaix.github.io/coact/llms.txt): an index of every page with a one-line description ([llms.txt](https://llmstxt.org) format)
- [`coact.md`](https://addaix.github.io/coact/coact.md): the whole documentation as one Markdown file
- `<page>.html.md`: a rendered Markdown twin of every page, advertised from each page’s `<head>` with `<link rel="alternate" type="text/markdown">`
- [`objects.inv`](https://addaix.github.io/coact/objects.inv): the Sphinx inventory: a symbol-to-URL index (`sphobjinv convert plain objects.inv -`)


# api.html.md

# API reference

| [`coact`](_autosummary/coact.html.md#module-coact)   | coact — reuse your AI stuff across the layers of the modern agent stack.   |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------|


