One pass over user history yields personalized agent code: best in 7 of 9 tests, 90% fewer tokens

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 Jiang

cs.CL

2026-11-22

A shared generator trained on downstream scores writes each new user's retrieval and guidance code in one pass: best in 7 of 9 settings, 90% fewer answer tokens.

What problem this solves

A personalized LLM agent depends on an agent harness: the surrounding memory and control code that connects a user's history to runtime decisions. Two paradigms dominate. Shared workflows (long-context prompting, fixed top-k BM25 retrieval, uniform rolling summaries) deploy instantly but run one procedure for every user, and user histories vary enough that padding the prompt with more raw records mostly buys cost and distraction. Per-user harness optimization customizes behavior through task-scored search, but every new user triggers another round of candidate generation and evaluation, raw logs mix enduring preferences with temporary intent and incidental exposure, and no ground-truth harness exists to match against. HyperHarness turns this efficiency-versus-adaptation trade-off into something learned.

Method

The design echoes hypernetworks, which generate one network's weights from another; here the generated artifact is executable code. Three layers keep the system modular:

During training, the construction LLM (gpt-6-sol) and the answering model both stay frozen. An optimizer inspects the current spec, the programs synthesized for training users, their task scores, and execution traces, then proposes revisions; a candidate must rebuild harnesses for the training panel and beat the incumbent on mean score, for up to ten rounds. Supervision is downstream task score alone, so no reference harnesses are needed. Static validity checks never see quality scores, and personal code cannot redefine shared entry points. At deployment the generator is frozen: one construction pass over an unseen user's history produces their harness, executed unchanged for every subsequent query, with no per-user scored search.

Results

Across PersonaMemv3, Mem-PAL, and MemoryCD with three frozen answering models (Qwen3.5-9B, Qwen3.8-27B, GPT-5.6-Luna), HyperHarness takes the highest aggregate score in 7 of 9 settings and second in the other two.

SettingBest baselineHyperHarness
PersonaMemv3 × Qwen3.5-9B score48.56 (LongContext)54.51
Mem-PAL × Qwen3.5-9B score29.38 (Meta-Harness)32.77
PersonaMemv3 × Qwen3.5-9B deploy tokens/query38.23k (LongContext)2.07k
MemoryCD answer tokens/query (matched)32.51k (LongContext)3.15k

The multi-step agent baseline Codex CLI is weakest on PersonaMemv3 at 40.41: unconstrained exploration fails to pull stable preference signals from noisy logs. Subcategory gains come from both preference application (51.40 vs 49.87) and restraint (77.74 vs 66.88), so the learned code also decides when personal context should be withheld. Optimization adapts to the executor: 7 of 9 configurations shrink model input while raising accuracy, with +7.96 points and 17.4% fewer input tokens on PersonaMemv3 with Qwen3.5-9B; given identical history on MemoryCD, it steers Qwen3.8-27B toward richer evidence-conditioned guidance and GPT-5.6-Luna toward concise static cues. Shared training cost crosses below per-user search (GEPA, Meta-Harness) after roughly 9 to 35 users.

Why it matters

Two takeaways for anyone building personalized assistants or memory systems. Personalization can live in readable, auditable retrieval and guidance code rather than model weights or longer prompts, and code is easier to inspect than a black-box adapter. Most raw history is also redundant at query time: filtering it programmatically before invoking the answering model cut answer-time tokens by 90.32% in the matched comparison, a real cost lever. The recipe combines known ideas (hypernetwork-style amortization, harness optimization); the contribution is validating the direct history-to-executable-code path across benchmarks and executors.

Limitations

Author-stated: three benchmarks under bounded retrieval-and-guidance interfaces, no unrestricted agent workflows; some cross-method comparisons span slightly different evaluation subsets; robustness tested on 12 users per dataset with a single perturbation seed; optimization and construction are stochastic; case studies lack per-rule ablations; cost comparisons differ in workload scope; deployment requires strict access controls and privacy safeguards.

Some open questions remain. Training cohorts are small (25 users on PersonaMemv3), and generalization rests partly on the cluster-transfer experiment: strong on Mem-PAL and PersonaMemv3 (up to +5.99 and +4.22 over baselines), but on MemoryCD the trained version trails LongContext and Qwen3.5-9B dips below initialization, so specialized retrieval rules overfit when domain shift compounds population shift. Construction and optimization depend on gpt-6-sol, and shared training consumes roughly 24M to 81M rollout tokens. In the case study, two users gain about six points overall with recommendation NDCG@5 nearly doubling, yet NDCG@5 stays at zero on both illustrated slates: single-shot retrieval budgets remain a bottleneck against hard distractors.

Terms

Source

What people are saying

Related papers

All paper explainers