ov.agents#

ov.agents — the optional in-package agent layer (Phase 4 productization).

This is the mechanical lift the spec promised (§7, D4): the Phase-1–3 deterministic core + the .claude/skills/ policy are re-hosted as runnable agents, with no rewrite. The lift is done by coact (COMPLETE a skill into an agent definition, REALIZE it onto a backend); this package is the thin ov-specific glue that coact intentionally leaves out — the operator’s live-browser loop, the analyst’s multimodal evidence-bundle call, and the orchestration topology.

Three things to know:

  • Host stays the manager (the cheap default). materialize() writes .claude/agents/ so Claude Code runs ov’s agents as subagents — zero LLM, no fan-out. In-package SDK agents (OperatorAgent, AnalystAgent, study()) are opt-in; estimate() surfaces the ~15× fan-out cost gate.

  • Reuse, don’t rewrite. Capture, the analyzers, the evidence-bundle assembler, the reliability passes and the synopsis map-reduce are used unchanged.

  • Injected, optional, model-free-by-default. Every LLM is dependency-injected; coact/aw/py2mcp are the ov[agents] extra, gated with a friendly error — importing this package needs none of them.

    >>> from ov.agents import OV_AGENTS, default_model
    >>> sorted(OV_AGENTS)
    ['arch-analyst', 'operator', 'orchestrator', 'ux-analyst']
    >>> default_model("operator")
    'haiku'
    
class ov.agents.AgentSpec(name, role, skill, lens=None, default_model='sonnet')[source]#

Bases: object

One ov agent: its name, role, source skill, optional lens, default model.

>>> AgentSpec("ov-analyze-ux", "analyst", "ov-analyze-ux", "ux").lens
'ux'
class ov.agents.AnalystAgent(lens, llm=None, judge=None, model=None, max_marks=20, task=None, name='')[source]#

Bases: object

Interpret a captured run’s evidence bundle into grounded findings (UX or Arch).

Parameters:
  • lens (str) – "ux" or "arch" — selects default model + finding defaults.

  • llm (Any) – the injected LLM (a callable, an object exposing structured for the multimodal path, an aw StepConfig, or None). Ignored if a judge is given.

  • judge (Optional[Callable[..., list]]) – (bundle, *, run, store) -> list[Finding | dict]. Override the whole LLM step (tests, alternative providers). Defaults to _default_judge().

  • model (Optional[str]) – model selector for the image-budget + info (defaults from the lens).

  • max_marks (int) – cap on Set-of-Mark regions in the bundle.

execute(input_data, context=None)[source]#

Analyze a run (or a prebuilt bundle) → (verified_findings, info) (aw protocol).

input_data may be a CaptureRun, an EvidenceBundle, or a mapping carrying run / store / bundle. The verified LLM findings are appended to run.findings (additive — source_layer keeps them distinct from deterministic facts) and returned.

Return type:

tuple[list[Finding], dict[str, Any]]

class ov.agents.OperatorAgent(decider, session=None, max_steps=12, strategy='ax_snapshot', polite_rate_s=0.0, no_progress_steps=3, observe_fn=None, act_fn=None, model='haiku', name='operator')[source]#

Bases: object

Drive a target toward a goal, recording every step (an aw.AgenticStep).

Parameters:
  • decider (Callable[..., Optional[Action]]) – (observation, *, goal, history) -> Action | None. Returns the next action, or None to stop. Use make_llm_decider() for a model-backed one, or any callable (host / script / test stub).

  • session (Any) – a CaptureSession (supplies .page + .run). Optional — page and run may instead arrive via the context passed to execute() (keys "page" / "run").

  • max_steps (int) – hard cap on actions (a budget; the deterministic loop signal is advisory, the cap is the backstop).

  • strategy (str) – perception strategy for the default observe ("ax_snapshot" | "screenshot" | "hybrid").

  • act_fn (Optional[Callable[[Any, Action], Any]]) – injection seams for the hands (default to the real observe() / act()); tests pass fakes.

execute(input_data, context=None)[source]#

Pursue input_data (the goal) and return (CaptureRun, info) (aw protocol).

Return type:

tuple[CaptureRun, dict[str, Any]]

class ov.agents.Orchestrator(llm=None, lenses=('ux', 'arch'), out_dir=None, store=None, capture_fn=<function _default_capture>, analyze_fn=<function _default_analyze>, report_fn=<function _default_report>, synopsis_fn=<function _default_synopsis>, capture_kwargs=dict())[source]#

Bases: object

Coordinate a full study, delegating each stage (never analyzing itself).

Parameters:
  • llm (Any) – the injected model for the analyst agents. None → deterministic-only study (the host-is-manager default; analysts are skipped).

  • lenses (tuple) – which analysis lenses to run ("ux" and/or "arch").

  • out_dir (Any) – where reports + synopsis are written (None → the run’s store).

  • synopsis_fn (Callable) – stage seams (default to the real ov facade). Inject fakes to unit-test the coordination.

  • capture_kwargs (dict) – extra kwargs forwarded to capture_fn (e.g. mode, authorized, crawl_pages, journey).

run(url)[source]#

Run the full study for url and return an OrchestratorResult.

Return type:

OrchestratorResult

ov.agents.agents_for_role(role)[source]#

All specs with role (e.g. both analysts).

>>> [s.lens for s in agents_for_role("analyst")]
['ux', 'arch']
Return type:

list[AgentSpec]

ov.agents.analyst_specs()[source]#

The UX + Arch analyst specs, in pipeline order (UX then Arch).

Return type:

list[AgentSpec]

ov.agents.arch_analyst(llm=None, **kwargs)[source]#

A software-architecture analyst (Opus-routed). llm is the injected model.

>>> arch_analyst().model
'opus'
Return type:

AnalystAgent

ov.agents.complete_agent(role_or_name, *, skills_dir=None, policy=None, llm=None)[source]#

COMPLETE one ov skill into a coact.AgentDefinition (the lift).

Mechanical by default (no LLM): model, tools, return contract and MCP wiring come from the skill’s coact: block. Pass llm= only to let coact draft a persona — the deterministic template path is used otherwise.

Return type:

Any

ov.agents.complete_all(*, roles=None, skills_dir=None, policy=None)[source]#

COMPLETE every ov agent (or roles) → {role: AgentDefinition}.

Return type:

dict[str, Any]

ov.agents.default_model(role)[source]#

The default model selector for a role (falls back to "sonnet").

>>> default_model("operator"), default_model("arch"), default_model("???")
('haiku', 'opus', 'sonnet')
Return type:

str

ov.agents.default_skills_dir()[source]#

Resolve the directory holding ov’s skills (env, then packaged, then repo).

Returns the first layout that actually contains skills; if none is found, the packaged path is returned so callers get a clear, consistent miss to report.

Deliberately not cached: it reads OV_SKILLS_DIR at call time (a few cheap Path checks), so an env change is always honoured. Resolution is invoked once per agent lift, not in a hot loop, so the cost is immaterial.

Return type:

Path

ov.agents.estimate(roles=None, *, skills_dir=None)[source]#

The cost gate — coact’s fan-out estimate over the selected ov agents.

Realizing an in-package fleet costs roughly an order of magnitude more tokens than the host path, and the premium is worst on interdependent work (ov’s analysts share the evidence bundle). Render this before spawning:

from ov.agents import estimate
print(estimate(["ux-analyst", "arch-analyst"]).render())
Return type:

Any

ov.agents.materialize(*, roles=None, dest=None, scope='project', project_dir=None, link=True, skills_dir=None, force=False, policy=None)[source]#

Realize ov’s agents on the host backend: write .claude/agents/ + link skills.

This is the cheap pit-of-success — it stands up no runtime. It emits one <name>.md per agent into dest (default: the project’s .claude/agents/) and symlinks each referenced skill into the sibling .claude/skills/ so Claude Code discovers both, then verifies discovery. Returns coact’s RealizedHost (.agents, .skills, .warnings).

Return type:

Any

ov.agents.mcp_server(*, name='ov', tools=None, input_trans=None)[source]#

Build a FastMCP server exposing ov to foreign hosts (via py2mcp).

>>> srv = mcp_server()
>>> srv.run()                               # serve over stdio
Return type:

Any

ov.agents.ov_tools()[source]#

The ov callables exposed as MCP tools (coarse, stateless, JSON-shaped).

Return type:

list[Callable]

ov.agents.realize_agent(role_or_name, *, backend='host', skills_dir=None, policy=None, **kwargs)[source]#

Realize a single ov agent on backend ("host" | "sdk" | "mcp").

sdk returns a coact.RunnableAgent (an aw.AgenticStep) for text-shaped agents; mcp exposes the skill’s declared coact: mcp: tools as a FastMCP server (foreign hosts). For ov’s live-browser / multimodal runtimes use OperatorAgent / AnalystAgent instead — coact’s text-prompt sdk agent can’t drive a page or send images.

Return type:

Any

ov.agents.resolve_llm(llm=None)[source]#

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

One injection convention: a callable (used as-is), an aw StepConfig, a model-name string, or None to discover an ambient provider. A plain callable short-circuits (no optional dependency needed); the other forms defer to coact.llm.resolve_llm().

>>> resolve_llm(lambda p: "hi")("x")
'hi'
ov.agents.skill_path(name, *, skills_dir=None)[source]#

Absolute path to skill name’s directory (the one holding SKILL.md).

Raises FileNotFoundError with an actionable hint when the skill is not discoverable, rather than letting coact fail later on a missing path.

Return type:

Path

ov.agents.structured(prompt, schema, *, llm=None, images=None, retries=1)[source]#

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

Resolution order honours dependency injection:

  1. if llm exposes a structured method, it is used as-is — this is the multimodal path (the method may accept images=); a real vision client plugs in here;

  2. otherwise fall through to coact’s portable text-only structured (any images are dropped — the bundle’s textual facts still ground the claims);

  3. if no LLM is resolvable at all, return None so callers fall back to a deterministic-only path (no crash, no provider lock-in).

Return type:

Optional[dict]

ov.agents.study(url, *, llm=None, lenses=('ux', 'arch'), **kwargs)[source]#

Run an end-to-end study of url (the in-package twin of the study-web-app skill).

The pit-of-success one-liner: capture → analyze → (optional analyst judgment) → report → synopsis. With llm=None it is fully deterministic; pass an injected model to add grounded UX/Arch narrative. Forwards mode / authorized / crawl_pages / out_dir / stage seams via **kwargs.

Return type:

OrchestratorResult

ov.agents.ux_analyst(llm=None, **kwargs)[source]#

A UX/accessibility analyst (Sonnet-routed). llm is the injected model.

>>> a = ux_analyst()
>>> a.lens, a.model, a.name
('ux', 'sonnet', 'ux-analyst')
Return type:

AnalystAgent

Modules

analyst

The Analyst agents (UX + Arch) — grounded judgment over an evidence bundle.

definitions

SSOT: which ov skills become which agents (role, lens, model routing).

llm

Provider-agnostic LLM facade for the ov agent layer (thin, injected, optional).

mcp

Expose ov to non-Claude-Code hosts as an MCP server (via py2mcp).

operator

The Operator agent — the model-bound perceive→decide→act→record loop.

orchestrator

The Orchestrator — a pure coordinator over the study pipeline (aw workflow).

realize

The mechanical lift — turn ov's skills into agent definitions and realize them.