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 is one object that can serialize to both the
filesystem .claude/agents/*.md format and the Claude Agent SDK form (see
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— the agent’s final-message schema (so a manager can deterministically consume its output); the single most important “extra”.AgentDefinition— the SSOT object.AgentPlan/FieldProvenance— the inspectable dry-run result of COMPLETE, recording where every synthesized field came from.
Module Attributes
Host model selector values (the Agent SDK |
|
Subagent memory scope. |
|
Provenance source tags — where a synthesized field's value originated. |
Classes
|
The SSOT: one object, two serializations (filesystem md + SDK form). |
|
The inspectable result of |
|
Where one |
|
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)[source]¶
Bases:
objectThe 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), plus the coact-specificreturns/consumes.tools=Nonemeans inherit all tools; an empty list means no tools — the distinction is preserved.>>> ad = AgentDefinition(name='ux-analyst', description='Analyze UX bundles.') >>> ad.name, ad.tools, ad.returns.is_empty() ('ux-analyst', None, True)
- class coact.base.AgentPlan(agent, provenance=list(), warnings=list())[source]¶
Bases:
objectThe inspectable result of
plan_completion: the agent + its provenance.Shows the proposed
AgentDefinitionand, 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()[source]¶
Render a human-readable provenance table for terminal display.
>>> 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:
- class coact.base.FieldProvenance(field, value, source, note='')[source]¶
Bases:
objectWhere one
AgentDefinitionfield’s value came from (dry-run audit).>>> FieldProvenance('model', 'sonnet', 'policy', 'default worker').source 'policy'
- coact.base.ModelName¶
Host model selector values (the Agent SDK
modelliteral).alias of
Literal[‘sonnet’, ‘opus’, ‘haiku’, ‘inherit’]
- coact.base.ProvenanceSource¶
Provenance source tags — where a synthesized field’s value originated.
alias of
Literal[‘skill’, ‘coact-frontmatter’, ‘policy’, ‘inferred’, ‘synthesized-template’, ‘synthesized-llm’, ‘default’]
- class coact.base.ReturnContract(json_schema=dict(), ref=None, description='')[source]¶
Bases:
objectThe 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).
refrecords a'module:Name'source if the schema was resolved from a Pydantic model / dataclass / TypedDict.>>> rc = ReturnContract(json_schema={'type': 'object'}, description='findings') >>> rc.is_empty() False >>> ReturnContract().is_empty() True- classmethod from_dict(d)[source]¶
Parse from a
coact: returnsmapping (acceptsschema_reforjson_schema).>>> ReturnContract.from_dict({'schema_ref': 'ov.schemas:UxFindings'}).ref 'ov.schemas:UxFindings'- Return type:
- schema()[source]¶
Return the canonical JSON Schema, resolving
refif needed (else{}).Honors DECISIONS D6 (“JSON Schema is canonical; refs resolve to it”): an inline
json_schemawins; otherwise amodule:Namerefis resolved best-effort to a schema. Returns{}when neither is available.>>> ReturnContract(json_schema={'type': 'object'}).schema() {'type': 'object'} >>> 'properties' in ReturnContract(ref='coact.base:ReturnContract').schema() True- Return type: