Prime Intellect unveils new open toolkit for training custom agentic models

AI Engineer////6 min read

The Shift From APIs to Private Post-Training

For the past few years, the standard playbook for AI engineers has been simple: call a frontier model API, construct a complex prompt, and hope for the best. While this works for basic prototyping, builders targeting complex agentic tasks eventually hit a ceiling. Off-the-shelf models are generalists. They lack the specific behavior, tool compliance, and efficiency required for complex, real-world workflows.

Prime Intellect, an open-source AI research organization led by figures like Applied Research Lead Will Brown, is building a modern post-training stack designed to change this. Post-training—consisting of Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL)—is how generalist base models transform into specialist agents. By open-sourcing libraries like Verifiers and PrimeRL, they aim to democratize the techniques that frontier labs use to build reasoning models, making it possible for individual developers and enterprises to refine models on their own custom tasks.


Prerequisites

Prime Intellect unveils new open toolkit for training custom agentic models
Modern Post-Training: A Deep Dive — Will Brown, Prime Intellect

To get the most out of this tutorial, you should be comfortable with:

  • Python: Intermediate level, including asynchronous programming (asyncio).
  • Machine Learning Concepts: Basic familiarity with Reinforcement Learning (states, actions, rewards), SFT, and tokenizer mechanics.
  • Modern Developer Tools: Experience with Docker and package managers like uv.

Key Libraries & Tools

This workflow centers around three core components:

  • Verifiers: A Python library for defining agent environments, tasks, and reward structures.
  • PrimeRL: A highly scalable, asynchronous reinforcement learning training framework.
  • Renderers: A standalone library that simplifies tokenizer chat templates, eliminating the need to write fragile Jinja configurations.

Deconstructing the Agent Environment: Verifiers V1

In classical RL, environments are often tightly coupled systems. The Verifiers V1 library rethinks this architecture, splitting an agent environment into three distinct, highly modular components:

  1. Task Set: The data and rules of what needs to be solved (completely agent-agnostic).
  2. Harness: The execution loop defining how the agent interacts with the world (e.g., executing terminal commands or calling tools).
  3. Runtime: The execution backend where the code runs (e.g., local subprocesses, Docker, or isolated cloud sandboxes).

Defining a Custom Task Set and Reward

Instead of loading static JSON datasets, you define tasks using dynamic Python decorators. Here is how to write a simple type-checked task loader and a reward function that balances accuracy with conciseness.

from pydantic import BaseModel
from verifiers.v1 import task_set, reward

class CodingTask(BaseModel):
    problem_id: str
    prompt: str
    test_suite: str

@task_set.loader(name="custom_coding_tasks")
def load_my_tasks(config: dict) -> list[CodingTask]:
    # In a real app, pull from Hugging Face or an internal database
    return [
        CodingTask(
            problem_id="task_01",
            prompt="Write a function to reverse a list in Python.",
            test_suite="assert reverse_list([1, 2]) == [2, 1]"
        )
    ]

@reward(name="correctness_and_length_penalty")
def calculate_reward(rollout_trace, task: CodingTask) -> float:
    # 1. Verify correct execution
    is_correct = execute_sandbox_test(rollout_trace.final_code, task.test_suite)
    if not is_correct:
        return 0.0
    
    # 2. Apply length penalty to prevent runaway thinking loops
    token_count = len(rollout_trace.generated_tokens)
    length_penalty = min(0.2, token_count * 0.0001)
    
    return 1.0 - length_penalty

This modular design allows you to write your evaluation logic once and use it interchangeably for offline evaluation, SFT dataset collection, and active RL training.


Bypassing Custom Client Code via Interception Servers

One of the biggest headaches when integrating an existing agent harness into an RL pipeline is updating the network code. Typically, you have to rewrite the agent's internal API client to extract log probabilities, track token usages, or match state transitions.

Verifiers solves this problem using an Interception Server Pattern.

+-----------------------+              +------------------------+              +---------------------+
| Agent Harness         |   OpenAI     | Interception Server    |  gRPC/HTTP   | PrimeRL Inference   |
| (Thinks it talks to   | -----------> | (Injects log_probs,    | -----------> | Engine              |
| OpenAI/Anthropic APIs)|  API Request |  overrides temperature)|              | (Updates weights)   |
+-----------------------+              +------------------------+              +---------------------+

The agent harness remains completely unmodified. It targets a local base URL configured by Verifiers. The interception server intercepts the requests, coordinates with the PrimeRL trainer to extract critical training metrics (like log probabilities and policy tokens), and forwards the requests to the active model.


Resolving the Fragile Jinja Chat Template Problem

When conducting post-training, keeping training and inference perfectly aligned is critical. Minor mismatches—such as a tokenizer template stripping a trailing whitespace or injecting an extra newline—can degrade model policy performance.

To address this, the standalone Renderers library treats chat templates as programmable Python artifacts rather than template strings. Below is a practical example showing how to build a strict chat sequence wrapper with Renderers:

from renderers import ChatRenderer, Message

# Configure a template pipeline for a reasoning model
renderer = ChatRenderer.from_pretrained("deepseek-ai/DeepSeek-R1")

messages = [
    Message(role="system", content="You are an expert software developer."),
    Message(role="user", content="Implement a quicksort algorithm.")
]

# Safely serialize to tokens, preserving exact whitespaces and special tokens
token_ids = renderer.encode(messages, add_generation_prompt=True)
print(f"Encoded safely into {len(token_ids)} tokens without template drift.")

By ensuring that tokenization is consistent across training and deployment, developers can completely eliminate off-policy drift caused by fragile templating engines.


Asynchronous RL: Training DeepSeek-Size Models Efficiently

Traditional reinforcement learning frameworks operate synchronously: the system halts training while waiting for the slowest agent rollout to finish. This creates a massive bottleneck when agents are executing long-horizon tasks, such as solving software engineering tickets, which can take anywhere from seconds to hours.

PrimeRL implements a fully asynchronous architecture where training and inference run as decoupled processes. The model continuously updates its weights from completed batches, allowing the system to run up to 16 steps off-policy without losing training stability.

Customizing the Objective Function

Developers can easily implement custom objective functions. Here is how to configure a training script in PrimeRL using a registry-registered Group Relative Policy Optimization (GRPO) setup:

from primerl.trainers import AsyncRLTrainer
from primerl.configs import TrainerConfig

# Configure an asynchronous trainer targeting a distributed cluster
config = TrainerConfig(
    base_model="deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
    algorithm="grpo",
    learning_rate=1e-6,
    batch_size=128,
    async_off_policy_limit=16,
    use_fp8=True
)

trainer = AsyncRLTrainer(config)
# Starts asynchronous training loop alongside separated inference engines
trainer.fit()

By leveraging asynchronous parallel processing and FP8 quantization, Prime Intellect's stack can run large-scale RL runs on giant models over multiple nodes in days rather than weeks, offering a cost-effective path to state-of-the-art agent performance.


Tips & Gotchas

  • Mind the Variance in Length: Agents will naturally write longer and longer outputs to maximize reward. Always implement a length penalty or group comparison reward to keep inference costs under control.
  • Run Local First: Use the verifiers CLI to run small-scale evaluations locally on your laptop before pushing your task sets to expensive multi-node GPU clusters.
  • Stateful Tooling: When building environments that involve multi-turn tool calling, ensure your runtime (like Docker) isolates filesystem state between rollouts to prevent cross-contamination.
Topic DensityMention share of the most discussed topics · 18 mentions across 6 distinct topics
PrimeRL
28%· products
Verifiers
28%· products
Renderers
17%· products
Docker
11%· products
Prime Intellect
11%· companies
Will Brown
6%· people
End of Article
Source video
Prime Intellect unveils new open toolkit for training custom agentic models

Modern Post-Training: A Deep Dive — Will Brown, Prime Intellect

Watch

AI Engineer // 46:52

We turn high signal in-person events for the top AI engineers, founders, leaders, and researchers in the world into the best free learning opportunities for millions around the world here on YouTube. Your subscribes, likes, comments, speaking, attendance, or sponsorships goes a long way toward making our biz model sustainable indefinitely. We strongly believe this industry deserves a better class of community and that we know how to do this well; we just need your support.

Who and what they mention most
Anthropic
26.9%21
Claude
21.8%17
OpenAI
19.2%15
Cursor
15.4%12
6 min read0%
6 min read