> built 2026-11-30 22:24 UTC from 50cf785 (main) · aw 0.1.14. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# aw - Agentic Workflows for Data Preparation

An AI agent package for data preparation with a focus on modular, extensible workflows that follow best practices from modern agentic architectures.

## Installation

```bash
pip install aw
```

### Optional Dependencies

```bash
# For LangChain code execution
pip install langchain langchain-experimental

# For cosmograph validation
pip install cosmograph

# For OpenAI LLM
pip install openai

# LLM calls go through aix (a dependency); oa is only an optional fallback
pip install 'aw[llm]'
```

## Quick Start

### Simple Example: Load and Prepare for Cosmograph

```python
from aw import load_for_cosmo

# Load and prepare data in one call
df, metadata = load_for_cosmo("data.csv")

# Use with cosmograph
from cosmograph import cosmo

params = metadata["preparing"]["metadata"]["validation_result"]["params"]
cosmo(df, **params)
```

### Step-by-Step Example

```python
from aw import LoadingAgent, PreparationAgent, Context
from aw.cosmo import basic_cosmo_validator

# Create context
context = Context()

# Step 1: Load data
loading_agent = LoadingAgent()
df, loading_meta = loading_agent.execute("data.csv", context)

print(f"Loaded {df.shape[0]} rows, {df.shape[1]} columns")

# Step 2: Prepare data
preparing_agent = PreparationAgent(
    target="cosmo-ready", target_validator=basic_cosmo_validator()
)
prepared_df, prep_meta = preparing_agent.execute(df, context)

print(f"Prepared data: {prep_meta['validation_result']}")
```

### Workflow Example

```python
from aw import create_cosmo_prep_workflow

# Create a complete workflow
workflow = create_cosmo_prep_workflow(max_retries=5)

# Run it
result_df, metadata = workflow.run("data.csv")

# Check results
if metadata["success"]:
    print("Success!")
    print(f"Steps executed: {[s['name'] for s in metadata['steps']]}")
else:
    print(f"Failed at: {metadata.get('failed_at')}")
```

## Features

- **AgenticStep Protocol**: Build modular agents that follow a consistent interface
- **ReAct Pattern**: Reason-Act-Observe loops with automatic retry logic
- **Three Validation Flavors**: Schema-based, info-dict based, and functional validation
- **Code Execution**: Safe defaults with extensibility for robust backends (LangChain, DSPy)
- **Loading Agent**: Automatically loads data from various sources into pandas DataFrames
- **Preparation Agent**: Transforms data to meet target requirements
- **Cosmograph Support**: Specialized validators for cosmograph visualization
- **Orchestration**: Chain multiple steps together with context management
- **Human-in-Loop**: Optional human approval at any step

## Architecture

### Core Concepts

#### AgenticStep Protocol

All agents implement the `AgenticStep` protocol:

```python
def execute(
    self, input_data: Any, context: MutableMapping[str, Any]
) -> tuple[ArtifactType, dict[str, Any]]:
    """Execute the agentic step following ReAct pattern"""
    ...
```

#### ReAct Pattern

Each agent follows the Reason-Act-Observe loop:

1. **Reason (Thought)**: Analyze input and context to decide action
2. **Act (Action)**: Generate and execute code or use tools
3. **Observe**: Capture results and validate
4. **Repeat or Finish**: Based on validation, retry or proceed

#### Three Validation Flavors

1. **Schema-based**: Use Pydantic models or JSON schemas
2. **Info-dict based**: Compute info → check info → pass/fail
3. **Functional**: Try to use the artifact for its purpose

```python
from aw.validation import schema_validator, info_dict_validator, functional_validator

# Schema validation
from pydantic import BaseModel


class DataSchema(BaseModel):
    x: float
    y: float


validate = schema_validator(DataSchema)


# Info-dict validation
def compute_info(df):
    return {"null_count": df.isnull().sum().sum()}


def check_info(info):
    return info["null_count"] == 0, "No nulls allowed"


validate = info_dict_validator(compute_info, check_info)


# Functional validation (try the purpose)
def try_visualize(df):
    return cosmograph.cosmo(df, points_x_by="x", points_y_by="y")


validate = functional_validator(try_visualize)
```

### Configuration System

Supports both simple objects and callables with cascading defaults:

```python
from aw import GlobalConfig, StepConfig

# Global defaults
global_config = GlobalConfig(llm="gpt-4", max_retries=3)

# Step-specific override
step_config = global_config.override(llm="gpt-3.5-turbo", max_retries=5)


# Or pass callables
def my_llm(prompt):
    return "Response to: " + prompt


step_config = StepConfig(
    llm=my_llm,  # Function instead of string
    validator=lambda x: (True, {}),
    max_retries=3,
)
```

### Tools

#### CodeInterpreterTool

Safe code execution with extensibility:

```python
from aw import CodeInterpreterTool

# Default (safe exec)
tool = CodeInterpreterTool()
result = tool("x = 5; y = x * 2; print(y)")
print(result.output)  # "10"

# With LangChain backend
from aw import create_langchain_executor

tool = CodeInterpreterTool(executor=create_langchain_executor())
```

#### FileSamplerTool

Sample and analyze files before loading:

```python
from aw import FileSamplerTool

sampler = FileSamplerTool()
info = sampler("data.csv")
print(info["extension"])  # '.csv'
print(info["sample_text"])  # First 1024 bytes
```

### Custom Agents

Build your own agents following the pattern:

```python
from aw.base import AgenticStep, StepConfig
from collections.abc import MutableMapping
from typing import Any


class MyCustomAgent:
    """Custom agent following AgenticStep protocol"""

    def __init__(self, config: StepConfig = None):
        self.config = config or StepConfig()
        self.llm = self.config.resolve_llm()
        self.validator = self.config.resolve_validator()

    def execute(
        self, input_data: Any, context: MutableMapping[str, Any]
    ) -> tuple[Any, dict]:
        attempts = []

        for attempt in range(self.config.max_retries):
            # 1. Reason: Analyze situation
            thought = self._analyze(input_data, attempts)

            # 2. Act: Perform action
            result = self._act(thought)

            # 3. Observe: Validate
            is_valid, info = self.validator(result)
            attempts.append({"attempt": attempt, "info": info})

            if is_valid:
                context["my_agent"] = {"result": result, "info": info}
                return result, {"success": True, "attempts": attempts}

        return None, {"success": False, "attempts": attempts}
```

## Advanced Usage

### Interactive Workflows with Human-in-Loop

```python
from aw import InteractiveWorkflow, LoadingAgent, PreparationAgent

workflow = InteractiveWorkflow()
workflow.add_step("loading", LoadingAgent(), require_approval=True)
workflow.add_step("preparing", PreparationAgent(), require_approval=False)


# Set custom approval callback
def approve(step_name, artifact, metadata):
    print(f"\nStep '{step_name}' completed")
    print(f"Artifact shape: {artifact.shape}")
    return input("Continue? (y/n): ").lower() == "y"


workflow.set_approval_callback(approve)

# Run interactively
result, metadata = workflow.run_interactive("data.csv")
```

### Custom Validators

Create domain-specific validators:

```python
from aw.validation import info_dict_validator


def compute_ml_info(df):
    return {
        "num_features": len(df.columns) - 1,
        "num_samples": len(df),
        "class_balance": df["target"].value_counts().to_dict(),
    }


def check_ml_requirements(info):
    if info["num_features"] < 5:
        return False, "Need at least 5 features"
    if info["num_samples"] < 100:
        return False, "Need at least 100 samples"
    return True, "ML ready"


ml_validator = info_dict_validator(compute_ml_info, check_ml_requirements)
```

### Partial Workflow Execution

```python
from aw import create_data_prep_workflow

workflow = create_data_prep_workflow()

# Run only the loading step
df, metadata = workflow.run_partial("data.csv", stop_after="loading")

# Inspect intermediate result
print(f"Loaded {df.shape}")

# Continue with preparing
final_df, final_meta = workflow.run_partial(df, stop_after="preparing")
```

## Dispatching to a skill (cheap-first)

`aw.dispatch` assembles the chain decided in opsward ADR 0011: retrieval over a skills corpus answers only when its ranking is clear, and an LLM adjudicator sees the raw request plus the top-k candidates only on ambiguity. Nothing routes until a boundary is configured.

```python
from aw.dispatch import skills_dispatch_chain, Adjudicator

chain = skills_dispatch_chain()  # needs `pip install aw[ir]`
chain("open an issue for the client about the broken export")  # -> 'ge-write-issue'
chain.trace("deploy the site")  # layer, ranked candidates, reason
chain = skills_dispatch_chain(
    adjudicate=Adjudicator()
)  # escalate through aix.chat on ambiguity
```

`aw.routing.ConfidentRetrievalStrategy` is the generic piece (any `search(query) -> [(candidate, score)]`), with `floor`, absolute `gap`, relative `rel_gap`, and `dedup_key`.

## Design Principles

The package follows these principles:

1. **Functional over OOP**: Favor functions and generators
2. **Modularity**: Small, focused functions with clear purposes
3. **Open-Closed**: Easy to extend without modifying core
4. **Dependency Injection**: Abstract interfaces with injectable implementations
5. **Mapping Interfaces**: Use `Mapping`/`MutableMapping` from `collections.abc`
6. **Generators over Lists**: Use lazy evaluation when possible
7. **Minimal Doctests**: Simple examples in docstrings

## Project Structure

```default
aw/
├── __init__.py         # Main exports
├── base.py            # Core protocols and configs
├── validation.py      # Three validation flavors
├── tools.py           # Code execution and tools
├── utils.py           # Helpers and facades
├── loading.py         # LoadingAgent
├── preparing.py       # PreparationAgent
├── cosmo.py          # Cosmograph validators
└── orchestration.py   # Workflow management
```

## Contributing

Contributions welcome! Key areas:

- Additional validators for other visualization libraries
- More robust LLM reasoning in code generation
- Integration with more backends (DSPy, CrewAI)
- State management with lakeFS/DVC
- Additional agent types (sourcing, finding, etc.)

## License

See LICENSE file.

## Credits

Built following best practices from:

- ReAct pattern (Reasoning and Acting)
- LangChain’s agent architectures
- CrewAI’s multi-agent systems
- Data Version Control (DVC) principles

<p class="epythet-aggregates">This documentation as a single file: <a href="aw.md">aw.md</a> (Markdown, for agents).</p>


# _autosummary/aw.base.html.md

# aw.base

Core protocols and base classes for agentic workflows.

This module provides the foundational abstractions for building AI agents
that follow the AgenticStep protocol with ReAct pattern (Reason-Act-Observe).

### Classes

| [`AgenticStep`](_autosummary/aw.base.html.md#aw.base.AgenticStep)(\*args, \*\*kwargs)                 | Protocol defining the interface for any agentic step in a workflow.   |
|--------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`Context`](_autosummary/aw.base.html.md#aw.base.Context)([initial_data])                         | Context for sharing state and artifacts between agentic steps.        |
| [`GlobalConfig`](_autosummary/aw.base.html.md#aw.base.GlobalConfig)([llm, max_retries, human_in_loop]) | Global configuration with cascading defaults.                         |
| [`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)([llm, validator, tools, ...])        | Configuration for an AgenticStep.                                     |
| [`Tool`](_autosummary/aw.base.html.md#aw.base.Tool)(\*args, \*\*kwargs)                        | Protocol for tools that agents can use.                               |
| [`Validator`](_autosummary/aw.base.html.md#aw.base.Validator)(\*args, \*\*kwargs)                   | Protocol for validation functions.                                    |

### *class* aw.base.AgenticStep(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)[`ArtifactType`]

Protocol defining the interface for any agentic step in a workflow.

Each step follows the ReAct pattern:

1. Reason (Thought): Analyze input and context
2. Act (Action): Generate and execute code or use tools
3. Observe: Capture results and validate
4. Repeat or finish based on validation

### Example

```pycon
>>> class MyAgent:
...     def execute(self, input_data, context):
...         # Agent implementation
...         return result, metadata
```

#### execute(input_data, context)

Execute the agentic step.

* **Parameters:**
  * **input_data** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – The input to process
  * **context** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Mutable mapping containing shared state and history
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[`ArtifactType`, [`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)]]
* **Returns:**
  Tuple of (artifact, metadata) where artifact is the main output
  and metadata contains auxiliary information

### *class* aw.base.Context(initial_data=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), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

Context for sharing state and artifacts between agentic steps.

Implements MutableMapping interface for dict-like behavior while
providing additional functionality for managing agent state.

### Example

```pycon
>>> ctx = Context()
>>> ctx['loading'] = {'df': df, 'info': {...}}
>>> ctx['preparing'] = {'df': prepared_df}
```

#### *property* history *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]*

Access the history of all context updates.

#### snapshot()

Create a snapshot of current context state.

* **Return type:**
  [`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)]
* **Returns:**
  A dict copy of current context data

### *class* aw.base.GlobalConfig(llm='gpt-4', max_retries=3, human_in_loop=False)

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

Global configuration with cascading defaults.

Provides defaults that can be overridden at step or agent level.

### Example

```pycon
>>> global_cfg = GlobalConfig(llm="gpt-4", max_retries=5)
>>> step_cfg = global_cfg.override(llm="gpt-3.5-turbo")
```

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

Create a StepConfig with overridden values.

* **Parameters:**
  **\*\*kwargs** – Values to override from global defaults
* **Return type:**
  [`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)
* **Returns:**
  A new StepConfig with merged configuration

### *class* aw.base.StepConfig(llm='gpt-4', validator=None, tools=list(), max_retries=3, human_in_loop=False)

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

Configuration for an AgenticStep.

Supports both simple objects (strings, ints) and callables for maximum
flexibility with dependency injection.

#### llm

Either a model name string or a text-to-text chat function

* **Type:**
  [`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`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)]]

#### validator

Validation callable or schema object

* **Type:**
  [`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### tools

List of callable tools available to the agent

* **Type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]

#### max_retries

Maximum number of retry attempts

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### human_in_loop

Whether to require human approval/intervention

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

### Example

```pycon
>>> config = StepConfig(
...     llm="gpt-4",
...     validator=lambda x: (True, {}),
...     max_retries=3
... )
```

#### resolve_llm()

Resolve llm to a callable function.

* **Return type:**
  [`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)]
* **Returns:**
  A callable that takes a prompt string and returns a response string

#### resolve_validator()

Resolve validator to a callable.

* **Return type:**
  [`Validator`](_autosummary/aw.base.html.md#aw.base.Validator)
* **Returns:**
  A callable that validates artifacts

### *class* aw.base.Tool(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Protocol for tools that agents can use.

Tools are callable objects that perform specific actions like
executing code, sampling files, or calling external APIs.

### Example

```pycon
>>> class FileSampler:
...     def __call__(self, uri):
...         # Sample file logic
...         return {'extension': '.csv', 'sample': '...'}
```

### *class* aw.base.Validator(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Protocol for validation functions.

Validators check if an artifact meets requirements and return
both a success indicator and detailed information.

### Example

```pycon
>>> def is_non_empty_dataframe(df):
...     success = df is not None and len(df) > 0
...     info = {'shape': df.shape if success else None}
...     return success, info
```


# _autosummary/aw.cosmo.html.md

# aw.cosmo

Cosmograph-specific validator tool.

Provides functional validation for cosmograph visualization requirements.

### Functions

| [`basic_cosmo_validator`](_autosummary/aw.cosmo.html.md#aw.cosmo.basic_cosmo_validator)()                       | Basic validator that checks structural requirements only.   |
|------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [`create_cosmo_validator`](_autosummary/aw.cosmo.html.md#aw.cosmo.create_cosmo_validator)([cosmo_function, ...]) | Create a validator for cosmograph requirements.             |
| [`infer_cosmo_params`](_autosummary/aw.cosmo.html.md#aw.cosmo.infer_cosmo_params)(df)                        | Infer suitable cosmograph parameters from DataFrame.        |
| [`strict_cosmo_validator`](_autosummary/aw.cosmo.html.md#aw.cosmo.strict_cosmo_validator)()                      | Strict validator that actually calls cosmograph.            |
| [`try_cosmo_visualization`](_autosummary/aw.cosmo.html.md#aw.cosmo.try_cosmo_visualization)(df[, cosmo_function]) | Try to create a cosmograph visualization.                   |

### aw.cosmo.basic_cosmo_validator()

Basic validator that checks structural requirements only.

Does not require cosmograph to be installed.

### Example

```pycon
>>> validator = basic_cosmo_validator()
>>> success, info = validator(df)
```

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

### aw.cosmo.create_cosmo_validator(cosmo_function=None, required_columns=2, allow_generated_params=True)

Create a validator for cosmograph requirements.

This validator attempts to actually call cosmograph.cosmo() with the
DataFrame to see if it’s ready for visualization.

* **Parameters:**
  * **cosmo_function** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – The cosmograph.cosmo function (imported if None)
  * **required_columns** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Minimum number of numeric columns needed
  * **allow_generated_params** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to auto-infer x/y columns
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  Validator function following (artifact) -> (success, info) protocol

### Example

```pycon
>>> validator = create_cosmo_validator()
>>> success, info = validator(df)
>>> if success:
...     print(f"Can visualize with: {info['params']}")
```

### aw.cosmo.infer_cosmo_params(df)

Infer suitable cosmograph parameters from DataFrame.

* **Parameters:**
  **df** – pandas DataFrame
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict of suggested parameters for cosmograph.cosmo()

### Example

```pycon
>>> params = infer_cosmo_params(df)
>>> from cosmograph import cosmo
>>> cosmo(df, **params)
```

### aw.cosmo.strict_cosmo_validator()

Strict validator that actually calls cosmograph.

Requires cosmograph to be installed.

### Example

```pycon
>>> validator = strict_cosmo_validator()
>>> success, info = validator(df)
```

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

### aw.cosmo.try_cosmo_visualization(df, cosmo_function=None, \*\*cosmo_kwargs)

Try to create a cosmograph visualization.

This is a functional validator that actually attempts the visualization.

* **Parameters:**
  * **df** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – DataFrame to visualize
  * **cosmo_function** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – The cosmograph.cosmo function
  * **\*\*cosmo_kwargs** – Additional arguments for cosmo
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]
* **Returns:**
  Tuple of (success, info)

### Example

```pycon
>>> from cosmograph import cosmo
>>> success, info = try_cosmo_visualization(df, cosmo)
```


# _autosummary/aw.dispatch.html.md

# aw.dispatch

Cheap-first dispatch to a skill: calibrated retrieval first, an LLM adjudicator only on ambiguity.

The chain decided in opsward ADR 0011 (`misc/docs/decisions/0011-cheap-first-dispatch-no-router-agent.md`
in thorwhalen/opsward): a route in the instructions and the host’s own skill listing are
the first two layers and belong to the host; this module is layers three and four, as code:

```default
chain = skills_dispatch_chain(adjudicate=Adjudicator(ask=my_llm))
chain("open an issue for the client about the broken export")   # -> 'ge-write-issue' or None
chain.trace("…")   # which layer answered, the ranked candidates, the reason
```

- [`ir_search()`](_autosummary/aw.dispatch.html.md#aw.dispatch.ir_search) adapts `ir.discover` (lexical by default: the only mode fast enough
  for a hot path) to the `search(query) -> [(candidate, score)]` shape, with copies of one
  skill (`name@base`) collapsed to the best one.
- [`aw.routing.ConfidentRetrievalStrategy`](_autosummary/aw.routing.html.md#aw.routing.ConfidentRetrievalStrategy) answers only on a clear ranking and
  abstains until a boundary (floor, gap or relative gap) is configured.
- [`Adjudicator`](_autosummary/aw.dispatch.html.md#aw.dispatch.Adjudicator) is the escalation: an LLM shown the raw request and the top-k
  candidates with their descriptions, answering with one of them or none. Never the whole
  catalog, never a summary of the request.
- [`DispatchChain`](_autosummary/aw.dispatch.html.md#aw.dispatch.DispatchChain) wires them and keeps the ranked list between the two, which a
  plain [`aw.routing.PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter) cannot do.

`ir` is an optional dependency (`pip install aw[ir]`); everything here is testable with
a fake search and a fake `ask`.

### Functions

| [`ir_search`](_autosummary/aw.dispatch.html.md#aw.dispatch.ir_search)([corpus, mode, k, discover])            | A `search(query) -> [(name, score)]` over an `ir` corpus, copies collapsed.          |
|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [`skill_name`](_autosummary/aw.dispatch.html.md#aw.dispatch.skill_name)(candidate)                             | The skill a corpus record stands for: `'branch-hygiene@priv'` -> `'branch-hygiene'`. |
| [`skills_dispatch_chain`](_autosummary/aw.dispatch.html.md#aw.dispatch.skills_dispatch_chain)(\*[, corpus, mode, k, ...]) | The ADR 0011 chain over the `ir` skills corpus, ready to call.                       |

### Classes

| [`Adjudicator`](_autosummary/aw.dispatch.html.md#aw.dispatch.Adjudicator)([ask, describe, k, none_token])       | The escalation layer: an LLM picks one of the top-k candidates for the raw request, or none.   |
|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
| [`DispatchChain`](_autosummary/aw.dispatch.html.md#aw.dispatch.DispatchChain)(search[, floor, gap, rel_gap, ...]) | Retrieval, then confident selection, then adjudication; with a trace of which layer answered.  |

### *class* aw.dispatch.Adjudicator(ask=<function \_default_ask>, describe=None, k=5, none_token='NONE')

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

The escalation layer: an LLM picks one of the top-k candidates for the raw request, or none.

`ask(prompt) -> str` is the model call (default: `aix.chat`, via [`aw.llm`](_autosummary/aw.llm.html.md#module-aw.llm)); `describe(name)`
returns a candidate’s description so the model sees cards, not bare names. The model
sees the user’s words verbatim: a summary is a lossy channel (opsward ADR 0011 §3).

```pycon
>>> adj = Adjudicator(ask=lambda p: 'ge-write-issue', describe={'ge-write-issue': 'Write an issue.'}.get)
>>> adj('open an issue for the client', [('ge-write-issue', 9.0), ('ge', 8.9)])
'ge-write-issue'
>>> Adjudicator(ask=lambda p: 'NONE')('x', [('a', 1.0)]) is None
True
>>> Adjudicator(ask=lambda p: 'something-else')('x', [('a', 1.0)]) is None   # not a candidate: no guess
True
```

### *class* aw.dispatch.DispatchChain(search, floor=0.0, gap=0.0, rel_gap=None, adjudicate=None, k_adjudicate=5)

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

Retrieval, then confident selection, then adjudication; with a trace of which layer answered.

```pycon
>>> table = {'clear': [('a', 10.0), ('b', 5.0)], 'close': [('a', 10.0), ('b', 9.8)], 'none': []}
>>> chain = DispatchChain(search=table.get, rel_gap=0.9, adjudicate=Adjudicator(ask=lambda p: 'b'))
>>> chain('clear'), chain('close'), chain('none')
('a', 'b', None)
>>> chain.trace('close')['layer'], chain.trace('clear')['layer'], chain.trace('none')['layer']
('adjudicate', 'retrieval', 'none')
>>> DispatchChain(search=table.get, rel_gap=0.9)('close') is None   # no adjudicator: abstain
True
```

#### trace(request)

`{'layer', 'answer', 'ranked', 'reason'}` for *request*; the model is called only on ambiguity.

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

### aw.dispatch.ir_search(corpus='skills', , mode='lexical', k=10, discover=None)

A `search(query) -> [(name, score)]` over an `ir` corpus, copies collapsed.

`discover` defaults to `ir.discover` (imported lazily, so `aw` itself does not
depend on `ir`); pass any callable with the same result shape to test without it.
Scores are the engine’s (BM25-like for lexical), so calibrate `floor` per corpus.

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

### aw.dispatch.skill_name(candidate)

The skill a corpus record stands for: `'branch-hygiene@priv'` -> `'branch-hygiene'`.

```pycon
>>> skill_name('ge-write-issue@g_ai'), skill_name('deslop')
('ge-write-issue', 'deslop')
```

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

### aw.dispatch.skills_dispatch_chain(, corpus='skills', mode='lexical', k=10, floor=0.0, rel_gap=0.75, adjudicate=None, discover=None)

The ADR 0011 chain over the `ir` skills corpus, ready to call.

Defaults: lexical mode; a relative gap of 0.75 (the runner-up must score at most 75% of
the top), the point on the 14-prompt probe set of opsward ADR 0011 where the chain
gives no confident wrong answer (9 confident, 5 escalated; at 0.9 it answers 12 right
and 2 wrong); no floor until `ir calibrate-min-score` has produced one for the
corpus; no adjudicator (pass an [`Adjudicator`](_autosummary/aw.dispatch.html.md#aw.dispatch.Adjudicator) to escalate instead of abstaining).

* **Return type:**
  [`DispatchChain`](_autosummary/aw.dispatch.html.md#aw.dispatch.DispatchChain)


# _autosummary/aw.func_calling.html.md

# aw.func_calling

This module provides robust templates for creating (python) code-generating functions
that can translate natural language task descriptions into executable Python code.

### Functions

| [`extract_function_from_code`](_autosummary/aw.func_calling.html.md#aw.func_calling.extract_function_from_code)(code_str_for_func, \*)   | Extract a function from a string of Python code.                  |
|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [`make_code_generator`](_autosummary/aw.func_calling.html.md#aw.func_calling.make_code_generator)([template, code_schema, ...])   | Create a code generation function from a template and schema.     |
| [`task_to_function`](_autosummary/aw.func_calling.html.md#aw.func_calling.task_to_function)(task[, output_schema, ...])        | End-to-end: Convert a task description to an executable function. |

### aw.func_calling.extract_function_from_code(code_str_for_func, , make_picklable=False, strict=True, verbose=True)

Extract a function from a string of Python code.

* **Parameters:**
  * **code_str_for_func** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – String containing a Python function definition
  * **make_picklable** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, make the function picklable by adding it to \_\_main_\_
  * **strict** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, enforce strict validation (no multiple functions, no syntax errors)
  * **verbose** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, print status messages
* **Return type:**
  `callable`
* **Returns:**
  The function object
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If no function is found or multiple functions exist

### Example

```pycon
>>> code = '''
... def add(a: int, b: int) -> dict:
...     return {"sum": a + b}
... '''
>>> func = extract_function_from_code(code, verbose=False)
>>> func(2, 3)
{'sum': 5}
```

### aw.func_calling.make_code_generator(template='\\nYou are a Python code generator. Your task is to create a complete, executable Python function.\\n\\n## TASK DESCRIPTION\\n{task}\\n\\n## OUTPUT SCHEMA\\nThe function should return a value that conforms to this JSON schema:\\n\\n{output_schema}\\n\\nIf output_schema is null or empty, the function can return any appropriate value.\\n\\n## REQUIREMENTS\\n\\n### Function Signature\\n- Function name: \`{name}\`\\n- Parameters: Extract from the task description (indicated by {{braces}})\\n- All parameters should have type hints where possible\\n- Use clear, descriptive parameter names\\n\\n### Code Quality\\n- Write ONLY the function definition (no imports in function body, no examples, no explanations)\\n- Include a minimal docstring (one line describing what it does)\\n- Use type hints for parameters and return value\\n- Handle edge cases appropriately (e.g., empty inputs, None values)\\n- Use built-in functions and standard library where possible\\n- Keep the code simple and readable\\n\\n### Output Format\\n- If returning a dict matching a schema, ensure all required fields are present\\n- If the schema specifies types, ensure they match (e.g., "number" → int or float)\\n- Return values directly without unnecessary wrapping\\n\\n### Code Style\\n- Follow PEP 8 conventions\\n- Use meaningful variable names\\n- Prefer comprehensions over loops where readable\\n- No print statements or side effects unless the task requires them\\n\\n## CRITICAL INSTRUCTIONS\\n- Respond with ONLY the function definition\\n- Do NOT include: imports, examples, explanations, markdown formatting, or test code\\n- Do NOT wrap the code in markdown code blocks\\n- The response must be valid Python that can be directly executed with \`exec()\`\\n\\n## EXAMPLE FORMAT (for reference only, do not include this in your response)\\n\`\`\`python\\ndef example_function(param1: int, param2: str) -> dict:\\n    """Brief description of what this does."""\\n    # function body\\n    return {{"result": param1}}\\n\`\`\`\\n\\nNOW GENERATE THE FUNCTION.\\n', code_schema={'name': 'generated_python_function', 'schema': {'properties': {'code': {'description': 'Complete Python function definition as a string', 'type': 'string'}}, 'required': ['code'], 'type': 'object'}}, prompt_json_function_maker=None)

Create a code generation function from a template and schema.

* **Parameters:**
  * **template** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The prompt template for code generation
  * **code_schema** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)) – JSON schema defining the output format
  * **prompt_json_function_maker** – Factory function (defaults to aix.prompt_to_json via aw.llm)
* **Returns:**
  A function that generates code from task descriptions

#### NOTE
The returned function requires all template variables to be provided.
See CODE_WRITING_TEMPLATE for required variables (task, output_schema, name).

### aw.func_calling.task_to_function(task, output_schema=None, name='generated_function', code_generator=None, \*\*generator_kwargs)

End-to-end: Convert a task description to an executable function.

* **Parameters:**
  * **task** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Natural language description of the function’s purpose
  * **output_schema** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict) | [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – JSON schema for the return value (optional)
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name for the generated function
  * **code_generator** – Code generation function (creates one if None)
  * **\*\*generator_kwargs** – Additional arguments for code generator
* **Return type:**
  `callable`
* **Returns:**
  Executable Python function

#### NOTE
This function requires an LLM backend (via code_generator or the ‘oa’ package).
Cannot be tested in doctests without mocking the LLM calls.


# _autosummary/aw.html.md

# aw

aw - Agentic Workflows for Data Preparation

An AI agent package for data preparation with a focus on loading and preparing
data for various purposes (e.g., visualization with cosmograph).

Key Features:

- AgenticStep protocol for building modular agents
- ReAct pattern (Reason-Act-Observe) with retry logic
- Three validation flavors: schema, info-dict, and functional
- Code execution with safe defaults and extensibility
- Loading and Preparation agents for data workflows
- Cosmograph-specific validators and utilities
- Orchestration for chaining multiple steps

### Example

```pycon
>>> from aw import load_for_cosmo
>>> df, metadata = load_for_cosmo('data.csv')
>>> from cosmograph import cosmo
>>> params = metadata['preparing']['metadata']['validation_result']['params']
>>> cosmo(df, **params)
```

Architecture:

> - aw.base: Core protocols and configurations
> - aw.validation: Three validation flavors
> - aw.tools: Code execution and agent tools
> - aw.utils: Helper functions and facades
> - aw.loading: LoadingAgent for data ingestion
> - aw.preparing: PreparationAgent for data transformation
> - aw.cosmo: Cosmograph-specific validators
> - aw.orchestration: Workflow management

### Functions

| [`schema_validator`](_autosummary/aw.html.md#aw.schema_validator)(schema)                           | Create a validator from a schema (Pydantic, JSON Schema, etc.).                                                                               |
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| [`info_dict_validator`](_autosummary/aw.html.md#aw.info_dict_validator)(compute_info, check_info)      | Create a validator that computes info then checks it.                                                                                         |
| [`functional_validator`](_autosummary/aw.html.md#aw.functional_validator)(try_function[, ...])          | Create a validator that tries to use the artifact for its purpose.                                                                            |
| [`all_validators`](_autosummary/aw.html.md#aw.all_validators)(\*validators)                       | Combine multiple validators - all must pass.                                                                                                  |
| [`any_validator`](_autosummary/aw.html.md#aw.any_validator)(\*validators)                        | Combine multiple validators - at least one must pass.                                                                                         |
| [`is_type`](_autosummary/aw.html.md#aw.is_type)(expected_type)                             | Validator that checks artifact type.                                                                                                          |
| [`is_not_empty`](_autosummary/aw.html.md#aw.is_not_empty)()                                     | Validator that checks artifact is not empty.                                                                                                  |
| [`has_attributes`](_autosummary/aw.html.md#aw.has_attributes)(\*\*required_attrs)                 | Validator that checks artifact has required attributes.                                                                                       |
| [`create_langchain_executor`](_autosummary/aw.html.md#aw.create_langchain_executor)()                        | Create an executor using LangChain's CodeInterpreter (if available).                                                                          |
| [`djoin`](_autosummary/aw.html.md#aw.djoin)(\*p)                                         | Join two or more pathname components, inserting '/' as needed.                                                                                |
| [`infer_loader_from_extension`](_autosummary/aw.html.md#aw.infer_loader_from_extension)(extension)             | Infer pandas loader function from file extension.                                                                                             |
| [`infer_loader_params`](_autosummary/aw.html.md#aw.infer_loader_params)(extension[, sample_text])      | Infer parameters for pandas loader based on file characteristics.                                                                             |
| [`compute_dataframe_info`](_autosummary/aw.html.md#aw.compute_dataframe_info)(df)                         | Compute comprehensive info about a DataFrame.                                                                                                 |
| [`get_numeric_columns`](_autosummary/aw.html.md#aw.get_numeric_columns)(df[, exclude_nulls])           | Get numeric columns from DataFrame.                                                                                                           |
| [`default_llm_factory`](_autosummary/aw.html.md#aw.default_llm_factory)([model])                       | Factory to create LLM function from various specifications.                                                                                   |
| [`create_openai_chat`](_autosummary/aw.html.md#aw.create_openai_chat)([model])                        | Create a text-to-text chat function using OpenAI API.                                                                                         |
| [`create_oa_chat`](_autosummary/aw.html.md#aw.create_oa_chat)()                                   | Create a chat function through [`aw.llm.default_chat()`](_autosummary/aw.llm.html.md#aw.llm.default_chat) (`aix`, else `oa`). |
| [`create_loading_agent`](_autosummary/aw.html.md#aw.create_loading_agent)([llm, validator, ...])        | Factory function to create a loading agent.                                                                                                   |
| [`create_preparation_agent`](_autosummary/aw.html.md#aw.create_preparation_agent)([target, ...])            | Factory function to create a preparation agent.                                                                                               |
| [`create_cosmo_validator`](_autosummary/aw.html.md#aw.create_cosmo_validator)([cosmo_function, ...])      | Create a validator for cosmograph requirements.                                                                                               |
| [`try_cosmo_visualization`](_autosummary/aw.html.md#aw.try_cosmo_visualization)(df[, cosmo_function])      | Try to create a cosmograph visualization.                                                                                                     |
| [`basic_cosmo_validator`](_autosummary/aw.html.md#aw.basic_cosmo_validator)()                            | Basic validator that checks structural requirements only.                                                                                     |
| [`strict_cosmo_validator`](_autosummary/aw.html.md#aw.strict_cosmo_validator)()                           | Strict validator that actually calls cosmograph.                                                                                              |
| [`infer_cosmo_params`](_autosummary/aw.html.md#aw.infer_cosmo_params)(df)                             | Infer suitable cosmograph parameters from DataFrame.                                                                                          |
| [`create_data_prep_workflow`](_autosummary/aw.html.md#aw.create_data_prep_workflow)([loading_config, ...])   | Factory to create a data preparation workflow.                                                                                                |
| [`create_cosmo_prep_workflow`](_autosummary/aw.html.md#aw.create_cosmo_prep_workflow)([...])                  | Create a workflow specifically for cosmograph preparation.                                                                                    |
| [`load_and_prepare`](_autosummary/aw.html.md#aw.load_and_prepare)(source_uri[, target, ...])        | Convenience function to load and prepare data in one call.                                                                                    |
| [`load_for_cosmo`](_autosummary/aw.html.md#aw.load_for_cosmo)(source_uri[, max_retries, strict])  | Load and prepare data specifically for cosmograph visualization.                                                                              |
| [`extract_agent_spec`](_autosummary/aw.html.md#aw.extract_agent_spec)(agent[, name])                  | Extract a normalized AgentSpec from any aw agent.                                                                                             |
| [`to_claude_skill`](_autosummary/aw.html.md#aw.to_claude_skill)(agent[, name, description, ...])   | Translate an aw agent to a Claude Code SKILL.md string.                                                                                       |
| [`claude_skill_from_spec`](_autosummary/aw.html.md#aw.claude_skill_from_spec)(spec, \*[, name, ...])      | Render a Claude Code SKILL.md string from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).                                      |
| [`write_skill_directory`](_autosummary/aw.html.md#aw.write_skill_directory)(agent, output_dir[, ...])    | Write a complete Claude Code skill directory.                                                                                                 |
| [`workflow_to_skills`](_autosummary/aw.html.md#aw.workflow_to_skills)(workflow, output_dir)           | Translate an AgenticWorkflow into a set of Claude Code skills.                                                                                |
| [`to_crewai_yaml`](_autosummary/aw.html.md#aw.to_crewai_yaml)(agent[, name, role, goal, ...])     | Translate an aw agent to a CrewAI agent YAML config dict.                                                                                     |
| [`crewai_yaml_from_spec`](_autosummary/aw.html.md#aw.crewai_yaml_from_spec)(spec, \*[, name, role, ...]) | Render a CrewAI agent config dict from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).                                         |
| [`workflow_to_crewai_yaml`](_autosummary/aw.html.md#aw.workflow_to_crewai_yaml)(workflow)                  | Translate an AgenticWorkflow to CrewAI agents.yaml + tasks.yaml.                                                                              |
| [`to_openai_tools`](_autosummary/aw.html.md#aw.to_openai_tools)(agent)                             | Translate an aw agent's tools to OpenAI function-calling tool schemas.                                                                        |
| [`openai_tools_from_spec`](_autosummary/aw.html.md#aw.openai_tools_from_spec)(spec)                       | Render OpenAI function-calling tool schemas from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).                               |
| [`to_openai_assistant`](_autosummary/aw.html.md#aw.to_openai_assistant)(agent[, name, model])          | Translate an aw agent to an OpenAI Assistant-style config dict.                                                                               |
| [`openai_assistant_from_spec`](_autosummary/aw.html.md#aw.openai_assistant_from_spec)(spec, \*[, name, ...])  | Render an OpenAI Assistant-style config dict from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).                              |

### Classes

| [`AgenticStep`](_autosummary/aw.html.md#aw.AgenticStep)(\*args, \*\*kwargs)                   | Protocol defining the interface for any agentic step in a workflow.   |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`Validator`](_autosummary/aw.html.md#aw.Validator)(\*args, \*\*kwargs)                     | Protocol for validation functions.                                    |
| [`Tool`](_autosummary/aw.html.md#aw.Tool)(\*args, \*\*kwargs)                          | Protocol for tools that agents can use.                               |
| [`StepConfig`](_autosummary/aw.html.md#aw.StepConfig)([llm, validator, tools, ...])          | Configuration for an AgenticStep.                                     |
| [`GlobalConfig`](_autosummary/aw.html.md#aw.GlobalConfig)([llm, max_retries, human_in_loop])   | Global configuration with cascading defaults.                         |
| [`Context`](_autosummary/aw.html.md#aw.Context)([initial_data])                           | Context for sharing state and artifacts between agentic steps.        |
| [`CodeInterpreterTool`](_autosummary/aw.html.md#aw.CodeInterpreterTool)([allowed_modules, ...])       | Tool for executing Python code in a controlled environment.           |
| [`SafeCodeInterpreter`](_autosummary/aw.html.md#aw.SafeCodeInterpreter)(\*\*kwargs)                   | Extra-safe code interpreter with restricted operations.               |
| [`ExecutionResult`](_autosummary/aw.html.md#aw.ExecutionResult)(success[, output, error, ...])    | Result of code execution.                                             |
| [`FileSamplerTool`](_autosummary/aw.html.md#aw.FileSamplerTool)([sample_size])                    | Tool to sample and analyze file metadata and content.                 |
| [`LoadingAgent`](_autosummary/aw.html.md#aw.LoadingAgent)([config])                            | Agent that loads data from various sources into pandas DataFrames.    |
| [`PreparationAgent`](_autosummary/aw.html.md#aw.PreparationAgent)([config, target, ...])           | Agent that prepares data to meet target requirements.                 |
| [`AgenticWorkflow`](_autosummary/aw.html.md#aw.AgenticWorkflow)([context])                        | Orchestrates a chain of agentic steps.                                |
| [`InteractiveWorkflow`](_autosummary/aw.html.md#aw.InteractiveWorkflow)([context])                    | Workflow with human-in-the-loop capabilities.                         |
| [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec)(name[, description, instructions, ...]) | Normalized, format-agnostic description of an aw agent.               |
| [`ToolSpec`](_autosummary/aw.html.md#aw.ToolSpec)(name[, description, parameters, source]) | Normalized description of a tool.                                     |
| [`ValidatorSpec`](_autosummary/aw.html.md#aw.ValidatorSpec)(name[, description, checks])        | Normalized description of a validator.                                |

### *class* aw.AgentSpec(name, description='', instructions='', tools=list(), validators=list(), model='', max_retries=3, human_in_loop=False, source_class='', extra=dict())

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

Normalized, format-agnostic description of an aw agent.

This is the intermediate representation that all translators consume.
It captures the essential components of an agent without being tied
to any specific framework.

### Example

```pycon
>>> from aw import LoadingAgent
>>> spec = extract_agent_spec(LoadingAgent())
>>> spec.name
'LoadingAgent'
```

### *class* aw.AgenticStep(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)[`ArtifactType`]

Protocol defining the interface for any agentic step in a workflow.

Each step follows the ReAct pattern:

1. Reason (Thought): Analyze input and context
2. Act (Action): Generate and execute code or use tools
3. Observe: Capture results and validate
4. Repeat or finish based on validation

### Example

```pycon
>>> class MyAgent:
...     def execute(self, input_data, context):
...         # Agent implementation
...         return result, metadata
```

#### execute(input_data, context)

Execute the agentic step.

* **Parameters:**
  * **input_data** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – The input to process
  * **context** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Mutable mapping containing shared state and history
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[`ArtifactType`, [`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)]]
* **Returns:**
  Tuple of (artifact, metadata) where artifact is the main output
  and metadata contains auxiliary information

### *class* aw.AgenticWorkflow(context=None)

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

Orchestrates a chain of agentic steps.

Manages the execution of multiple steps in sequence, handling
context/artifact passing between steps.

### Example

```pycon
>>> workflow = AgenticWorkflow()
>>> workflow.add_step('loading', loading_agent)
>>> workflow.add_step('preparing', preparing_agent)
>>> result = workflow.run(source_uri)
```

#### add_step(name, step)

Add a step to the workflow.

* **Parameters:**
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name/identifier for the step
  * **step** ([`AgenticStep`](_autosummary/aw.base.html.md#aw.base.AgenticStep)) – Agent or step implementation
* **Return type:**
  [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)
* **Returns:**
  Self for chaining

#### run(initial_input)

Execute the workflow.

* **Parameters:**
  **initial_input** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Input to the first step
* **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)]]
* **Returns:**
  Tuple of (final_artifact, workflow_metadata)

#### run_partial(initial_input, stop_after=None)

Run workflow up to a specific step.

* **Parameters:**
  * **initial_input** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Input to first step
  * **stop_after** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name of step to stop after (runs all if None)
* **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)]]
* **Returns:**
  Tuple of (artifact, metadata)

### *class* aw.CodeInterpreterTool(allowed_modules=None, global_context=None, executor=None)

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

Tool for executing Python code in a controlled environment.

Provides a safe default implementation using exec() with limited namespace,
and allows injection of more robust backends.

### Example

```pycon
>>> tool = CodeInterpreterTool()
>>> result = tool("x = 5; y = x * 2; print(y)")
>>> result.success
True
>>> result.output.strip()
'10'
```

### *class* aw.Context(initial_data=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), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

Context for sharing state and artifacts between agentic steps.

Implements MutableMapping interface for dict-like behavior while
providing additional functionality for managing agent state.

### Example

```pycon
>>> ctx = Context()
>>> ctx['loading'] = {'df': df, 'info': {...}}
>>> ctx['preparing'] = {'df': prepared_df}
```

#### *property* history *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]]*

Access the history of all context updates.

#### snapshot()

Create a snapshot of current context state.

* **Return type:**
  [`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)]
* **Returns:**
  A dict copy of current context data

### *class* aw.ExecutionResult(success, output='', error='', traceback_str='', result=None, locals_dict=None)

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

Result of code execution.

#### success

Whether execution succeeded without exceptions

#### output

Standard output captured during execution

#### error

Error message if execution failed

#### traceback

Full traceback if execution failed

#### result

The return value or final expression value

#### locals

Local variables after execution

### *class* aw.FileSamplerTool(sample_size=1024)

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

Tool to sample and analyze file metadata and content.

Helps agents understand what kind of data they’re dealing with
before attempting to load it.

### Example

```pycon
>>> sampler = FileSamplerTool()
>>> info = sampler('/path/to/data.csv')
>>> info['extension']
'.csv'
```

### *class* aw.GlobalConfig(llm='gpt-4', max_retries=3, human_in_loop=False)

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

Global configuration with cascading defaults.

Provides defaults that can be overridden at step or agent level.

### Example

```pycon
>>> global_cfg = GlobalConfig(llm="gpt-4", max_retries=5)
>>> step_cfg = global_cfg.override(llm="gpt-3.5-turbo")
```

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

Create a StepConfig with overridden values.

* **Parameters:**
  **\*\*kwargs** – Values to override from global defaults
* **Return type:**
  [`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)
* **Returns:**
  A new StepConfig with merged configuration

### *class* aw.InteractiveWorkflow(context=None)

Bases: [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)

Workflow with human-in-the-loop capabilities.

Pauses execution to request human input/approval at configured points.

### Example

```pycon
>>> workflow = InteractiveWorkflow()
>>> workflow.add_step('loading', agent, require_approval=True)
>>> result = workflow.run_interactive(source_uri)
```

#### add_step(name, step, require_approval=False)

Add step with optional approval requirement.

* **Return type:**
  [`InteractiveWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.InteractiveWorkflow)

#### run_interactive(initial_input)

Run workflow with human-in-loop checkpoints.

* **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)]

#### set_approval_callback(callback)

Set callback for human approval.

* **Parameters:**
  **callback** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Function(step_name, artifact, metadata) -> bool
  Returns True to continue, False to abort
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* aw.LoadingAgent(config=None)

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

Agent that loads data from various sources into pandas DataFrames.

Uses ReAct loop:

1. Thought: Analyze source (extension, sample) to choose loader
2. Action: Generate code to load data
3. Observe: Execute code and capture result/error
4. Validate: Check if result is valid DataFrame
5. Repeat or finish

### Example

```pycon
>>> agent = LoadingAgent()
>>> context = Context()
>>> df, metadata = agent.execute('/path/to/data.csv', context)
```

#### execute(source_uri, context)

Execute loading agent to load data from source.

* **Parameters:**
  * **source_uri** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – URI of data source (file path or URL)
  * **context** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Context for storing intermediate results
* **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)]]
* **Returns:**
  Tuple of (dataframe, metadata)

### *class* aw.PreparationAgent(config=None, target='generic', target_validator=None)

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

Agent that prepares data to meet target requirements.

Uses ReAct loop with functional validation:

1. Thought: Analyze current data state vs. requirements
2. Action: Generate transformation code
3. Observe: Execute code and capture result
4. Validate: Try to use data for its purpose (e.g., visualization)
5. Repeat or finish

### Example

```pycon
>>> agent = PreparationAgent(target='cosmo-ready')
>>> context = Context({'loading': {'df': df}})
>>> prepared_df, metadata = agent.execute(df, context)
```

#### execute(input_df, context)

Execute preparation agent to transform data.

* **Parameters:**
  * **input_df** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Input DataFrame to prepare
  * **context** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Context for storing intermediate results
* **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)]]
* **Returns:**
  Tuple of (prepared_dataframe, metadata)

### *class* aw.SafeCodeInterpreter(\*\*kwargs)

Bases: [`CodeInterpreterTool`](_autosummary/aw.tools.html.md#aw.tools.CodeInterpreterTool)

Extra-safe code interpreter with restricted operations.

Disallows file I/O, network access, and other potentially dangerous operations.

### *class* aw.StepConfig(llm='gpt-4', validator=None, tools=list(), max_retries=3, human_in_loop=False)

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

Configuration for an AgenticStep.

Supports both simple objects (strings, ints) and callables for maximum
flexibility with dependency injection.

#### llm

Either a model name string or a text-to-text chat function

* **Type:**
  [`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`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)]]

#### validator

Validation callable or schema object

* **Type:**
  [`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### tools

List of callable tools available to the agent

* **Type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]

#### max_retries

Maximum number of retry attempts

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### human_in_loop

Whether to require human approval/intervention

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

### Example

```pycon
>>> config = StepConfig(
...     llm="gpt-4",
...     validator=lambda x: (True, {}),
...     max_retries=3
... )
```

#### resolve_llm()

Resolve llm to a callable function.

* **Return type:**
  [`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)]
* **Returns:**
  A callable that takes a prompt string and returns a response string

#### resolve_validator()

Resolve validator to a callable.

* **Return type:**
  [`Validator`](_autosummary/aw.base.html.md#aw.base.Validator)
* **Returns:**
  A callable that validates artifacts

### *class* aw.Tool(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Protocol for tools that agents can use.

Tools are callable objects that perform specific actions like
executing code, sampling files, or calling external APIs.

### Example

```pycon
>>> class FileSampler:
...     def __call__(self, uri):
...         # Sample file logic
...         return {'extension': '.csv', 'sample': '...'}
```

### *class* aw.ToolSpec(name, description='', parameters=dict(), source='')

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

Normalized description of a tool.

### *class* aw.Validator(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Protocol for validation functions.

Validators check if an artifact meets requirements and return
both a success indicator and detailed information.

### Example

```pycon
>>> def is_non_empty_dataframe(df):
...     success = df is not None and len(df) > 0
...     info = {'shape': df.shape if success else None}
...     return success, info
```

### *class* aw.ValidatorSpec(name, description='', checks=list())

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

Normalized description of a validator.

### aw.all_validators(\*validators)

Combine multiple validators - all must pass.

* **Parameters:**
  **\*validators** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Validator functions to combine
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator that passes only if all validators pass

### Example

```pycon
>>> validate = all_validators(
...     is_dataframe,
...     has_required_columns(['x', 'y']),
...     has_no_nulls
... )
```

### aw.any_validator(\*validators)

Combine multiple validators - at least one must pass.

* **Parameters:**
  **\*validators** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Validator functions to combine
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator that passes if any validator passes

### aw.basic_cosmo_validator()

Basic validator that checks structural requirements only.

Does not require cosmograph to be installed.

### Example

```pycon
>>> validator = basic_cosmo_validator()
>>> success, info = validator(df)
```

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

### aw.claude_skill_from_spec(spec, , name=None, description=None, extra_tools=None, disable_model_invocation=False)

Render a Claude Code SKILL.md string from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).

The rendering core of [`to_claude_skill()`](_autosummary/aw.html.md#aw.to_claude_skill) — driveable by any `AgentSpec`
(not only a live aw agent), so other tools (e.g. `coact`) can reuse it.

### Example

```pycon
>>> from aw import LoadingAgent
>>> from aw.translators import extract_agent_spec, claude_skill_from_spec
>>> spec = extract_agent_spec(LoadingAgent(), name='data-loading')
>>> '---' in claude_skill_from_spec(spec)
True
```

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

### aw.compute_dataframe_info(df)

Compute comprehensive info about a DataFrame.

* **Parameters:**
  **df** – pandas DataFrame
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with shape, dtypes, null counts, sample rows, etc.

### Example

```pycon
>>> import pandas as pd
>>> df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
>>> info = compute_dataframe_info(df)
>>> info['shape']
(2, 2)
```

### aw.create_cosmo_prep_workflow(cosmo_validator=None, max_retries=3)

Create a workflow specifically for cosmograph preparation.

* **Parameters:**
  * **cosmo_validator** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Custom cosmo validator (uses default if None)
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retries for each step
* **Return type:**
  [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)
* **Returns:**
  Configured workflow

### Example

```pycon
>>> workflow = create_cosmo_prep_workflow()
>>> prepared_df, metadata = workflow.run('data.csv')
```

### aw.create_cosmo_validator(cosmo_function=None, required_columns=2, allow_generated_params=True)

Create a validator for cosmograph requirements.

This validator attempts to actually call cosmograph.cosmo() with the
DataFrame to see if it’s ready for visualization.

* **Parameters:**
  * **cosmo_function** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – The cosmograph.cosmo function (imported if None)
  * **required_columns** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Minimum number of numeric columns needed
  * **allow_generated_params** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to auto-infer x/y columns
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  Validator function following (artifact) -> (success, info) protocol

### Example

```pycon
>>> validator = create_cosmo_validator()
>>> success, info = validator(df)
>>> if success:
...     print(f"Can visualize with: {info['params']}")
```

### aw.create_data_prep_workflow(loading_config=None, preparing_config=None, target='generic')

Factory to create a data preparation workflow.

Creates a workflow with LoadingAgent -> PreparationAgent.

* **Parameters:**
  * **loading_config** ([`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)) – Configuration for loading agent
  * **preparing_config** ([`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)) – Configuration for preparing agent
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target format for preparation
* **Return type:**
  [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)
* **Returns:**
  Configured workflow

### Example

```pycon
>>> workflow = create_data_prep_workflow(target='cosmo-ready')
>>> df, metadata = workflow.run('/path/to/data.csv')
```

### aw.create_langchain_executor()

Create an executor using LangChain’s CodeInterpreter (if available).

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`ExecutionResult`](_autosummary/aw.tools.html.md#aw.tools.ExecutionResult)]
* **Returns:**
  Executor function compatible with CodeInterpreterTool

### Example

```pycon
>>> try:
...     executor = create_langchain_executor()
...     tool = CodeInterpreterTool(executor=executor)
... except ImportError:
...     # LangChain not available - use default
...     tool = CodeInterpreterTool()
```

### aw.create_loading_agent(llm=None, validator=None, max_retries=3)

Factory function to create a loading agent.

* **Parameters:**
  * **llm** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – LLM model name or callable
  * **validator** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Custom validator (uses default if None)
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
* **Return type:**
  [`LoadingAgent`](_autosummary/aw.loading.html.md#aw.loading.LoadingAgent)
* **Returns:**
  Configured LoadingAgent

### Example

```pycon
>>> agent = create_loading_agent(llm="gpt-4", max_retries=5)
```

### aw.create_oa_chat()

Create a chat function through [`aw.llm.default_chat()`](_autosummary/aw.llm.html.md#aw.llm.default_chat) (`aix`, else `oa`).

The name is kept for compatibility; generation is routed through `aix`.

* **Return type:**
  [`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)]
* **Returns:**
  A callable that takes a prompt and returns a response

### Example

```pycon
>>> chat = create_oa_chat()
>>> response = chat("Hello!")
```

### aw.create_openai_chat(model='gpt-4', \*\*default_kwargs)

Create a text-to-text chat function using OpenAI API.

* **Parameters:**
  * **model** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – OpenAI model name
  * **\*\*default_kwargs** – Default parameters for API calls
* **Return type:**
  [`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)]
* **Returns:**
  A callable that takes a prompt and returns a response

### Example

```pycon
>>> chat = create_openai_chat("gpt-4o-mini")
>>> response = chat("What is 2+2?")
```

(Skipped: the call is billable and needs `OPENAI_API_KEY`.)

### aw.create_preparation_agent(target='generic', validator=None, llm=None, max_retries=3)

Factory function to create a preparation agent.

* **Parameters:**
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target format/purpose
  * **validator** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Custom validator function
  * **llm** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – LLM model name or callable
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
* **Return type:**
  [`PreparationAgent`](_autosummary/aw.preparing.html.md#aw.preparing.PreparationAgent)
* **Returns:**
  Configured PreparationAgent

### Example

```pycon
>>> agent = create_preparation_agent(
...     target='cosmo-ready',
...     validator=cosmo_validator,
...     max_retries=5
... )
```

### aw.crewai_yaml_from_spec(spec, , name=None, role=None, goal=None, backstory=None)

Render a CrewAI agent config dict from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).

The rendering core of [`to_crewai_yaml()`](_autosummary/aw.html.md#aw.to_crewai_yaml), driveable by any `AgentSpec`.

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

### aw.default_llm_factory(model='gpt-4')

Factory to create LLM function from various specifications.

* **Parameters:**
  **model** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]) – Either a model name string, or a callable
* **Return type:**
  [`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)]
* **Returns:**
  A callable text-to-text function

### Example

```pycon
>>> llm = default_llm_factory("gpt-4")
>>> llm = default_llm_factory(lambda p: f"Echo: {p}")
```

### aw.djoin(\*p)

Join two or more pathname components, inserting ‘/’ as needed.
If any component is an absolute path, all previous path components
will be discarded.  An empty last part will result in a path that
ends with a separator.

### aw.extract_agent_spec(agent, name=None)

Extract a normalized AgentSpec from any aw agent.

Introspects the agent’s class, config, tools, and validators
to build a format-agnostic intermediate representation.

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance (LoadingAgent, PreparationAgent, etc.)
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override name (defaults to class name)
* **Return type:**
  [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec)
* **Returns:**
  AgentSpec with all extractable information

### Example

```pycon
>>> from aw import LoadingAgent
>>> spec = extract_agent_spec(LoadingAgent())
>>> spec.name
'LoadingAgent'
>>> len(spec.tools) >= 1
True
```

### aw.functional_validator(try_function, success_check=None)

Create a validator that tries to use the artifact for its purpose.

This validator actually attempts to use the artifact in the way it’s
intended to be used (e.g., try to visualize the data, try to train a model).

* **Parameters:**
  * **try_function** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Function that tries to use the artifact
  * **success_check** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Optional function to check if result is acceptable
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator function

### Example

```pycon
>>> def try_cosmo(df):
...     return cosmograph.cosmo(df, points_x_by='x', points_y_by='y')
>>> validate = functional_validator(try_cosmo)
>>> validate(df)
```

### aw.get_numeric_columns(df, exclude_nulls=True)

Get numeric columns from DataFrame.

* **Parameters:**
  * **df** – pandas DataFrame
  * **exclude_nulls** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to exclude columns with null values
* **Returns:**
  Generator of column names

### Example

```pycon
>>> for col in get_numeric_columns(df):
...     print(col)
```

### aw.has_attributes(\*\*required_attrs)

Validator that checks artifact has required attributes.

### Example

```pycon
>>> validate = has_attributes(shape=lambda s: len(s) == 2, columns=lambda c: len(c) > 0)
```

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

### aw.infer_cosmo_params(df)

Infer suitable cosmograph parameters from DataFrame.

* **Parameters:**
  **df** – pandas DataFrame
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict of suggested parameters for cosmograph.cosmo()

### Example

```pycon
>>> params = infer_cosmo_params(df)
>>> from cosmograph import cosmo
>>> cosmo(df, **params)
```

### aw.infer_loader_from_extension(extension)

Infer pandas loader function from file extension.

* **Parameters:**
  **extension** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – File extension (e.g., ‘.csv’, ‘.json’)
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Returns:**
  Name of pandas loader function

### Example

```pycon
>>> infer_loader_from_extension('.csv')
'read_csv'
>>> infer_loader_from_extension('.xlsx')
'read_excel'
```

### aw.infer_loader_params(extension, sample_text=None)

Infer parameters for pandas loader based on file characteristics.

* **Parameters:**
  * **extension** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – File extension
  * **sample_text** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Optional sample of file content
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict of parameters to pass to loader

### Example

```pycon
>>> params = infer_loader_params('.csv', 'a,b,c\n1,2,3')
>>> params.get('sep')
','
```

### aw.info_dict_validator(compute_info, check_info)

Create a validator that computes info then checks it.

This is a two-stage validator:

1. Compute information about the artifact (e.g., df.shape, df.dtypes)
2. Check if that information meets requirements

* **Parameters:**
  * **compute_info** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]) – Function to extract info from artifact
  * **check_info** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]) – Function to check if info is acceptable
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator function

### Example

```pycon
>>> def compute_df_info(df):
...     return {'shape': df.shape, 'null_count': df.isnull().sum().sum()}
>>> def check_df_info(info):
...     if info['null_count'] > 10:
...         return False, "Too many nulls"
...     return True, "OK"
>>> validate = info_dict_validator(compute_df_info, check_df_info)
```

### aw.is_not_empty()

Validator that checks artifact is not empty.

Works for sequences, mappings, DataFrames, etc.

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

### aw.is_type(expected_type)

Validator that checks artifact type.

### Example

```pycon
>>> import pandas as pd
>>> validate = is_type(pd.DataFrame)
```

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

### aw.load_and_prepare(source_uri, target='generic', validator=None, max_retries=3)

Convenience function to load and prepare data in one call.

* **Parameters:**
  * **source_uri** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – URI of data source
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target format/purpose
  * **validator** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Optional custom validator
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
* **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)]
* **Returns:**
  Tuple of (prepared_dataframe, metadata)

### Example

```pycon
>>> df, meta = load_and_prepare('data.csv', target='cosmo-ready')
```

### aw.load_for_cosmo(source_uri, max_retries=3, strict=False)

Load and prepare data specifically for cosmograph visualization.

* **Parameters:**
  * **source_uri** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – URI of data source
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
  * **strict** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, actually calls cosmograph for validation
* **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)]
* **Returns:**
  Tuple of (prepared_dataframe, metadata)

### Example

```pycon
>>> df, meta = load_for_cosmo('data.csv')
>>> from cosmograph import cosmo
>>> cosmo(df, **meta['preparing']['metadata']['validation_result']['params'])
```

### aw.openai_assistant_from_spec(spec, , name=None, model='gpt-4')

Render an OpenAI Assistant-style config dict from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).

The rendering core of [`to_openai_assistant()`](_autosummary/aw.html.md#aw.to_openai_assistant), driveable by any `AgentSpec`.

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

### aw.openai_tools_from_spec(spec)

Render OpenAI function-calling tool schemas from an [`AgentSpec`](_autosummary/aw.html.md#aw.AgentSpec).

The rendering core of [`to_openai_tools()`](_autosummary/aw.html.md#aw.to_openai_tools), driveable by any `AgentSpec`.

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

### aw.schema_validator(schema)

Create a validator from a schema (Pydantic, JSON Schema, etc.).

* **Parameters:**
  **schema** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – A schema object with validation capability
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator function

### Example

```pycon
>>> from pydantic import BaseModel
>>> class DataSchema(BaseModel):
...     x: float
...     y: float
>>> validate = schema_validator(DataSchema)
>>> validate({'x': 1.0, 'y': 2.0})
(True, {'validated': ...})
```

### aw.strict_cosmo_validator()

Strict validator that actually calls cosmograph.

Requires cosmograph to be installed.

### Example

```pycon
>>> validator = strict_cosmo_validator()
>>> success, info = validator(df)
```

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

### aw.to_claude_skill(agent, name=None, description=None, extra_tools=None, disable_model_invocation=False)

Translate an aw agent to a Claude Code SKILL.md string.

Generates a complete SKILL.md file with YAML frontmatter and
markdown instructions, compatible with both Claude Code skills
and the Agent Skills Open Standard (agentskills.io).

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override skill name (defaults to kebab-case of class name)
  * **description** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override description
  * **extra_tools** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – Additional Claude Code tools to allow
  * **disable_model_invocation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, skill is manual-only (/name)
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Returns:**
  Complete SKILL.md content as a string

### Example

```pycon
>>> from aw import LoadingAgent
>>> skill = to_claude_skill(LoadingAgent(), name='data-loading')
>>> '---' in skill
True
>>> 'data-loading' in skill
True
```

### aw.to_crewai_yaml(agent, name=None, role=None, goal=None, backstory=None)

Translate an aw agent to a CrewAI agent YAML config dict.

CrewAI agents are defined with role, goal, backstory, and tools.
This function maps aw’s AgentSpec to that structure.

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override agent name
  * **role** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override role (defaults to agent description)
  * **goal** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override goal
  * **backstory** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override backstory
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict suitable for YAML serialization as a CrewAI agent config

### Example

```pycon
>>> from aw import LoadingAgent
>>> config = to_crewai_yaml(LoadingAgent(), name='data_loader')
>>> config['role']
'Data Loading Specialist'
```

### aw.to_openai_assistant(agent, name=None, model='gpt-4')

Translate an aw agent to an OpenAI Assistant-style config dict.

Generates a configuration suitable for creating an OpenAI Assistant
(or Responses API agent) via the API.

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override name
  * **model** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override model
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with assistant configuration

### Example

```pycon
>>> from aw import LoadingAgent
>>> config = to_openai_assistant(LoadingAgent())
>>> 'instructions' in config
True
```

### aw.to_openai_tools(agent)

Translate an aw agent’s tools to OpenAI function-calling tool schemas.

Generates JSON-Schema-based tool definitions compatible with the
OpenAI Chat Completions API and Responses API.

* **Parameters:**
  **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)
* **Returns:**
  List of tool definition dicts in OpenAI format

### Example

```pycon
>>> from aw import LoadingAgent
>>> tools = to_openai_tools(LoadingAgent())
>>> all(t['type'] == 'function' for t in tools)
True
```

### aw.try_cosmo_visualization(df, cosmo_function=None, \*\*cosmo_kwargs)

Try to create a cosmograph visualization.

This is a functional validator that actually attempts the visualization.

* **Parameters:**
  * **df** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – DataFrame to visualize
  * **cosmo_function** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – The cosmograph.cosmo function
  * **\*\*cosmo_kwargs** – Additional arguments for cosmo
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]
* **Returns:**
  Tuple of (success, info)

### Example

```pycon
>>> from cosmograph import cosmo
>>> success, info = try_cosmo_visualization(df, cosmo)
```

### aw.workflow_to_crewai_yaml(workflow)

Translate an AgenticWorkflow to CrewAI agents.yaml + tasks.yaml.

* **Parameters:**
  **workflow** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An AgenticWorkflow instance
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with ‘agents’ and ‘tasks’ keys, each containing
  YAML-serializable config dicts

### Example

```pycon
>>> from aw import create_cosmo_prep_workflow
>>> workflow = create_cosmo_prep_workflow()
>>> config = workflow_to_crewai_yaml(workflow)
>>> 'agents' in config and 'tasks' in config
True
```

### aw.workflow_to_skills(workflow, output_dir)

Translate an AgenticWorkflow into a set of Claude Code skills.

Each step in the workflow becomes a separate skill directory.

* **Parameters:**
  * **workflow** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An AgenticWorkflow instance
  * **output_dir** ([`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)]) – Parent directory for all skill directories
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)
* **Returns:**
  List of Paths to created skill directories

### Example

```pycon
>>> from aw import create_cosmo_prep_workflow
>>> workflow = create_cosmo_prep_workflow()
>>> paths = workflow_to_skills(workflow, '/tmp/skills')
```

### aw.write_skill_directory(agent, output_dir, name=None, description=None, include_scripts=True)

Write a complete Claude Code skill directory.

Creates:

```default
output_dir/
├── SKILL.md
└── scripts/          (if include_scripts and agent has tools)
    └── validate.py   (validator wrapper script)
```

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **output_dir** ([`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)]) – Directory to write the skill to
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override skill name
  * **description** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override description
  * **include_scripts** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to generate helper scripts
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created directory

### Example

```pycon
>>> from aw import LoadingAgent
>>> path = write_skill_directory(
...     LoadingAgent(), '/tmp/test-skill', name='data-loading'
... )
```

### Modules

| [`base`](_autosummary/aw.base.html.md#module-aw.base)                   | Core protocols and base classes for agentic workflows.                                                                                                                   |
|----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`cosmo`](_autosummary/aw.cosmo.html.md#module-aw.cosmo)                 | Cosmograph-specific validator tool.                                                                                                                                      |
| [`dispatch`](_autosummary/aw.dispatch.html.md#module-aw.dispatch)           | Cheap-first dispatch to a skill: calibrated retrieval first, an LLM adjudicator only on ambiguity.                                                                       |
| [`func_calling`](_autosummary/aw.func_calling.html.md#module-aw.func_calling)   | This module provides robust templates for creating (python) code-generating functions that can translate natural language task descriptions into executable Python code. |
| [`llm`](_autosummary/aw.llm.html.md#module-aw.llm)                     | The one place aw reaches a language model: `aix` first, `oa` only as a fallback.                                                                                         |
| [`loading`](_autosummary/aw.loading.html.md#module-aw.loading)             | Loading agent for converting data sources to pandas DataFrames.                                                                                                          |
| [`orchestration`](_autosummary/aw.orchestration.html.md#module-aw.orchestration) | Orchestration and workflow management for agentic steps.                                                                                                                 |
| [`preparing`](_autosummary/aw.preparing.html.md#module-aw.preparing)         | Preparation agent for transforming data to meet target requirements.                                                                                                     |
| [`py_gen`](_autosummary/aw.py_gen.html.md#module-aw.py_gen)               | Function makeing and calling                                                                                                                                             |
| [`routing`](_autosummary/aw.routing.html.md#module-aw.routing)             | Configurable routing and decision chains for agentic workflows.                                                                                                          |
| [`tools`](_autosummary/aw.tools.html.md#module-aw.tools)                 | Tools for executing code and other agent actions.                                                                                                                        |
| [`translators`](_autosummary/aw.translators.html.md#module-aw.translators)     | Translators from aw agent specifications to other agent formats.                                                                                                         |
| [`util`](_autosummary/aw.util.html.md#module-aw.util)                   | Utility tools and helper functions for agents.                                                                                                                           |
| [`validation`](_autosummary/aw.validation.html.md#module-aw.validation)       | Validation system supporting three flavors: schema, info-dict, and functional.                                                                                           |


# _autosummary/aw.llm.html.md

# aw.llm

The one place aw reaches a language model: `aix` first, `oa` only as a fallback.

Generation is routed through `aix` (the fleet’s LLM facade). `oa` stays an optional
extra (the `llm` extra) and is used only when `aix` cannot be imported, so an
install that has only `oa` keeps working.

```pycon
>>> callable(default_chat())
True
```

### Functions

| [`default_chat`](_autosummary/aw.llm.html.md#aw.llm.default_chat)()                | `chat(prompt, **kwargs) -> str`: `aix.chat`, else `oa.chat`.                                         |
|--------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| [`default_json_function_maker`](_autosummary/aw.llm.html.md#aw.llm.default_json_function_maker)() | `maker(template, *, json_schema) -> function`: `aix.prompt_to_json`, else `oa.prompt_json_function`. |

### aw.llm.default_chat()

`chat(prompt, **kwargs) -> str`: `aix.chat`, else `oa.chat`.

Raises `ImportError` when neither is installed.

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

### aw.llm.default_json_function_maker()

`maker(template, *, json_schema) -> function`: `aix.prompt_to_json`, else `oa.prompt_json_function`.

Raises `ImportError` when neither is installed.

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


# _autosummary/aw.loading.html.md

# aw.loading

Loading agent for converting data sources to pandas DataFrames.

Implements the ReAct pattern to iteratively try different loading strategies
until successful or max retries reached.

### Functions

| [`create_loading_agent`](_autosummary/aw.loading.html.md#aw.loading.create_loading_agent)([llm, validator, ...])   | Factory function to create a loading agent.   |
|------------------------------------------------------------------------------------------------|-----------------------------------------------|

### Classes

| [`LoadingAgent`](_autosummary/aw.loading.html.md#aw.loading.LoadingAgent)([config])   | Agent that loads data from various sources into pandas DataFrames.   |
|---------------------------------------------------------------------------|----------------------------------------------------------------------|

### *class* aw.loading.LoadingAgent(config=None)

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

Agent that loads data from various sources into pandas DataFrames.

Uses ReAct loop:

1. Thought: Analyze source (extension, sample) to choose loader
2. Action: Generate code to load data
3. Observe: Execute code and capture result/error
4. Validate: Check if result is valid DataFrame
5. Repeat or finish

### Example

```pycon
>>> agent = LoadingAgent()
>>> context = Context()
>>> df, metadata = agent.execute('/path/to/data.csv', context)
```

#### execute(source_uri, context)

Execute loading agent to load data from source.

* **Parameters:**
  * **source_uri** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – URI of data source (file path or URL)
  * **context** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Context for storing intermediate results
* **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)]]
* **Returns:**
  Tuple of (dataframe, metadata)

### aw.loading.create_loading_agent(llm=None, validator=None, max_retries=3)

Factory function to create a loading agent.

* **Parameters:**
  * **llm** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – LLM model name or callable
  * **validator** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Custom validator (uses default if None)
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
* **Return type:**
  [`LoadingAgent`](_autosummary/aw.loading.html.md#aw.loading.LoadingAgent)
* **Returns:**
  Configured LoadingAgent

### Example

```pycon
>>> agent = create_loading_agent(llm="gpt-4", max_retries=5)
```


# _autosummary/aw.orchestration.html.md

# aw.orchestration

Orchestration and workflow management for agentic steps.

Provides utilities to chain multiple agentic steps together and manage
the overall workflow.

### Functions

| [`create_cosmo_prep_workflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.create_cosmo_prep_workflow)([...])                 | Create a workflow specifically for cosmograph preparation.       |
|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| [`create_data_prep_workflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.create_data_prep_workflow)([loading_config, ...])  | Factory to create a data preparation workflow.                   |
| [`load_and_prepare`](_autosummary/aw.orchestration.html.md#aw.orchestration.load_and_prepare)(source_uri[, target, ...])       | Convenience function to load and prepare data in one call.       |
| [`load_for_cosmo`](_autosummary/aw.orchestration.html.md#aw.orchestration.load_for_cosmo)(source_uri[, max_retries, strict]) | Load and prepare data specifically for cosmograph visualization. |

### Classes

| [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)([context])     | Orchestrates a chain of agentic steps.        |
|---------------------------------------------------------------------------------|-----------------------------------------------|
| [`InteractiveWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.InteractiveWorkflow)([context]) | Workflow with human-in-the-loop capabilities. |

### *class* aw.orchestration.AgenticWorkflow(context=None)

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

Orchestrates a chain of agentic steps.

Manages the execution of multiple steps in sequence, handling
context/artifact passing between steps.

### Example

```pycon
>>> workflow = AgenticWorkflow()
>>> workflow.add_step('loading', loading_agent)
>>> workflow.add_step('preparing', preparing_agent)
>>> result = workflow.run(source_uri)
```

#### add_step(name, step)

Add a step to the workflow.

* **Parameters:**
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name/identifier for the step
  * **step** ([`AgenticStep`](_autosummary/aw.base.html.md#aw.base.AgenticStep)) – Agent or step implementation
* **Return type:**
  [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)
* **Returns:**
  Self for chaining

#### run(initial_input)

Execute the workflow.

* **Parameters:**
  **initial_input** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Input to the first step
* **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)]]
* **Returns:**
  Tuple of (final_artifact, workflow_metadata)

#### run_partial(initial_input, stop_after=None)

Run workflow up to a specific step.

* **Parameters:**
  * **initial_input** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Input to first step
  * **stop_after** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name of step to stop after (runs all if None)
* **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)]]
* **Returns:**
  Tuple of (artifact, metadata)

### *class* aw.orchestration.InteractiveWorkflow(context=None)

Bases: [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)

Workflow with human-in-the-loop capabilities.

Pauses execution to request human input/approval at configured points.

### Example

```pycon
>>> workflow = InteractiveWorkflow()
>>> workflow.add_step('loading', agent, require_approval=True)
>>> result = workflow.run_interactive(source_uri)
```

#### add_step(name, step, require_approval=False)

Add step with optional approval requirement.

* **Return type:**
  [`InteractiveWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.InteractiveWorkflow)

#### run_interactive(initial_input)

Run workflow with human-in-loop checkpoints.

* **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)]

#### set_approval_callback(callback)

Set callback for human approval.

* **Parameters:**
  **callback** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Function(step_name, artifact, metadata) -> bool
  Returns True to continue, False to abort
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### aw.orchestration.create_cosmo_prep_workflow(cosmo_validator=None, max_retries=3)

Create a workflow specifically for cosmograph preparation.

* **Parameters:**
  * **cosmo_validator** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Custom cosmo validator (uses default if None)
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retries for each step
* **Return type:**
  [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)
* **Returns:**
  Configured workflow

### Example

```pycon
>>> workflow = create_cosmo_prep_workflow()
>>> prepared_df, metadata = workflow.run('data.csv')
```

### aw.orchestration.create_data_prep_workflow(loading_config=None, preparing_config=None, target='generic')

Factory to create a data preparation workflow.

Creates a workflow with LoadingAgent -> PreparationAgent.

* **Parameters:**
  * **loading_config** ([`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)) – Configuration for loading agent
  * **preparing_config** ([`StepConfig`](_autosummary/aw.base.html.md#aw.base.StepConfig)) – Configuration for preparing agent
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target format for preparation
* **Return type:**
  [`AgenticWorkflow`](_autosummary/aw.orchestration.html.md#aw.orchestration.AgenticWorkflow)
* **Returns:**
  Configured workflow

### Example

```pycon
>>> workflow = create_data_prep_workflow(target='cosmo-ready')
>>> df, metadata = workflow.run('/path/to/data.csv')
```

### aw.orchestration.load_and_prepare(source_uri, target='generic', validator=None, max_retries=3)

Convenience function to load and prepare data in one call.

* **Parameters:**
  * **source_uri** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – URI of data source
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target format/purpose
  * **validator** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Optional custom validator
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
* **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)]
* **Returns:**
  Tuple of (prepared_dataframe, metadata)

### Example

```pycon
>>> df, meta = load_and_prepare('data.csv', target='cosmo-ready')
```

### aw.orchestration.load_for_cosmo(source_uri, max_retries=3, strict=False)

Load and prepare data specifically for cosmograph visualization.

* **Parameters:**
  * **source_uri** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – URI of data source
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
  * **strict** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, actually calls cosmograph for validation
* **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)]
* **Returns:**
  Tuple of (prepared_dataframe, metadata)

### Example

```pycon
>>> df, meta = load_for_cosmo('data.csv')
>>> from cosmograph import cosmo
>>> cosmo(df, **meta['preparing']['metadata']['validation_result']['params'])
```


# _autosummary/aw.preparing.html.md

# aw.preparing

Preparation agent for transforming data to meet target requirements.

Implements ReAct pattern with functional validation (try-the-purpose approach).

### Functions

| [`create_preparation_agent`](_autosummary/aw.preparing.html.md#aw.preparing.create_preparation_agent)([target, ...])   | Factory function to create a preparation agent.   |
|--------------------------------------------------------------------------------------------|---------------------------------------------------|

### Classes

| [`PreparationAgent`](_autosummary/aw.preparing.html.md#aw.preparing.PreparationAgent)([config, target, ...])   | Agent that prepares data to meet target requirements.   |
|--------------------------------------------------------------------------------------------|---------------------------------------------------------|

### *class* aw.preparing.PreparationAgent(config=None, target='generic', target_validator=None)

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

Agent that prepares data to meet target requirements.

Uses ReAct loop with functional validation:

1. Thought: Analyze current data state vs. requirements
2. Action: Generate transformation code
3. Observe: Execute code and capture result
4. Validate: Try to use data for its purpose (e.g., visualization)
5. Repeat or finish

### Example

```pycon
>>> agent = PreparationAgent(target='cosmo-ready')
>>> context = Context({'loading': {'df': df}})
>>> prepared_df, metadata = agent.execute(df, context)
```

#### execute(input_df, context)

Execute preparation agent to transform data.

* **Parameters:**
  * **input_df** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Input DataFrame to prepare
  * **context** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Context for storing intermediate results
* **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)]]
* **Returns:**
  Tuple of (prepared_dataframe, metadata)

### aw.preparing.create_preparation_agent(target='generic', validator=None, llm=None, max_retries=3)

Factory function to create a preparation agent.

* **Parameters:**
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target format/purpose
  * **validator** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Custom validator function
  * **llm** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – LLM model name or callable
  * **max_retries** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Maximum retry attempts
* **Return type:**
  [`PreparationAgent`](_autosummary/aw.preparing.html.md#aw.preparing.PreparationAgent)
* **Returns:**
  Configured PreparationAgent

### Example

```pycon
>>> agent = create_preparation_agent(
...     target='cosmo-ready',
...     validator=cosmo_validator,
...     max_retries=5
... )
```


# _autosummary/aw.py_gen.html.md

# aw.py_gen

Function makeing and calling

### Functions

| [`extract_function_from_code`](_autosummary/aw.py_gen.html.md#aw.py_gen.extract_function_from_code)(code_str)              | Safely extract a function from a code string.                     |
|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [`make_code_generator`](_autosummary/aw.py_gen.html.md#aw.py_gen.make_code_generator)([template, code_schema, ...]) | Create a code generation function from a template and schema.     |
| [`task_to_function`](_autosummary/aw.py_gen.html.md#aw.py_gen.task_to_function)(task[, output_schema, ...])      | End-to-end: Convert a task description to an executable function. |

### aw.py_gen.extract_function_from_code(code_str)

Safely extract a function from a code string.

* **Parameters:**
  **code_str** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – String containing a Python function definition
* **Return type:**
  `callable`
* **Returns:**
  The function object
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If no function is found or multiple functions exist

### Example

```pycon
>>> code = 'def add(a, b):\n    return a + b'
>>> func = extract_function_from_code(code)
>>> func(2, 3)
5
```

### aw.py_gen.make_code_generator(template='\\nYou are a Python code generator. Your task is to create a complete, executable Python function.\\n\\n## TASK DESCRIPTION\\n{task}\\n\\n## OUTPUT SCHEMA\\nThe function should return a value that conforms to this JSON schema:\\n\\n{output_schema}\\n\\nIf output_schema is null or empty, the function can return any appropriate value.\\n\\n## REQUIREMENTS\\n\\n### Function Signature\\n- Function name: \`{name}\`\\n- Parameters: Extract from the task description (indicated by {{braces}})\\n- All parameters should have type hints where possible\\n- Use clear, descriptive parameter names\\n\\n### Code Quality\\n- Write ONLY the function definition (no imports in function body, no examples, no explanations)\\n- Include a minimal docstring (one line describing what it does)\\n- Use type hints for parameters and return value\\n- Handle edge cases appropriately (e.g., empty inputs, None values)\\n- Use built-in functions and standard library where possible\\n- Keep the code simple and readable\\n\\n### Output Format\\n- If returning a dict matching a schema, ensure all required fields are present\\n- If the schema specifies types, ensure they match (e.g., "number" → int or float)\\n- Return values directly without unnecessary wrapping\\n\\n### Code Style\\n- Follow PEP 8 conventions\\n- Use meaningful variable names\\n- Prefer comprehensions over loops where readable\\n- No print statements or side effects unless the task requires them\\n\\n## CRITICAL INSTRUCTIONS\\n- Respond with ONLY the function definition\\n- Do NOT include: imports, examples, explanations, markdown formatting, or test code\\n- Do NOT wrap the code in markdown code blocks\\n- The response must be valid Python that can be directly executed with \`exec()\`\\n\\n## EXAMPLE FORMAT (for reference only, do not include this in your response)\\n\`\`\`python\\ndef example_function(param1: int, param2: str) -> dict:\\n    """Brief description of what this does."""\\n    # function body\\n    return {{"result": param1}}\\n\`\`\`\\n\\nNOW GENERATE THE FUNCTION.\\n', code_schema={'name': 'generated_python_function', 'schema': {'properties': {'code': {'description': 'Complete Python function definition as a string', 'type': 'string'}}, 'required': ['code'], 'type': 'object'}}, prompt_json_function_maker=None)

Create a code generation function from a template and schema.

* **Parameters:**
  * **template** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The prompt template for code generation
  * **code_schema** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)) – JSON schema defining the output format
  * **prompt_json_function_maker** – Factory function (defaults to aix.prompt_to_json via aw.llm)
* **Returns:**
  A function that generates code from task descriptions

### Example

```pycon
>>> write_code = make_code_generator()
>>> result = write_code(
...     task='Add {a} and {b}',
...     output_schema='{"type": "object", "properties": {"sum": {"type": "number"}}}',
...     name='add_numbers'
... )
>>> func = extract_function_from_code(result['code'])
>>> func(2, 3)
{'sum': 5}
```

### aw.py_gen.task_to_function(task, output_schema=None, name='generated_function', code_generator=None, \*\*generator_kwargs)

End-to-end: Convert a task description to an executable function.

* **Parameters:**
  * **task** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Natural language description of the function’s purpose
  * **output_schema** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict) | [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – JSON schema for the return value (optional)
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name for the generated function
  * **code_generator** – Code generation function (creates one if None)
  * **\*\*generator_kwargs** – Additional arguments for code generator
* **Return type:**
  `callable`
* **Returns:**
  Executable Python function

### Example

```pycon
>>> func = task_to_function(
...     task='Multiply {x} and {y}',
...     output_schema='{"type": "object", "properties": {"product": {"type": "number"}}}',
...     name='multiply'
... )
>>> func(3, 4)
{'product': 12}
```


# _autosummary/aw.routing.html.md

# aw.routing

Configurable routing and decision chains for agentic workflows.

This module provides tools for building extensible, inspectable routing chains
that follow the open-closed principle. Users can:

- Use default configurations out of the box
- Inspect all routing rules and mappings
- Customize individual components
- Extend with new routing strategies

The key pattern is: provide sensible defaults, make them visible, keep them mutable.

### Functions

| [`detect_explicit`](_autosummary/aw.routing.html.md#aw.routing.detect_explicit)(ctx)                           | Use explicit extension if provided.       |
|-------------------------------------------------------------------------------------------------|-------------------------------------------|
| [`detect_from_url`](_autosummary/aw.routing.html.md#aw.routing.detect_from_url)(ctx)                           | Extract extension from URL path.          |
| [`make_content_type_detector`](_autosummary/aw.routing.html.md#aw.routing.make_content_type_detector)([content_type_map]) | Factory for content-type based detection. |
| [`make_magic_bytes_detector`](_autosummary/aw.routing.html.md#aw.routing.make_magic_bytes_detector)([magic_bytes_map])   | Factory for magic bytes based detection.  |

### Classes

| [`ConditionalRouter`](_autosummary/aw.routing.html.md#aw.routing.ConditionalRouter)([strategies, short_circuit])   | Router with short-circuit conditions.                                                |
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [`ConfidentRetrievalStrategy`](_autosummary/aw.routing.html.md#aw.routing.ConfidentRetrievalStrategy)(search[, floor, ...]) | A routing strategy backed by a ranked search: answer only when the ranking is clear. |
| [`ExtensionContext`](_autosummary/aw.routing.html.md#aw.routing.ExtensionContext)(url[, content, ...])            | Context for extension detection.                                                     |
| [`ExtensionRouter`](_autosummary/aw.routing.html.md#aw.routing.ExtensionRouter)([priority_extensions, ...])      | Route extension detection through configurable strategies.                           |
| [`MappingRouter`](_autosummary/aw.routing.html.md#aw.routing.MappingRouter)([mapping, default, key_transform]) | Router based on a lookup mapping.                                                    |
| [`PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter)([strategies])                     | Route through strategies in priority order, short-circuiting on first match.         |
| [`RoutingStrategy`](_autosummary/aw.routing.html.md#aw.routing.RoutingStrategy)(\*args, \*\*kwargs)              | Protocol for routing strategies.                                                     |

### *class* aw.routing.ConditionalRouter(strategies=list(), short_circuit=None)

Bases: [`PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter)

Router with short-circuit conditions.

Only accepts results that match the short-circuit condition,
otherwise continues to next strategy.

```pycon
>>> def try_url(x): return x.get('url_ext')
>>> def try_type(x): return x.get('content_type_ext')
>>>
>>> # Only accept .pdf or .md, otherwise keep trying
>>> router = ConditionalRouter(
...     [try_url, try_type],
...     short_circuit=lambda r: r in {'.pdf', '.md'}
... )
>>>
>>> # .pdf matches short-circuit, return immediately
>>> router({'url_ext': '.pdf', 'content_type_ext': '.html'})
'.pdf'
>>>
>>> # .jpg doesn't match, try next strategy, .md matches
>>> router({'url_ext': '.jpg', 'content_type_ext': '.md'})
'.md'
```

### *class* aw.routing.ConfidentRetrievalStrategy(search, floor=0.0, gap=0.0, rel_gap=None, require_boundary=True, dedup_key=None)

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

A routing strategy backed by a ranked search: answer only when the ranking is clear.

`search(context)` returns `(candidate, score)` pairs, best first (any retrieval
engine: `ir.discover`, a BM25 index, a dict lookup). The strategy returns the top
candidate when its score reaches `floor` *and* beats the runner-up by `gap`
(absolute) or keeps it at or below `rel_gap` times its own score (relative);
otherwise it returns `None` so a [`PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter) can fall through to the
next, more expensive, strategy (an LLM adjudicator, a human). That is the
“cheap-first, escalate on ambiguity” shape: no model in the hot path for the clear
cases, abstention rather than a guess for the close ones.

Until a boundary is configured the strategy **abstains** (`require_boundary`):
an uncalibrated search must not route. Set `floor`, `gap` or `rel_gap`, or
pass `require_boundary=False` to take the top candidate of any ranking.

`dedup_key` collapses copies of one candidate (`'name@base'` records of the same
skill) to the best-scoring one before the gap test, so twins cannot tie.

```pycon
>>> ranked = {'open an issue': [('ge-write-issue', 0.9), ('ge', 0.4)],
...           'do the thing': [('a', 0.5), ('b', 0.48)],
...           'nothing': []}
>>> route = ConfidentRetrievalStrategy(search=ranked.get, floor=0.3, gap=0.1)
>>> route('open an issue')
'ge-write-issue'
>>> route('do the thing') is None   # too close to call: escalate
True
>>> route('nothing') is None
True
>>> router = PriorityRouter([route, lambda q: 'ask-the-llm'])
>>> router('do the thing')
'ask-the-llm'
```

`explain` tells a caller why a query fell through, for calibration logs:

```pycon
>>> route.explain('do the thing')
'ambiguous: a=0.5 over b=0.48 is below gap 0.1'
>>> ConfidentRetrievalStrategy(search=ranked.get).explain('open an issue')
'abstained: no boundary configured (set floor, gap or rel_gap)'
>>> copies = lambda q: [('x@a', 10.0), ('x@b', 10.0), ('y', 7.0)]
>>> ConfidentRetrievalStrategy(search=copies, rel_gap=0.9, dedup_key=lambda c: c.split('@')[0])('q')
'x@a'
```

#### explain(context)

Why the strategy answered or abstained, in one line.

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

### *class* aw.routing.ExtensionContext(url, content=b'', content_type='', explicit_extension=None)

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

Context for extension detection.

```pycon
>>> ctx = ExtensionContext(
...     url='https://example.com/file.pdf',
...     content=b'%PDF-1.5',
...     content_type='text/html'
... )
>>> ctx.url
'https://example.com/file.pdf'
```

### *class* aw.routing.ExtensionRouter(priority_extensions=<factory>, content_type_map=<factory>, magic_bytes_map=<factory>)

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

Route extension detection through configurable strategies.

This router implements the default logic for detecting file extensions,
but every component is visible and customizable.

### Examples

```pycon
>>> # Use with defaults
>>> router = ExtensionRouter()
>>> ctx = ExtensionContext('https://example.com/file.pdf', b'%PDF-1.5')
>>> router(ctx)
'.pdf'
>>>
>>> # URL without extension, falls back to magic bytes
>>> ctx = ExtensionContext('https://example.com/download', b'%PDF-1.5')
>>> router(ctx)
'.pdf'
>>>
>>> # Priority extensions short-circuit
>>> ctx = ExtensionContext('https://example.com/file.pdf', b'<html>')
>>> router(ctx)  # .pdf from URL wins even though content is HTML
'.pdf'
>>>
>>> # Customize content type mapping
>>> router.content_type_map['.txt'] = 'text/x-log'
>>>
>>> # Add custom detector
>>> def my_detector(ctx): return '.custom' if 'special' in ctx.url else None
>>> router = router.with_prepended_strategy(my_detector)
```

#### with_appended_strategy(strategy)

Create new router with added strategy at lowest priority.

* **Return type:**
  [`ExtensionRouter`](_autosummary/aw.routing.html.md#aw.routing.ExtensionRouter)

#### with_prepended_strategy(strategy)

Create new router with added strategy at highest priority.

* **Return type:**
  [`ExtensionRouter`](_autosummary/aw.routing.html.md#aw.routing.ExtensionRouter)

### *class* aw.routing.MappingRouter(mapping=dict(), default=None, key_transform=None)

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

Router based on a lookup mapping.

Provides a clean interface for switch-case style routing with:

- Visible, mutable mapping
- Optional default value or factory
- Easy extension via dict interface

```pycon
>>> # Content-Type to extension mapping
>>> ct_map = {
...     'application/pdf': '.pdf',
...     'text/html': '.html',
...     'application/json': '.json',
... }
>>> router = MappingRouter(ct_map)
>>>
>>> router('application/pdf')
'.pdf'
>>> router('text/plain') is None  # No default
True
>>>
>>> # With default
>>> router_with_default = MappingRouter(ct_map, default='.bin')
>>> router_with_default('text/plain')
'.bin'
```

#### copy()

Create a copy with same configuration.

* **Return type:**
  [`MappingRouter`](_autosummary/aw.routing.html.md#aw.routing.MappingRouter)

#### update(\*args, \*\*kwargs)

Update mapping.

### *class* aw.routing.PriorityRouter(strategies=list())

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

Route through strategies in priority order, short-circuiting on first match.

This is a simpler, more specialized version of i2.routing_forest that’s
optimized for the common case of “try these in order, stop at first success”.

```pycon
>>> def try_a(x): return 'A' if x > 10 else None
>>> def try_b(x): return 'B' if x > 5 else None
>>> def try_c(x): return 'C'
>>>
>>> router = PriorityRouter([try_a, try_b, try_c])
>>> router(15)
'A'
>>> router(8)
'B'
>>> router(3)
'C'
```

#### append(strategy)

Add a strategy at the end (lowest priority).

* **Return type:**
  [`PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter)

#### insert(index, strategy)

Insert a strategy at a specific position.

* **Return type:**
  [`PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter)

#### prepend(strategy)

Add a strategy at the beginning (highest priority).

* **Return type:**
  [`PriorityRouter`](_autosummary/aw.routing.html.md#aw.routing.PriorityRouter)

### *class* aw.routing.RoutingStrategy(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Protocol for routing strategies.

A routing strategy takes a context and returns a result or None.

### aw.routing.detect_explicit(ctx)

Use explicit extension if provided.

```pycon
>>> ctx = ExtensionContext('', explicit_extension='pdf')
>>> detect_explicit(ctx)
'.pdf'
>>> ctx = ExtensionContext('', explicit_extension='.json')
>>> detect_explicit(ctx)
'.json'
```

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

### aw.routing.detect_from_url(ctx)

Extract extension from URL path.

```pycon
>>> ctx = ExtensionContext('https://example.com/file.pdf')
>>> detect_from_url(ctx)
'.pdf'
>>> ctx = ExtensionContext('https://example.com/file')
>>> detect_from_url(ctx) 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)]

### aw.routing.make_content_type_detector(content_type_map=None)

Factory for content-type based detection.

Returns a detector function with the given mapping.
Users can create custom detectors with different mappings.

```pycon
>>> # Use default mapping
>>> detector = make_content_type_detector()
>>> ctx = ExtensionContext('', content_type='application/pdf')
>>> detector(ctx)
'.pdf'
>>>
>>> # Custom mapping
>>> custom_map = {'text/plain': '.log'}
>>> custom_detector = make_content_type_detector(custom_map)
>>> ctx = ExtensionContext('', content_type='text/plain')
>>> custom_detector(ctx)
'.log'
```

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

### aw.routing.make_magic_bytes_detector(magic_bytes_map=None)

Factory for magic bytes based detection.

```pycon
>>> detector = make_magic_bytes_detector()
>>> ctx = ExtensionContext('', content=b'%PDF-1.5...')
>>> detector(ctx)
'.pdf'
>>> ctx = ExtensionContext('', content=b'<html>...')
>>> detector(ctx)
'.html'
```

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


# _autosummary/aw.tools.html.md

# aw.tools

Tools for executing code and other agent actions.

Provides code execution capabilities with safe defaults and extensibility
for robust backends like LangChain’s CodeInterpreter.

### Functions

| [`create_dspy_executor`](_autosummary/aw.tools.html.md#aw.tools.create_dspy_executor)()      | Create an executor using DSPy's code execution (if available).       |
|------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [`create_langchain_executor`](_autosummary/aw.tools.html.md#aw.tools.create_langchain_executor)() | Create an executor using LangChain's CodeInterpreter (if available). |

### Classes

| [`CodeInterpreterTool`](_autosummary/aw.tools.html.md#aw.tools.CodeInterpreterTool)([allowed_modules, ...])    | Tool for executing Python code in a controlled environment.   |
|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [`ExecutionResult`](_autosummary/aw.tools.html.md#aw.tools.ExecutionResult)(success[, output, error, ...]) | Result of code execution.                                     |
| [`SafeCodeInterpreter`](_autosummary/aw.tools.html.md#aw.tools.SafeCodeInterpreter)(\*\*kwargs)                | Extra-safe code interpreter with restricted operations.       |

### *class* aw.tools.CodeInterpreterTool(allowed_modules=None, global_context=None, executor=None)

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

Tool for executing Python code in a controlled environment.

Provides a safe default implementation using exec() with limited namespace,
and allows injection of more robust backends.

### Example

```pycon
>>> tool = CodeInterpreterTool()
>>> result = tool("x = 5; y = x * 2; print(y)")
>>> result.success
True
>>> result.output.strip()
'10'
```

### *class* aw.tools.ExecutionResult(success, output='', error='', traceback_str='', result=None, locals_dict=None)

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

Result of code execution.

#### success

Whether execution succeeded without exceptions

#### output

Standard output captured during execution

#### error

Error message if execution failed

#### traceback

Full traceback if execution failed

#### result

The return value or final expression value

#### locals

Local variables after execution

### *class* aw.tools.SafeCodeInterpreter(\*\*kwargs)

Bases: [`CodeInterpreterTool`](_autosummary/aw.tools.html.md#aw.tools.CodeInterpreterTool)

Extra-safe code interpreter with restricted operations.

Disallows file I/O, network access, and other potentially dangerous operations.

### aw.tools.create_dspy_executor()

Create an executor using DSPy’s code execution (if available).

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`ExecutionResult`](_autosummary/aw.tools.html.md#aw.tools.ExecutionResult)]
* **Returns:**
  Executor function compatible with CodeInterpreterTool

### aw.tools.create_langchain_executor()

Create an executor using LangChain’s CodeInterpreter (if available).

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`ExecutionResult`](_autosummary/aw.tools.html.md#aw.tools.ExecutionResult)]
* **Returns:**
  Executor function compatible with CodeInterpreterTool

### Example

```pycon
>>> try:
...     executor = create_langchain_executor()
...     tool = CodeInterpreterTool(executor=executor)
... except ImportError:
...     # LangChain not available - use default
...     tool = CodeInterpreterTool()
```


# _autosummary/aw.translators.html.md

# aw.translators

Translators from aw agent specifications to other agent formats.

Supports:

- Claude Code Skills / Agent Skills Open Standard (SKILL.md + scripts/)
- CrewAI (YAML agent/task configs)
- OpenAI tool schemas (JSON)

The core pattern is:

1. extract_agent_spec() introspects an aw agent into a normalized dict
2. Format-specific renderers convert the spec to target formats

### Example

```pycon
>>> from aw import LoadingAgent
>>> from aw.translators import to_claude_skill
>>> agent = LoadingAgent()
>>> skill_md = to_claude_skill(agent, name='data-loading')
>>> print(skill_md)
```

```pycon
>>> # Write a complete skill directory
>>> from aw.translators import write_skill_directory
>>> write_skill_directory(agent, '/path/to/skills/data-loading')
```

### Functions

| [`claude_skill_from_spec`](_autosummary/aw.translators.html.md#aw.translators.claude_skill_from_spec)(spec, \*[, name, ...])      | Render a Claude Code SKILL.md string from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).         |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [`crewai_yaml_from_spec`](_autosummary/aw.translators.html.md#aw.translators.crewai_yaml_from_spec)(spec, \*[, name, role, ...]) | Render a CrewAI agent config dict from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).            |
| [`extract_agent_spec`](_autosummary/aw.translators.html.md#aw.translators.extract_agent_spec)(agent[, name])                  | Extract a normalized AgentSpec from any aw agent.                                                                |
| [`openai_assistant_from_spec`](_autosummary/aw.translators.html.md#aw.translators.openai_assistant_from_spec)(spec, \*[, name, ...])  | Render an OpenAI Assistant-style config dict from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec). |
| [`openai_tools_from_spec`](_autosummary/aw.translators.html.md#aw.translators.openai_tools_from_spec)(spec)                       | Render OpenAI function-calling tool schemas from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).  |
| [`to_claude_skill`](_autosummary/aw.translators.html.md#aw.translators.to_claude_skill)(agent[, name, description, ...])   | Translate an aw agent to a Claude Code SKILL.md string.                                                          |
| [`to_crewai_yaml`](_autosummary/aw.translators.html.md#aw.translators.to_crewai_yaml)(agent[, name, role, goal, ...])     | Translate an aw agent to a CrewAI agent YAML config dict.                                                        |
| [`to_openai_assistant`](_autosummary/aw.translators.html.md#aw.translators.to_openai_assistant)(agent[, name, model])          | Translate an aw agent to an OpenAI Assistant-style config dict.                                                  |
| [`to_openai_tools`](_autosummary/aw.translators.html.md#aw.translators.to_openai_tools)(agent)                             | Translate an aw agent's tools to OpenAI function-calling tool schemas.                                           |
| [`workflow_to_crewai_yaml`](_autosummary/aw.translators.html.md#aw.translators.workflow_to_crewai_yaml)(workflow)                  | Translate an AgenticWorkflow to CrewAI agents.yaml + tasks.yaml.                                                 |
| [`workflow_to_skills`](_autosummary/aw.translators.html.md#aw.translators.workflow_to_skills)(workflow, output_dir)           | Translate an AgenticWorkflow into a set of Claude Code skills.                                                   |
| [`write_skill_directory`](_autosummary/aw.translators.html.md#aw.translators.write_skill_directory)(agent, output_dir[, ...])    | Write a complete Claude Code skill directory.                                                                    |

### Classes

| [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec)(name[, description, instructions, ...])   | Normalized, format-agnostic description of an aw agent.   |
|------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [`ToolSpec`](_autosummary/aw.translators.html.md#aw.translators.ToolSpec)(name[, description, parameters, source])   | Normalized description of a tool.                         |
| [`ValidatorSpec`](_autosummary/aw.translators.html.md#aw.translators.ValidatorSpec)(name[, description, checks])          | Normalized description of a validator.                    |

### *class* aw.translators.AgentSpec(name, description='', instructions='', tools=list(), validators=list(), model='', max_retries=3, human_in_loop=False, source_class='', extra=dict())

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

Normalized, format-agnostic description of an aw agent.

This is the intermediate representation that all translators consume.
It captures the essential components of an agent without being tied
to any specific framework.

### Example

```pycon
>>> from aw import LoadingAgent
>>> spec = extract_agent_spec(LoadingAgent())
>>> spec.name
'LoadingAgent'
```

### *class* aw.translators.ToolSpec(name, description='', parameters=dict(), source='')

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

Normalized description of a tool.

### *class* aw.translators.ValidatorSpec(name, description='', checks=list())

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

Normalized description of a validator.

### aw.translators.claude_skill_from_spec(spec, , name=None, description=None, extra_tools=None, disable_model_invocation=False)

Render a Claude Code SKILL.md string from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).

The rendering core of [`to_claude_skill()`](_autosummary/aw.translators.html.md#aw.translators.to_claude_skill) — driveable by any `AgentSpec`
(not only a live aw agent), so other tools (e.g. `coact`) can reuse it.

### Example

```pycon
>>> from aw import LoadingAgent
>>> from aw.translators import extract_agent_spec, claude_skill_from_spec
>>> spec = extract_agent_spec(LoadingAgent(), name='data-loading')
>>> '---' in claude_skill_from_spec(spec)
True
```

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

### aw.translators.crewai_yaml_from_spec(spec, , name=None, role=None, goal=None, backstory=None)

Render a CrewAI agent config dict from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).

The rendering core of [`to_crewai_yaml()`](_autosummary/aw.translators.html.md#aw.translators.to_crewai_yaml), driveable by any `AgentSpec`.

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

### aw.translators.extract_agent_spec(agent, name=None)

Extract a normalized AgentSpec from any aw agent.

Introspects the agent’s class, config, tools, and validators
to build a format-agnostic intermediate representation.

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance (LoadingAgent, PreparationAgent, etc.)
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override name (defaults to class name)
* **Return type:**
  [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec)
* **Returns:**
  AgentSpec with all extractable information

### Example

```pycon
>>> from aw import LoadingAgent
>>> spec = extract_agent_spec(LoadingAgent())
>>> spec.name
'LoadingAgent'
>>> len(spec.tools) >= 1
True
```

### aw.translators.openai_assistant_from_spec(spec, , name=None, model='gpt-4')

Render an OpenAI Assistant-style config dict from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).

The rendering core of [`to_openai_assistant()`](_autosummary/aw.translators.html.md#aw.translators.to_openai_assistant), driveable by any `AgentSpec`.

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

### aw.translators.openai_tools_from_spec(spec)

Render OpenAI function-calling tool schemas from an [`AgentSpec`](_autosummary/aw.translators.html.md#aw.translators.AgentSpec).

The rendering core of [`to_openai_tools()`](_autosummary/aw.translators.html.md#aw.translators.to_openai_tools), driveable by any `AgentSpec`.

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

### aw.translators.to_claude_skill(agent, name=None, description=None, extra_tools=None, disable_model_invocation=False)

Translate an aw agent to a Claude Code SKILL.md string.

Generates a complete SKILL.md file with YAML frontmatter and
markdown instructions, compatible with both Claude Code skills
and the Agent Skills Open Standard (agentskills.io).

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override skill name (defaults to kebab-case of class name)
  * **description** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override description
  * **extra_tools** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – Additional Claude Code tools to allow
  * **disable_model_invocation** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, skill is manual-only (/name)
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Returns:**
  Complete SKILL.md content as a string

### Example

```pycon
>>> from aw import LoadingAgent
>>> skill = to_claude_skill(LoadingAgent(), name='data-loading')
>>> '---' in skill
True
>>> 'data-loading' in skill
True
```

### aw.translators.to_crewai_yaml(agent, name=None, role=None, goal=None, backstory=None)

Translate an aw agent to a CrewAI agent YAML config dict.

CrewAI agents are defined with role, goal, backstory, and tools.
This function maps aw’s AgentSpec to that structure.

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override agent name
  * **role** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override role (defaults to agent description)
  * **goal** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override goal
  * **backstory** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override backstory
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict suitable for YAML serialization as a CrewAI agent config

### Example

```pycon
>>> from aw import LoadingAgent
>>> config = to_crewai_yaml(LoadingAgent(), name='data_loader')
>>> config['role']
'Data Loading Specialist'
```

### aw.translators.to_openai_assistant(agent, name=None, model='gpt-4')

Translate an aw agent to an OpenAI Assistant-style config dict.

Generates a configuration suitable for creating an OpenAI Assistant
(or Responses API agent) via the API.

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override name
  * **model** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override model
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with assistant configuration

### Example

```pycon
>>> from aw import LoadingAgent
>>> config = to_openai_assistant(LoadingAgent())
>>> 'instructions' in config
True
```

### aw.translators.to_openai_tools(agent)

Translate an aw agent’s tools to OpenAI function-calling tool schemas.

Generates JSON-Schema-based tool definitions compatible with the
OpenAI Chat Completions API and Responses API.

* **Parameters:**
  **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)
* **Returns:**
  List of tool definition dicts in OpenAI format

### Example

```pycon
>>> from aw import LoadingAgent
>>> tools = to_openai_tools(LoadingAgent())
>>> all(t['type'] == 'function' for t in tools)
True
```

### aw.translators.workflow_to_crewai_yaml(workflow)

Translate an AgenticWorkflow to CrewAI agents.yaml + tasks.yaml.

* **Parameters:**
  **workflow** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An AgenticWorkflow instance
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with ‘agents’ and ‘tasks’ keys, each containing
  YAML-serializable config dicts

### Example

```pycon
>>> from aw import create_cosmo_prep_workflow
>>> workflow = create_cosmo_prep_workflow()
>>> config = workflow_to_crewai_yaml(workflow)
>>> 'agents' in config and 'tasks' in config
True
```

### aw.translators.workflow_to_skills(workflow, output_dir)

Translate an AgenticWorkflow into a set of Claude Code skills.

Each step in the workflow becomes a separate skill directory.

* **Parameters:**
  * **workflow** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An AgenticWorkflow instance
  * **output_dir** ([`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)]) – Parent directory for all skill directories
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)
* **Returns:**
  List of Paths to created skill directories

### Example

```pycon
>>> from aw import create_cosmo_prep_workflow
>>> workflow = create_cosmo_prep_workflow()
>>> paths = workflow_to_skills(workflow, '/tmp/skills')
```

### aw.translators.write_skill_directory(agent, output_dir, name=None, description=None, include_scripts=True)

Write a complete Claude Code skill directory.

Creates:

```default
output_dir/
├── SKILL.md
└── scripts/          (if include_scripts and agent has tools)
    └── validate.py   (validator wrapper script)
```

* **Parameters:**
  * **agent** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – An aw agent instance
  * **output_dir** ([`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)]) – Directory to write the skill to
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override skill name
  * **description** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Override description
  * **include_scripts** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to generate helper scripts
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created directory

### Example

```pycon
>>> from aw import LoadingAgent
>>> path = write_skill_directory(
...     LoadingAgent(), '/tmp/test-skill', name='data-loading'
... )
```


# _autosummary/aw.util.html.md

# aw.util

Utility tools and helper functions for agents.

Includes file sampling, LLM facades, and other common utilities.

### Functions

| [`claude_desktop_config`](_autosummary/aw.util.html.md#aw.util.claude_desktop_config)([key_path, config_dir])   | Get a FileStore interface to Claude Desktop's configuration.                                                                                  |
|--------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| [`compute_dataframe_info`](_autosummary/aw.util.html.md#aw.util.compute_dataframe_info)(df)                      | Compute comprehensive info about a DataFrame.                                                                                                 |
| [`create_oa_chat`](_autosummary/aw.util.html.md#aw.util.create_oa_chat)()                                | Create a chat function through [`aw.llm.default_chat()`](_autosummary/aw.llm.html.md#aw.llm.default_chat) (`aix`, else `oa`). |
| [`create_openai_chat`](_autosummary/aw.util.html.md#aw.util.create_openai_chat)([model])                     | Create a text-to-text chat function using OpenAI API.                                                                                         |
| [`default_llm_factory`](_autosummary/aw.util.html.md#aw.util.default_llm_factory)([model])                    | Factory to create LLM function from various specifications.                                                                                   |
| [`get_numeric_columns`](_autosummary/aw.util.html.md#aw.util.get_numeric_columns)(df[, exclude_nulls])        | Get numeric columns from DataFrame.                                                                                                           |
| [`infer_loader_from_extension`](_autosummary/aw.util.html.md#aw.util.infer_loader_from_extension)(extension)          | Infer pandas loader function from file extension.                                                                                             |
| [`infer_loader_params`](_autosummary/aw.util.html.md#aw.util.infer_loader_params)(extension[, sample_text])   | Infer parameters for pandas loader based on file characteristics.                                                                             |

### Classes

| [`FileSamplerTool`](_autosummary/aw.util.html.md#aw.util.FileSamplerTool)([sample_size])   | Tool to sample and analyze file metadata and content.   |
|-----------------------------------------------------------------------------------|---------------------------------------------------------|

### *class* aw.util.FileSamplerTool(sample_size=1024)

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

Tool to sample and analyze file metadata and content.

Helps agents understand what kind of data they’re dealing with
before attempting to load it.

### Example

```pycon
>>> sampler = FileSamplerTool()
>>> info = sampler('/path/to/data.csv')
>>> info['extension']
'.csv'
```

### aw.util.claude_desktop_config(key_path='mcpServers', , config_dir=None)

Get a FileStore interface to Claude Desktop’s configuration.

By default, operates on the ‘mcpServers’ section.

Automatically creates the config file if it doesn’t exist, and creates the
mcpServers section if it’s missing.

* **Parameters:**
  * **key_path** – Path to nested section (default: ‘mcpServers’)
  * **config_dir** – Override default config directory location
* **Returns:**
  FileStore interface to Claude Desktop config

### Example

```pycon
>>> # Add/manage MCP servers
>>> mcp = claude_desktop_config()
>>>
>>> # Add a new server
>>> mcp['download'] = {
...     'command': 'python',
...     'args': ['/path/to/agent.py']
... }
>>>
>>> # List configured servers
>>> list(mcp)
>>>
>>> # Remove a server
>>> del mcp['old_server']
```

### aw.util.compute_dataframe_info(df)

Compute comprehensive info about a DataFrame.

* **Parameters:**
  **df** – pandas DataFrame
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with shape, dtypes, null counts, sample rows, etc.

### Example

```pycon
>>> import pandas as pd
>>> df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
>>> info = compute_dataframe_info(df)
>>> info['shape']
(2, 2)
```

### aw.util.create_oa_chat()

Create a chat function through [`aw.llm.default_chat()`](_autosummary/aw.llm.html.md#aw.llm.default_chat) (`aix`, else `oa`).

The name is kept for compatibility; generation is routed through `aix`.

* **Return type:**
  [`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)]
* **Returns:**
  A callable that takes a prompt and returns a response

### Example

```pycon
>>> chat = create_oa_chat()
>>> response = chat("Hello!")
```

### aw.util.create_openai_chat(model='gpt-4', \*\*default_kwargs)

Create a text-to-text chat function using OpenAI API.

* **Parameters:**
  * **model** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – OpenAI model name
  * **\*\*default_kwargs** – Default parameters for API calls
* **Return type:**
  [`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)]
* **Returns:**
  A callable that takes a prompt and returns a response

### Example

```pycon
>>> chat = create_openai_chat("gpt-4o-mini")
>>> response = chat("What is 2+2?")
```

(Skipped: the call is billable and needs `OPENAI_API_KEY`.)

### aw.util.default_llm_factory(model='gpt-4')

Factory to create LLM function from various specifications.

* **Parameters:**
  **model** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]) – Either a model name string, or a callable
* **Return type:**
  [`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)]
* **Returns:**
  A callable text-to-text function

### Example

```pycon
>>> llm = default_llm_factory("gpt-4")
>>> llm = default_llm_factory(lambda p: f"Echo: {p}")
```

### aw.util.get_numeric_columns(df, exclude_nulls=True)

Get numeric columns from DataFrame.

* **Parameters:**
  * **df** – pandas DataFrame
  * **exclude_nulls** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to exclude columns with null values
* **Returns:**
  Generator of column names

### Example

```pycon
>>> for col in get_numeric_columns(df):
...     print(col)
```

### aw.util.infer_loader_from_extension(extension)

Infer pandas loader function from file extension.

* **Parameters:**
  **extension** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – File extension (e.g., ‘.csv’, ‘.json’)
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Returns:**
  Name of pandas loader function

### Example

```pycon
>>> infer_loader_from_extension('.csv')
'read_csv'
>>> infer_loader_from_extension('.xlsx')
'read_excel'
```

### aw.util.infer_loader_params(extension, sample_text=None)

Infer parameters for pandas loader based on file characteristics.

* **Parameters:**
  * **extension** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – File extension
  * **sample_text** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Optional sample of file content
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict of parameters to pass to loader

### Example

```pycon
>>> params = infer_loader_params('.csv', 'a,b,c\n1,2,3')
>>> params.get('sep')
','
```


# _autosummary/aw.validation.html.md

# aw.validation

Validation system supporting three flavors: schema, info-dict, and functional.

This module provides validators that can be used to check if artifacts
meet requirements. Validators follow the pattern:

```default
validator(artifact) -> (success: bool, info: dict)
```

### Functions

| [`all_validators`](_autosummary/aw.validation.html.md#aw.validation.all_validators)(\*validators)                  | Combine multiple validators - all must pass.                       |
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [`any_validator`](_autosummary/aw.validation.html.md#aw.validation.any_validator)(\*validators)                   | Combine multiple validators - at least one must pass.              |
| [`functional_validator`](_autosummary/aw.validation.html.md#aw.validation.functional_validator)(try_function[, ...])     | Create a validator that tries to use the artifact for its purpose. |
| [`has_attributes`](_autosummary/aw.validation.html.md#aw.validation.has_attributes)(\*\*required_attrs)            | Validator that checks artifact has required attributes.            |
| [`info_dict_validator`](_autosummary/aw.validation.html.md#aw.validation.info_dict_validator)(compute_info, check_info) | Create a validator that computes info then checks it.              |
| [`is_not_empty`](_autosummary/aw.validation.html.md#aw.validation.is_not_empty)()                                | Validator that checks artifact is not empty.                       |
| [`is_type`](_autosummary/aw.validation.html.md#aw.validation.is_type)(expected_type)                        | Validator that checks artifact type.                               |
| [`schema_validator`](_autosummary/aw.validation.html.md#aw.validation.schema_validator)(schema)                      | Create a validator from a schema (Pydantic, JSON Schema, etc.).    |

### aw.validation.all_validators(\*validators)

Combine multiple validators - all must pass.

* **Parameters:**
  **\*validators** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Validator functions to combine
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator that passes only if all validators pass

### Example

```pycon
>>> validate = all_validators(
...     is_dataframe,
...     has_required_columns(['x', 'y']),
...     has_no_nulls
... )
```

### aw.validation.any_validator(\*validators)

Combine multiple validators - at least one must pass.

* **Parameters:**
  **\*validators** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – Validator functions to combine
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator that passes if any validator passes

### aw.validation.functional_validator(try_function, success_check=None)

Create a validator that tries to use the artifact for its purpose.

This validator actually attempts to use the artifact in the way it’s
intended to be used (e.g., try to visualize the data, try to train a model).

* **Parameters:**
  * **try_function** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]) – Function that tries to use the artifact
  * **success_check** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Optional function to check if result is acceptable
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator function

### Example

```pycon
>>> def try_cosmo(df):
...     return cosmograph.cosmo(df, points_x_by='x', points_y_by='y')
>>> validate = functional_validator(try_cosmo)
>>> validate(df)
```

### aw.validation.has_attributes(\*\*required_attrs)

Validator that checks artifact has required attributes.

### Example

```pycon
>>> validate = has_attributes(shape=lambda s: len(s) == 2, columns=lambda c: len(c) > 0)
```

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

### aw.validation.info_dict_validator(compute_info, check_info)

Create a validator that computes info then checks it.

This is a two-stage validator:

1. Compute information about the artifact (e.g., df.shape, df.dtypes)
2. Check if that information meets requirements

* **Parameters:**
  * **compute_info** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]) – Function to extract info from artifact
  * **check_info** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]) – Function to check if info is acceptable
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator function

### Example

```pycon
>>> def compute_df_info(df):
...     return {'shape': df.shape, 'null_count': df.isnull().sum().sum()}
>>> def check_df_info(info):
...     if info['null_count'] > 10:
...         return False, "Too many nulls"
...     return True, "OK"
>>> validate = info_dict_validator(compute_df_info, check_df_info)
```

### aw.validation.is_not_empty()

Validator that checks artifact is not empty.

Works for sequences, mappings, DataFrames, etc.

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

### aw.validation.is_type(expected_type)

Validator that checks artifact type.

### Example

```pycon
>>> import pandas as pd
>>> validate = is_type(pd.DataFrame)
```

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

### aw.validation.schema_validator(schema)

Create a validator from a schema (Pydantic, JSON Schema, etc.).

* **Parameters:**
  **schema** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – A schema object with validation capability
* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)], [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]]
* **Returns:**
  A validator function

### Example

```pycon
>>> from pydantic import BaseModel
>>> class DataSchema(BaseModel):
...     x: float
...     y: float
>>> validate = schema_validator(DataSchema)
>>> validate({'x': 1.0, 'y': 2.0})
(True, {'validated': ...})
```


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-30 22:24 UTC** from commit <a href="https://github.com/addaix/aw/commit/50cf785e603eebb6d589f05f57498cb05c748bae"><code>50cf785</code></a> on branch <code>main</code>, for **aw 0.1.14** (from <code>pyproject.toml</code>).

#### WARNING
The documentation and the package may be misaligned:

- The documented version (0.1.14) is ahead of the latest release on PyPI (0.1.13): these docs describe unreleased code.

## Source

|                     |                                                                                                                                                  |
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/addaix/aw/commit/50cf785e603eebb6d589f05f57498cb05c748bae"><code>50cf785e603eebb6d589f05f57498cb05c748bae</code></a> |
| Branch              | <code>main</code>                                                                                                                                |
| Tags at this commit | <code>0.1.14</code>                                                                                                                              |
| Working tree        | clean                                                                                                                                            |
| Remote              | <code>https://github.com/addaix/aw</code>                                                                                                        |

## Continuous integration

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

## Tools

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

## Configuration as resolved

|               |                                                                  |
|---------------|------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>furo</code>)               |
| accent        | <code>#4e6200</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/aw/0.1.13/">0.1.13</a>, older than the documented version (0.1.14).

## Reproduce

```bash
git clone https://github.com/addaix/aw && cd aw
git checkout 50cf785e603eebb6d589f05f57498cb05c748bae
pip install "epythet==0.2.25"
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).


# api.html.md

# API reference

| [`aw`](_autosummary/aw.html.md#module-aw)   | aw - Agentic Workflows for Data Preparation   |
|-----------------------------------------------------------------|-----------------------------------------------|


