Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add agents/redai-infra/relax/algorithm-expertgit clone --depth 1 https://github.com/redai-infra/RelaxWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00037 | $0.01314 |
| Opus 5 | $0.00018 | $0.00657 |
| Sonnet 5 | $0.00007 | $0.00263 |
| Haiku 4.5 | $0.00004 | $0.00131 |
Grade A, and why
algorithm-expert scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Algorithm Expert
Relax 中 RL 算法族的配置、损失计算和奖励函数。For project-level rules see AGENTS.md.
算法族
通过 --advantage-estimator 选择:
| 算法 | 特点 | 配置 |
|---|---|---|
| GRPO (默认) | Critic-free, 组归一化 | --advantage-estimator grpo |
| PPO | Critic-based, GAE | --advantage-estimator gae, --kl-coef > 0 |
| GSPO | Sequence-level 重要性采样 | --advantage-estimator gspo |
| SAPO | Soft gating 替代 hard clipping | compute_sapo_loss() |
| DAPO | Dynamic batch size | --use-dynamic-batch-size |
| REINFORCE++ | Discounted REINFORCE | --advantage-estimator reinforce_plus_plus |
| REINFORCE++ BL | + leave-one-out baseline | --advantage-estimator reinforce_plus_plus_baseline |
| OPD | Teacher-student KL penalty | --on-policy-distillation |
核心参数
位置: relax/utils/arguments.py → get_slime_extra_args_provider()
| 参数 | 默认 | 说明 |
|---|---|---|
--eps-clip |
0.2 | PPO clipping range |
--eps-clip-high |
None | 非对称 clipping 上界 |
--eps-clip-c |
None | Dual-clip 下界 |
--kl-coef |
0.0 | KL penalty(0 = critic-free) |
--kl-loss-type |
k1 | k1 / k2 / k3 / low_var_kl |
--entropy-coef |
0.0 | 熵正则化 |
--gamma |
1.0 | GAE 折扣因子 |
--lambd |
1.0 | GAE lambda |
--n-samples-per-prompt |
1 | GRPO 组大小 |
--normalize-advantages |
False | 跨 DP 组白化 |
KL Loss 类型
位置: relax/utils/training/ppo_utils.py → compute_approx_kl()
| 类型 | 公式 | 场景 |
|---|---|---|
| k1 | log_ratio |
简单快速(默认) |
| k2 | (log_ratio)^2 / 2 |
平方近似 |
| k3 / low_var_kl | 非负无偏低方差 | Schulman's KL |
损失计算
位置: relax/backends/megatron/loss.py
policy_loss_function()— PPO clipped loss + 可选 dual-clip / 非对称 clippingcompute_sapo_loss()— SAPO soft gatingvalue_loss_function()— 价值函数 clipping- 高级特性: TIS(截断重要性采样)、OPSM(序列级掩码)、OPD
Advantage 计算
compute_advantages_and_returns()— GAE / 组归一化distributed_masked_whiten()— 跨 DP 组归一化- 支持 Context Parallel (CP) 掩码
奖励函数
位置: relax/engine/rewards/
| 文件 | 领域 |
|---|---|
math_utils.py |
数学题验证 |
deepscaler.py |
DeepScaler |
gpqa.py |
GPQA 评估 |
f1.py |
F1 分数 |
multiple_choice.py |
选择题 |
ifbench.py |
IFBench |
dapo_genrm.py |
DAPO GenRM |
openr1mm.py |
OpenR1MM |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 118 lines · 37 tokens per session scan A e207f665125f
algorithm-expert is an agent published in the GitHub repository redai-infra/Relax (580 stars, last pushed 4d ago), licensed Apache-2.0. It adds 37 tokens to every session and 1,314 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
WEBHOOK_SDK
Write a custom Commonly agent in 30 lines of Python. The SDK is a single stdlib-only file that implements the four CAP verbs; the scaffolder wires publish + install + token-issuance in one command.
memory-keeper
Updates .claude/memory.md with important learnings, fixes, patterns, and gotchas from the current session that would help anyone starting with Claude on this project.
test-team-leader-worker-pool
You are a team leader for worker-pool E2E testing.
test-reporter
Agent "test-reporter" from nrslib/takt, covering e2e test reporter and instructions.
design-rules
Condensed 10 Golden Rules from the Agent Design Bible.
integrations-engineer
Third-party integration specialist for SMB Product-Builder archetypes. Owns the integration contract — OAuth2/API-key flows, webhook signature verification, idempotency keys, retry/backoff with jitter, rate-limit handling, secret storage, and sandbox→prod promotion — for Stripe, Twilio, QuickBooks, Google/Microsoft…