Building capable AI agents—those that can browse the web, write code, or solve complex math—requires high-quality "trajectories." These step-by-step records of an expert or high-capacity model solving a task are incredibly expensive to produce, costing anywhere from $8 to $100 per task due to manual curation and complex environment setups.
Despite this massive investment, creators currently lack mechanisms to protect their intellectual property. Once a trajectory dataset is released, it is vulnerable to unauthorized use in training commercial models. Traditional watermarking techniques designed for plain text or static code fail on agent data, which consists of small, interleaved sequences of model actions and environment observations. To address this critical gap, researchers have introduced ActHook, the first watermarking framework designed specifically for LLM agent trajectory datasets.
The ActHook Framework: Behavioral Over Syntactic Watermarking
Inspired by software engineering "hooks" that intercept system behavior, ActHook shifts the paradigm from syntactic watermarking (changing how a model speaks) to behavioral watermarking (changing what a model does).
ActHook injects subtle, non-disruptive "hook actions" into the training data. These actions do not alter the original task outcome and are triggered only when a secret activation key—such as a neutral phrase like "It is a thorny issue"—is included in the prompt. Hooks generally fall into two categories:
- Standalone Hooks: Simple, independent actions, such as running a
pwdcommand to check the current directory. - Contextual Hooks: Actions that make sense within the immediate context, such as running
ls -laimmediately after a file is created.
To maintain stealth, an auxiliary LLM generates diverse phrasing for these hooks, preventing them from being easily detected or stripped by simple pattern-matching filters.
Strategic Placement and Black-Box Detection
A critical insight of ActHook is the strategic placement of these watermarks. Researchers found that LLMs are most receptive to learning new patterns at action boundaries—the exact moment the model decides which tool to use. Because these decision points exhibit high "token entropy" (uncertainty), the model learns the watermarked behavior highly effectively, even from datasets as small as 1,000 samples.
To detect unauthorized use, the data owner queries the suspect model with a set of prompts. By comparing the frequency of the hook action when the secret activation key is present versus when it is absent, the owner can identify a significant statistical gap (measured via a t-test). This gap serves as reliable, black-box proof of data theft.
Experimental Results and Robustness
ActHook was evaluated across three diverse agent domains: mathematical reasoning (MATH), web searching and question answering (SimpleQA), and software engineering (SWE-Smith). Tests were conducted primarily on the Qwen-2.5-Coder series (3B, 7B, and 14B) and Llama-3.1-8B. The results demonstrate significant promise:
- High Detection Accuracy: On the Qwen-2.5-Coder-7B model, ActHook achieved an average Area Under the Curve (AUC) of 94.3, demonstrating an almost perfect ability to distinguish between models trained on watermarked versus unwatermarked data.
- Negligible Utility Loss: The model's "Pass@1" performance remained virtually unchanged. The agent retains its full problem-solving capabilities while successfully adopting the hidden watermark.
- Robustness to Attacks: Because ActHook relies on behavioral intent rather than specific syntax, it proved highly resilient to removal attacks. The watermark survived aggressive paraphrasing of the dataset, summarization (hiding full tool outputs), and even bypassed DeCoMa, a state-of-the-art tool designed to strip code watermarks.
Limitations and Future Directions
While highly effective, ActHook has some limitations. Smaller models, such as the 3B parameter version, occasionally struggled with complex software engineering tasks, lacking the "spare capacity" to perfectly learn both the primary task and the watermark. Additionally, while contextual hooks are stealthier, they proved slightly harder for models to learn than standalone hooks.
Future research will explore even more natural hook actions that blend seamlessly into an agent's reasoning chain. The authors also plan to extend the framework to protect multi-agent environments, where interaction patterns are significantly more complex.
Summary updated