add-workflow
Provides a template and guide for creating a new RolloutWorkflow in AReaL.
Install
mkdir -p .claude/skills/add-workflow && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3002" && unzip -o skill.zip -d .claude/skills/add-workflow && rm skill.zipInstalls to .claude/skills/add-workflow
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Guide for adding a new RolloutWorkflow to AReaL. Use when user wants to create a new workflow.Key capabilities
- →Create RolloutWorkflow boilerplate
- →Register workflows in package init
- →Implement async episode execution
- →Wrap reward functions for async use
How it works
The skill provides a template and step-by-step instructions to implement a new RolloutWorkflow class, ensuring async compatibility and correct tensor output formats.
Inputs & outputs
When to use add-workflow
- →Implementing a custom rollout workflow
- →Defining new inference engine workflows
- →Setting up async reward functions
About this skill
Add Workflow
Add a new RolloutWorkflow implementation to AReaL.
When to Use
This skill is triggered when:
- User asks "how do I add a workflow?"
- User wants to create a new RolloutWorkflow
- User mentions implementing a custom rollout
Prerequisites
Before starting, ensure you understand:
- The workflow's purpose and requirements
- Input/output data format
- Reward function to use
Step-by-Step Guide
Step 1: Create Workflow File
Create areal/workflow/<name>.py:
import uuid
from typing import Any, Callable
import torch
from areal.api.cli_args import GenerationHyperparameters
from areal.api.engine_api import InferenceEngine
from areal.api.io_struct import ModelRequest, ModelResponse
from areal.api.reward_api import AsyncRewardWrapper
from areal.api.workflow_api import RolloutWorkflow
from areal.utils import logging
logger = logging.getLogger("MyWorkflow")
class MyWorkflow(RolloutWorkflow):
"""Description of your workflow."""
def __init__(
self,
gconfig: GenerationHyperparameters,
tokenizer,
reward_fn: Callable,
):
self.gconfig = gconfig.new_with_stop_and_pad_token_ids(tokenizer)
self.tokenizer = tokenizer
self.async_reward_fn = AsyncRewardWrapper(reward_fn)
async def arun_episode(
self,
engine: InferenceEngine,
data: dict[str, Any],
) -> dict[str, torch.Tensor]:
"""Run a single episode. MUST be async and non-blocking."""
# 1. Prepare input_ids from data
input_ids = self.tokenizer.apply_chat_template(
data["messages"],
tokenize=True,
add_generation_prompt=True,
)
# 2. Build ModelRequest
req = ModelRequest(
rid=uuid.uuid4().hex,
input_ids=list(input_ids),
gconfig=self.gconfig.new(n_samples=1),
tokenizer=self.tokenizer,
)
# 3. Generate completion (async)
resp: ModelResponse = await engine.agenerate(req)
# 4. Compute reward (async)
prompt_str = self.tokenizer.decode(input_ids)
completion_str = self.tokenizer.decode(resp.output_tokens)
reward = await self.async_reward_fn(
prompt_str,
completion_str,
resp.input_tokens,
resp.output_tokens,
**data,
)
# 5. Return results in expected format
return {
"input_ids": torch.tensor(resp.input_tokens),
"output_ids": torch.tensor(resp.output_tokens),
"reward": torch.tensor(reward),
}
Step 2: Register in init.py
Add to areal/workflow/__init__.py:
from areal.workflow.<name> import MyWorkflow
__all__ = [
# ... existing exports
"MyWorkflow",
]
Step 3: Update Entry Script
Update your training script to use the new workflow:
trainer.train(
workflow="areal.workflow.<name>.MyWorkflow",
# ... other args
)
Step 4: Add Tests
Create tests/test_<name>_workflow.py:
import pytest
from areal.workflow.<name> import MyWorkflow
@pytest.mark.asyncio
async def test_workflow_basic():
# Test basic functionality
pass
Reference Implementations
| Workflow | File | Description |
|---|---|---|
| MultiTurnWorkflow | areal/workflow/multi_turn.py | Multi-turn conversation |
| RLVRWorkflow | areal/workflow/rlvr.py | RL with verifiable rewards |
| VisionRLVRWorkflow | areal/workflow/vision_rlvr.py | Vision + RLVR |
Key Requirements
- Async:
arun_episodemust beasync defand non-blocking - No sync I/O: Use
aiofilesfor file operations - Wrap rewards: Use
AsyncRewardWrapperfor reward functions - Tensor format: Output tensors should be
[batch, seq_len, ...] - Use helpers:
concat_padded_tensorsfor combining outputs
Common Mistakes
- ❌ Using
open()instead ofaiofiles.open() - ❌ Forgetting to
awaitasync calls - ❌ Not wrapping reward function with
AsyncRewardWrapper - ❌ Wrong tensor shape conventions
<!-- ================================================================================ MAINTAINER GUIDE ================================================================================ Location: .claude/skills/add-workflow/SKILL.md Invocation: /add-workflow <name> ## Purpose Step-by-step guide for adding new RolloutWorkflow implementations. ## How to Update ### When Workflow API Changes 1. Update the code template in Step 1 2. Update the required imports 3. Update the method signature if changed ### When New Patterns Emerge 1. Add to "Reference Implementations" table 2. Update "Key Requirements" if new requirements added ================================================================================ -->
When not to use it
- →Implementing synchronous workflows
- →Non-AReaL integration tasks
Prerequisites
Limitations
- →Requires async implementation
- →Must follow AReaL tensor conventions
How it compares
It standardizes the creation of custom workflows by providing boilerplate and enforcing architectural requirements like async reward wrapping.
Compared to similar skills
add-workflow side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| add-workflow (this skill) | 1 | 5mo | No flags | Intermediate |
| langchain-architecture | 8 | 2mo | Review | Intermediate |
| ai-agents-architect | 5 | 6mo | No flags | Advanced |
| llm-app-patterns | 3 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by inclusionAI
View all by inclusionAI →You might also like
langchain-architecture
wshobson
Design LLM applications using the LangChain framework with agents, memory, and tool integration patterns. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.
ai-agents-architect
davila7
Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration. Use when: build agent, AI agent, autonomous agent, tool use, function calling.
llm-app-patterns
davila7
Production-ready patterns for building LLM applications. Covers RAG pipelines, agent architectures, prompt IDEs, and LLMOps monitoring. Use when designing AI applications, implementing RAG, building agents, or setting up LLM observability.
model-code-analyzer
zhnnky329
Translate a validated method plan into language-neutral code logic, folder layout, and handoff notes before Python or MATLAB code generation.
architecture-design
brycewang-stanford
Use only when creating new registrable ML components that require Factory or Registry patterns.
triton-operator-design
Ascend
生成适用于 Ascend NPU 的 Triton 算子需求文档。当用户需要设计新的 Triton 算子、编写算子需求文档、进行算子性能优化设计时使用。核心产出:功能定义、API 接口、Tiling 策略、Kernel 实现方案。