Agent skill

Add Reward

by areal-project in areal-project/AReaL

Guide for adding a new reward function to AReaL. An agent skill from areal-project/AReaL.

Apache-2.0Auto-check passed

Install Add Reward

skills CLI
$ npx skills add areal-project/AReaL --skill add-reward -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install areal-project/AReaL add-reward --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/areal-project/AReaL.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/add-reward .claude/skills/add-reward && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
add-reward
GitHub stars
5.8k
Token cost
~1.2k tokens
SKILL.md length
207 words
Files
1
Skills in repo
11
Repo updated
First seen
Licence
Apache-2.0

At a glance

Guide for adding a new reward function to AReaL. An agent skill from areal-project/AReaL.

  • Works in 4 steps: Create Reward File → Register in init.py → Handle Blocking Operations → …
  • User wants to create a reward function
  • SKILL.md covers When to Use, Step-by-Step Guide, Reference Implementations and Function Signature, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Add Reward is an agent skill from areal-project/AReaL. Guide for adding a new reward function to AReaL. Use when user wants to create a reward function.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: The RL Bridge for LLM-based Agent Applications. Made Simple & Flexible. The licence is Apache-2.0.

When your agent uses it

  • User wants to create a reward function

Example prompts

  • “/add-reward”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Create Reward File
  2. Register in init.py
  3. Handle Blocking Operations
  4. Add Tests

What it can do on your machine

Read from SKILL.md and the folder at commit 298412a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Add Reward loads about 1.2k tokens when it runs. Until then it costs about 27 tokens; SKILL.md has 207 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~27
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from areal-project/AReaL at commit 298412a, republished under its Apache-2.0 licence (© areal-project). 207 words, ~1,237 tokens.

Download SKILL.mdSave it as .claude/skills/add-reward/SKILL.md (or your agent's skills folder).
name
add-reward
description
Guide for adding a new reward function to AReaL. Use when user wants to create a reward function.

Add Reward

Add a new reward function to AReaL.

When to Use

This skill is triggered when:

  • User asks "how do I add a reward function?"
  • User wants to implement custom rewards
  • User mentions reward computation

Step-by-Step Guide

Step 1: Create Reward File

Create areal/reward/<name>.py:

python
from typing import Any

from areal.utils import logging

logger = logging.getLogger("MyReward")


def <name>_reward_fn(
    prompt: str,
    completions: str,
    prompt_ids,
    completion_ids,
    answer: str | None = None,
    **kwargs: Any,
) -> float:
    """Compute reward for a single completion.

    Args:
        prompt: Prompt string
        completions: Completion string (model output)
        prompt_ids: Tokenized prompt IDs
        completion_ids: Tokenized completion IDs
        answer: Ground truth answer from dataset (optional)
        **kwargs: Additional data from dataset

    Returns:
        Reward value (float), typically 0.0 or 1.0
    """
    try:
        # Extract answer from completion
        extracted = _extract_answer(completions)

        # Compare with ground truth
        if answer is not None and extracted == str(answer):
            return 1.0
        return 0.0
    except Exception:
        logger.warning("Exception in reward computation", exc_info=True)
        return 0.0


def _extract_answer(completion: str) -> str:
    """Extract the answer from a completion string.

    Implement your extraction logic here.
    """
    # Example: Extract content from \boxed{}
    import re

    match = re.search(r"\\boxed\{([^}]+)\}", completion)
    if match:
        return match.group(1).strip()
    return completion.strip()
Step 2: Register in init.py

Update areal/reward/__init__.py:

python
# Add to VALID_REWARD_FN
VALID_REWARD_FN = [
    # ... existing reward functions
    "<name>",
]

# Add to get_reward_fn function
def get_reward_fn(name: str, **kwargs):
    # ... existing code
    elif name == "<name>":
        from areal.reward.<name> import <name>_reward_fn
        return <name>_reward_fn
Step 3: Handle Blocking Operations

If your reward function uses blocking operations (e.g., API calls, model inference), the workflow will wrap it with AsyncRewardWrapper:

python
# In your workflow
from areal.reward import AsyncRewardWrapper

self.reward_fn = AsyncRewardWrapper(reward_fn)

# Then call it asynchronously
rewards = await self.reward_fn(prompt, completions, **data)
Step 4: Add Tests

Create tests/test_<name>_reward.py:

python
import pytest
from areal.reward.<name> import <name>_reward_fn

def test_reward_correct_answer():
    reward = <name>_reward_fn(
        prompt="What is 2+2?",
        completions="The answer is \\boxed{4}",
        prompt_ids=None,
        completion_ids=None,
        answer="4",
    )
    assert reward == 1.0

def test_reward_wrong_answer():
    reward = <name>_reward_fn(
        prompt="What is 2+2?",
        completions="The answer is \\boxed{5}",
        prompt_ids=None,
        completion_ids=None,
        answer="4",
    )
    assert reward == 0.0

Reference Implementations

RewardFileDescription
GSM8Kareal/reward/gsm8k.pyMath answer verification
Geometry3Kareal/reward/geometry3k.pyGeometry answer verification
CLEVRareal/reward/clevr_count_70k.pyCounting verification
MathVerifyareal/reward/math_verify.pyGeneral math verification

Function Signature

All reward functions must follow this signature:

python
def reward_fn(
    prompt: str,               # Input prompt string
    completions: str,          # Model completion string
    prompt_ids,                # Tokenized prompt
    completion_ids,            # Tokenized completion
    **kwargs: Any,             # Additional data from dataset (e.g., answer)
) -> float:                    # Reward value (typically 0.0 or 1.0)

Note: The reward function is called once per sample. Batching is handled by AsyncRewardWrapper in the workflow.

Key Requirements

  1. Deterministic: Same inputs should produce same outputs
  2. Return float: Output is a single float value per sample
  3. No blocking in async context: Use AsyncRewardWrapper if needed
  4. Logging: Use areal.utils.logging, not print
  5. Handle exceptions: Return 0.0 on error, don't raise

Common Mistakes

  • Returning a tensor instead of a float
  • Expecting batched inputs (reward is called per sample)
  • Non-deterministic behavior
  • Blocking operations without AsyncRewardWrapper
  • Raising exceptions instead of returning 0.0

© areal-project, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/add-reward of areal-project/AReaL.

Open the folder on GitHubat commit 298412a

Compare with similar skills

Add Reward next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Add Reward compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Add Reward this skillareal-project/AReaL5.8k—~1.2kAutomated safety check: PassApache-2.0
Azure Functionsdavila7/claude-code-templates33k2 repos~344Automated safety check: PassMIT
Recognition Rewardssickn33/agentic-awesome-skills47k1 repos~3.4kAutomated safety check: PassMIT
Neon Functionssickn33/agentic-awesome-skills47k1 repos~8.6kAutomated safety check: NotesApache-2.0
GCP Cloud Functionssickn33/agentic-awesome-skills47k2 repos~2.3kAutomated safety check: PassMIT
Securing Serverless Functionsmukul975/Anthropic-Cybersecurity-Skills34k—~3.1kAutomated safety check: PassApache-2.0

Similar skills

  • Azure Functions

    davila7/claude-code-templates

    Expert patterns for Azure Functions development including isolated worker model, Durable Functions orchestration, cold start optimization, and production patterns.

    33k GitHub starsUsed in 2 repos~344 tokens
    Backend & APIsAuto-check passed
  • Recognition Rewards

    sickn33/agentic-awesome-skills

    Recognition register: employee, reward type, category, visibility, message and points awarded.

    47k GitHub starsUsed in 1 repo~3.4k tokens
    Auto-check passed
  • Neon Functions

    sickn33/agentic-awesome-skills

    Long-running, serverless Node.js HTTP functions deployed onto your Neon branch, with DATABASEURL injected automatically and compute that runs next to your data.

    47k GitHub starsUsed in 1 repo~8.6k tokens
    Backend & APIsAuto-check: notes
  • GCP Cloud Functions

    sickn33/agentic-awesome-skills

    Deploy serverless functions on Google Cloud Functions. An agent skill from sickn33/agentic-awesome-skills.

    47k GitHub starsUsed in 2 repos~2.3k tokens
    Backend & APIsAuto-check passed
  • Securing Serverless Functions

    mukul975/Anthropic-Cybersecurity-Skills

    Hardens serverless compute platforms (AWS Lambda, Azure Functions, Google Cloud Functions): least-privilege IAM roles, dependency vulnerability scanning, secrets management integration, input…

    34k GitHub stars~3.1k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Performing Serverless Function Security Review

    mukul975/Anthropic-Cybersecurity-Skills

    Performing security reviews of serverless functions across AWS Lambda, Azure Functions, and GCP Cloud Functions to identify overly permissive execution roles, insecure environment variables…

    34k GitHub stars~3.1k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed

More from areal-project/AReaL

All 11 skills in this repo
  • Add Archon Model

    areal-project/AReaL

    Guide for adding a new model to the Archon engine. An agent skill from areal-project/AReaL.

    5.8k GitHub stars~4.9k tokensUpdated yesterday
    Auto-check passed
  • Add Dataset

    areal-project/AReaL

    Guide for adding a new dataset loader to AReaL. An agent skill from areal-project/AReaL.

    5.8k GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed
  • Add Unit Tests

    areal-project/AReaL

    Guide for adding unit tests to AReaL. An agent skill from areal-project/AReaL.

    5.8k GitHub stars~1.8k tokensUpdated yesterday
    Auto-check passed
  • Add Workflow

    areal-project/AReaL

    Guide for adding a new RolloutWorkflow to AReaL. An agent skill from areal-project/AReaL.

    5.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Debug Distributed

    areal-project/AReaL

    Guide for debugging distributed training issues in AReaL. An agent skill from areal-project/AReaL.

    5.8k GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Review PR

    areal-project/AReaL

    Read-only pull request review workflow with risk analysis, targeted checklists, and Codex subagent consultation.

    5.8k GitHub stars~704 tokensUpdated yesterday
    Auto-check passed

Questions about Add Reward

What does Add Reward do?

Guide for adding a new reward function to AReaL. An agent skill from areal-project/AReaL. Add Reward is an agent skill from areal-project/AReaL. Guide for adding a new reward function to AReaL.

When should I use Add Reward?

Add Reward fits situations like: user wants to create a reward function.

How do I install Add Reward in Claude Code?

Run `npx skills add areal-project/AReaL --skill add-reward -a claude-code`. Or copy the skill folder (.agents/skills/add-reward in areal-project/AReaL) into .claude/skills/add-reward in your project. Claude Code loads it when a task matches its description.

How do I install Add Reward in Codex?

Run `npx skills add areal-project/AReaL --skill add-reward -a codex`. Or copy the skill folder (.agents/skills/add-reward in areal-project/AReaL) into .agents/skills/add-reward in your project. Codex loads it when a task matches its description.

Can I use Add Reward in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add areal-project/AReaL --skill add-reward -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/add-reward, .gemini/skills/add-reward, .github/skills/add-reward and .opencode/skills/add-reward in your project.

What does Add Reward need to run?

SKILL.md names no scripts, command-line tools or credentials: Add Reward is instructions for the agent only. Our summary lists: Python 3.

Does Add Reward access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Add Reward safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Add Reward use?

Add Reward is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Add Reward use?

About 1.2k tokens (SKILL.md is roughly 4.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Add Reward?

Skills that share tags, products or a category with Add Reward: Azure Functions (davila7/claude-code-templates, 33k stars), Recognition Rewards (sickn33/agentic-awesome-skills, 47k stars), Neon Functions (sickn33/agentic-awesome-skills, 47k stars) and GCP Cloud Functions (sickn33/agentic-awesome-skills, 47k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Add Reward?

areal-project (a GitHub organization) maintains it in areal-project/AReaL, which has 5,824 GitHub stars. The repository holds 11 skills in this directory. The repository was last updated on October 10, 2026.

Source: areal-project/AReaL on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.