Skip to content
Skills Library
AI & agents · Building & coding

add-workflow

/add-workflow

Guide for adding a new RolloutWorkflow to AReaL. Use when user wants to create a new workflow.

Repository
areal ↗
Licence
Apache-2.0
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Guide for adding a new RolloutWorkflow to AReaL. Use when user wants to create a new workflow.

Original author description

Guide for adding a new RolloutWorkflow to AReaL. Use when user wants to create a new workflow.

How it works

  1. When to Use
  2. Prerequisites
  3. Step-by-Step Guide
  4. Reference Implementations
  5. Key Requirements
  6. Common Mistakes
Original SKILL.md headings · 161 lines, 427 words
SKILL.md preview
---
name: add-workflow
description: Guide for adding a new RolloutWorkflow to AReaL. Use when user wants to create a new workflow.
---

# 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`:

```python
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, Any] | None | dict[str, InteractionWithTokenLogpReward]:
        """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`:

```python
from areal.workflow.<name> import MyWorkflow

__all__ = [
    # ... existing exports
    "MyWorkflow",
]
```

### Step 3: Update Entry Script

Update your training script to use the new workflow:

```python
trainer.train(
    workflow="areal.workflow.<name>.MyWorkflow",
    # ... other args
)
```

### Step 4: Add Tests

Create `tests/test_<name>_workflow.py`:

```python
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

1. **Async**: `arun_episode` must be `async def` and non-blocking
1. **No sync I/O**: Use `aiofiles` for file operations
1. **Wrap rewards**: Use `AsyncRewardWrapper` for reward functions
1. **Tensor format**: Output tensors should be `[batch, seq_len, ...]`
1. **Use helpers**: `concat_padded_tensors` for combining outputs

## Common Mistakes

- Using `open()` instead of `aiofiles.open()`
- Forgetting to `await` async calls
- Not wrapping reward function with `AsyncRewardWrapper`
- Wrong tensor shape conventions

Versions

RepositoryScoreLicence
This page · areal-project/areal100Apache-2.0
areal-project/areal100Apache-2.0
microbus-io/fabric100Apache-2.0

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 0f126f1cf5a9 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100add-dataset
    Guide for adding a new dataset loader to AReaL. Use when user wants to add a new dataset.
  • 100add-dataset
    Guide for adding a new dataset loader to AReaL. Use when user wants to add a new dataset.
  • 100add-new-model
    Guided workflow for adding a new model architecture to llama.cpp. Use when the user wants to add/port a new model architecture.
  • 100add-plugin
    Guide for adding a new plugin to this marketplace. Use when creating or scaffolding a new plugin.
  • 100add-new-model
    Guided workflow for adding a new model architecture to llama.cpp. Use when the user wants to add/port a new model architecture.
  • 100add-harness-package
    Guide for adding new AI SDK harness packages. Use when creating a new @ai-sdk/harness-<name> package that adapts a coding-agent runtime to HarnessV1.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.