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:
extract_agent_spec() introspects an aw agent into a normalized dict
Format-specific renderers convert the spec to target formats
Example
>>> 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)
>>> # Write a complete skill directory
>>> from aw.translators import write_skill_directory
>>> write_skill_directory(agent, '/path/to/skills/data-loading')
Functions
|
Render a Claude Code SKILL.md string from an |
|
Render a CrewAI agent config dict from an |
|
Extract a normalized AgentSpec from any aw agent. |
|
Render an OpenAI Assistant-style config dict from an |
|
Render OpenAI function-calling tool schemas from an |
|
Translate an aw agent to a Claude Code SKILL.md string. |
|
Translate an aw agent to a CrewAI agent YAML config dict. |
|
Translate an aw agent to an OpenAI Assistant-style config dict. |
|
Translate an aw agent's tools to OpenAI function-calling tool schemas. |
|
Translate an AgenticWorkflow to CrewAI agents.yaml + tasks.yaml. |
|
Translate an AgenticWorkflow into a set of Claude Code skills. |
|
Write a complete Claude Code skill directory. |
Classes
|
Normalized, format-agnostic description of an aw agent. |
|
Normalized description of a tool. |
|
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())[source]¶
Bases:
objectNormalized, 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
>>> from aw import LoadingAgent >>> spec = extract_agent_spec(LoadingAgent()) >>> spec.name 'LoadingAgent'
- class aw.translators.ToolSpec(name, description='', parameters=dict(), source='')[source]¶
Bases:
objectNormalized description of a tool.
- class aw.translators.ValidatorSpec(name, description='', checks=list())[source]¶
Bases:
objectNormalized description of a validator.
- aw.translators.claude_skill_from_spec(spec, *, name=None, description=None, extra_tools=None, disable_model_invocation=False)[source]¶
Render a Claude Code SKILL.md string from an
AgentSpec.The rendering core of
to_claude_skill()— driveable by anyAgentSpec(not only a live aw agent), so other tools (e.g.coact) can reuse it.Example
>>> 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:
- aw.translators.crewai_yaml_from_spec(spec, *, name=None, role=None, goal=None, backstory=None)[source]¶
Render a CrewAI agent config dict from an
AgentSpec.The rendering core of
to_crewai_yaml(), driveable by anyAgentSpec.- Return type:
- aw.translators.extract_agent_spec(agent, name=None)[source]¶
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:
- Return type:
- Returns:
AgentSpec with all extractable information
Example
>>> 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')[source]¶
Render an OpenAI Assistant-style config dict from an
AgentSpec.The rendering core of
to_openai_assistant(), driveable by anyAgentSpec.- Return type:
- aw.translators.openai_tools_from_spec(spec)[source]¶
Render OpenAI function-calling tool schemas from an
AgentSpec.The rendering core of
to_openai_tools(), driveable by anyAgentSpec.- Return type:
- aw.translators.to_claude_skill(agent, name=None, description=None, extra_tools=None, disable_model_invocation=False)[source]¶
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:
- Return type:
- Returns:
Complete SKILL.md content as a string
Example
>>> 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)[source]¶
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:
- Return type:
- Returns:
Dict suitable for YAML serialization as a CrewAI agent config
Example
>>> 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')[source]¶
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:
- Return type:
- Returns:
Dict with assistant configuration
Example
>>> from aw import LoadingAgent >>> config = to_openai_assistant(LoadingAgent()) >>> 'instructions' in config True
- aw.translators.to_openai_tools(agent)[source]¶
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) – An aw agent instance- Return type:
- Returns:
List of tool definition dicts in OpenAI format
Example
>>> 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)[source]¶
Translate an AgenticWorkflow to CrewAI agents.yaml + tasks.yaml.
- Parameters:
workflow (
Any) – An AgenticWorkflow instance- Return type:
- Returns:
Dict with ‘agents’ and ‘tasks’ keys, each containing YAML-serializable config dicts
Example
>>> 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)[source]¶
Translate an AgenticWorkflow into a set of Claude Code skills.
Each step in the workflow becomes a separate skill directory.
- Parameters:
- Return type:
- Returns:
List of Paths to created skill directories
Example
>>> 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)[source]¶
Write a complete Claude Code skill directory.
Creates:
output_dir/ ├── SKILL.md └── scripts/ (if include_scripts and agent has tools) └── validate.py (validator wrapper script)- Parameters:
- Return type:
- Returns:
Path to the created directory
Example
>>> from aw import LoadingAgent >>> path = write_skill_directory( ... LoadingAgent(), '/tmp/test-skill', name='data-loading' ... )