HyperHarness: Learning to Generate Personalized Agent Harnesses from User Histories

Zhaoxuan Tan, Jiachen Zhao, Jingbo Yang, Zheyuan Liu, Chuhan Wang, Pei Zhou, Mengting Wan, Meng JiangarXiv 2026

Imagine you’re trying to build a digital assistant that actually knows you. Not just your name, but the fact that you hate fight promotions, love Spanish family comedies, and recently started a DIY home repair project.

To do this, an AI agent needs a "harness"—the code and instructions that decide which parts of your massive digital history to remember and how to use that info to answer your questions. Usually, developers face a nasty choice: give everyone the same generic harness (efficient but "dumb") or spend a fortune in compute time to custom-build a harness for every single user (smart but incredibly slow).

Enter HyperHarness.

TL;DR

HyperHarness is a framework that teaches an AI to write custom "operating instructions" (harnesses) for other AI agents based on a user's specific history. It provides the "best of both worlds": the high performance of a custom-tailored system with the lightning-fast deployment of a generic one, cutting token costs by over 90% while actually improving accuracy.

What Problem Does This Paper Address?

The core challenge is procedural personalization. It’s not just about what the AI says; it’s about the execution procedure it uses to get there.

Currently, we have two extremes:

  1. Shared Workflows: Every user gets the same retrieval logic (e.g., "always grab the last 10 things they said"). This is fast but ignores that some users have stable tastes while others have rapidly shifting interests.
  2. Per-User Optimization: The system tries out dozens of different retrieval strategies for you specifically until it finds one that works. This is great, but it’s a computational nightmare to do at scale.
Figure 1: HYPERHARNESS bridges shared workflows and per-user search with a history-to-harness generator for zero-search deployment.

HyperHarness aims to bridge this gap by learning a "generator" that can look at a user's history and—in one single pass—write the perfect Python code to handle that specific user's data.

Methods

The authors treat harness generation as a meta-learning problem. Instead of optimizing a harness for User A, they optimize a Shared Generator.

  • The Generator: This is an LLM prompted to act as a "construction worker." It analyzes a user's history and writes executable Python functions for two tasks: recall (how to find relevant info) and apply (how to guide the answering model).
  • Iterative Refinement: During training, the system looks at how well the generated harnesses performed on actual tasks. If a harness failed, the "Agent Optimizer" tweaks the generator's instructions so it does better next time.
  • Zero-Search Deployment: Once the generator is trained, it’s "frozen." When a new user shows up, the generator writes their custom harness instantly. No repeated searching or expensive trial-and-error is needed at runtime.
  • Safety First: Because the system is literally writing and running code, it uses a restricted Python sandbox (AST validation) to ensure the generated harnesses can't do anything malicious or crash the system.
Figure 2: Overview of HYPERHARNESS. Given a user’s permitted history, a shared generator organizes historical evidence and prompts a frozen construction LLM to synthesize executable retrieval and answer-guidance code. Downstream task scores across training users guide iterative updates to the generator specification, after which the frozen generator constructs personalized harnesses for unseen users directly from their histories without per-user search.

Datasets

The researchers put HyperHarness through its paces on three diverse benchmarks:

  • PersonaMemv3: Tests personalized assistant tasks like recommendations and handling evolving preferences.
  • Mem-PAL: Focuses on selecting solutions based on long-term user preferences.
  • MemoryCD: A "cross-domain" challenge where the AI must use a user's history in Books or Electronics to help them with Home-related tasks.

Key Insights and Ideas

  • Filtering is Better than Packing: One of the biggest "aha" moments was that simply giving an LLM a massive context window (Long Context) often hurts performance because the model gets distracted by "noisy" or irrelevant history. HyperHarness wins by learning exactly what to ignore.
  • Model-Dependent Tailoring: The system discovered that different "answering models" need different harnesses. For example, a massive model like GPT-5.6-Luna might only need concise preference cues, whereas a smaller model like Qwen-9B performs better when the harness provides rich, explicit historical context.
  • Amortized Costs: While training the generator costs tokens upfront, it pays for itself incredibly quickly. For most tasks, HyperHarness becomes more cost-effective than per-user optimization after serving only 9 to 35 users.

Key Results

  • Top-Tier Performance: HyperHarness achieved the highest scores in 7 out of 9 experimental settings, beating out strong baselines like BM25 and specialized memory agents.
  • Massive Efficiency Gains: Compared to "Long Context" prompting (just stuffing everything into the prompt), HyperHarness reduced the number of tokens used at answer-time by 90.32%.
  • Robustness: Even when user history was "noisy" or 90% of it was missing, the trained harnesses remained resilient, often outperforming full-history baselines by focusing on the most recent, relevant signals.

Limitations and Future Work

The authors are transparent about a few hurdles:

  • Interface Bounds: Currently, the harnesses operate within specific "hooks" (retrieval and guidance). They haven't yet tested completely unrestricted agent workflows.
  • Stochasticity: Because the generator is an LLM, the code it writes can vary slightly. While they use validation checks, the process isn't 100% deterministic.
  • Security: Deploying generated code in production requires very strict access controls and sandboxing, which adds a layer of engineering complexity.

In short, HyperHarness suggests that the future of personalization isn't just about bigger models or more data—it's about AI that's smart enough to write its own custom software to understand you.

Summary updated

Abstract

Personalized LLM agents rely on an agent harness, the surrounding memory and control code, to connect user history with downstream decisions. Existing methods typically employ either a single shared memory workflow across all users, which is efficient to deploy but cannot adapt how evidence is retrieved and interpreted across diverse histories, or per-user harness optimization, which customizes behavior for each user but requires costly repeated candidate evaluation at deployment and suffers from sparse, noisy supervision in raw logs. To address this trade-off, we present HyperHarness, a framework that learns a shared history-to-harness generator to synthesize executable, user-specific retrieval and answer-guidance code directly from user histories. Given a user's permitted history, HyperHarness prompts a construction LLM to write personalized retrieval and guidance functions, while downstream task scores across training users supervise iterative refinements to the shared generator without reference harnesses or answering-model updates. At deployment, the frozen generator constructs a harness for each unseen user in a single pass from history alone, eliminating per-user task-scored search. Across three benchmarks (PersonaMemv3, Mem-PAL, and MemoryCD) and three answering models (Qwen3.5-9B, Qwen3.8-27B, and GPT-5.6-Luna), HyperHarness achieves the highest aggregate score in seven of nine settings and ranks second in the remaining two, improving over the strongest baselines by up to 5.95 points while cutting matched answer-time tokens by 90.32% over long-context prompting. Analyses show that optimization tailors context allocation to each executor, transfers to unseen user clusters, and amortizes adaptation costs.
BibTeX
@misc{tan2026hyperharness,
  author = {Zhaoxuan Tan and Jiachen Zhao and Jingbo Yang and Zheyuan Liu and Chuhan Wang and Pei Zhou and Mengting Wan and Meng Jiang},
  title = {{HyperHarness: Learning to Generate Personalized Agent Harnesses from User Histories}},
  year = {2026},
  eprint = {2611.29062},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.29062},
}
Figure