Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Artificial Intelligence
12 min read

HyperHarness: Per-User Generated Harnesses for Personal Agent Memory Retrieval

HyperHarness generates personalized Python harnesses for each user to control memory retrieval in personal agents, using a shared generator trained on other users; the code decides search queries, filtering, and answer guidance, but a fixed character budget can cause planned searches to be skipped, as shown when a user's negative-feedback search was omitted because the first search exhausted the budget.

One Harness Per User: How It Is Generated

Personal agents typically store user history in a memory bank and retrieve it at answer time. A single shared workflow — fixed top‑k BM25, rolling summaries, or stuffing recent history into the context window — ignores the fact that each user’s signal density differs. HyperHarness (arXiv:2611.29062v1, open‑sourced by Notre Dame, UCSB, and Microsoft) moves the per‑user optimization earlier: it trains a shared generator on a set of training users, then freezes it. For a new user, the frozen generator reads only that user’s permitted history and emits a personal Python program that sits between the memory bank and the frozen answer model. The answer model’s weights never change.

The generator can modify four shared files during training: generator.py – history‑preparation script prompt.md – build prompt for the generator model backbone.py – shared execution skeleton generation_policy.json – budget and policy configuration

Training uses gpt-6-sol as the optimizer/builder model. Each candidate generator is evaluated on the training users (25 users in PersonaMemv3 main experiment, 75 held‑out test users). Per‑user scores are averaged with equal weight per user, so users with more tasks do not dominate. Only if the mean score improves is the new generator adopted. Test‑user data never enters the build process. [1]

When building a personal program, the generator sees a cleaned history. For user 52, explicit dislikes, light interactions, self‑posts, and skimmed posts are separated; the prompt notes that a single skim under a common tag is only a weak signal. The generated code must contain at least one function reachable from the entry point — a static profile JSON is rejected. [1, Appendix E Tables 8–10]

从训练到回答
从训练到回答

Sandbox Boundaries: What the Personal Code Can Touch

The paper assigns three roles: Host controls data access and execution limits; Optimizer may modify the shared backbone during training; Builder model fills only the per‑user slot in the backbone. In the PersonaMemv3 configuration:

Personal code can define functions, use for loops over results.

No imports, file I/O, or network access.

Each hook call limited to 40,000 interpreter steps.

Zero model‑call budget during retrieval. [1, Appendix E Tables 10, 12]

The shared backbone ( backbone.py) is the only layer the optimizer may change during training. After training it becomes read‑only for the builder, leaving a single #@USER_SECTION@# slot. [2]

Inside that slot the user may define USER_MODEL and functions/constants prefixed with user_ or u_. An edit‑permission experiment in the repo shows the boundary: validate_program() compares the shared AST; changes to shared functions are rejected (whitespace/comments ignored). Personal functions may call shared helpers but cannot read shared constants directly. A custom u_recall must be enabled by a switch inside USER_MODEL. [1][2][4]

How the Code Queries Memory: The Recall Loop

Using the default PersonaMemv3 + Qwen3.5‑9B path, recall() is invoked repeatedly by the host. Each call receives a stage and step.

Step 0 (context) : user_route() returns query terms, top_k, and optional per_record length limit. The backbone returns search, prompting the host to run one BM25 keyword search over the observations collection. Remaining queries and a view name for recent records are stored in state for the next round.

Results return : collect() deduplicates by record ref, filters with user_keep(), truncates to remaining space. The default path processes queued searches first, then falls back to SQL for recent records (e.g., last 10 calendar entries in reverse chronological order). It returns finish plus the assembled history text and the source_refs actually used.

Answer stage : The backbone passes a boolean “any sourced record retrieved?” to user_guidance() as its third argument. The guidance function can still read preferences written into USER_MODEL at build time. The backbone merges task instruction and personal guidance, truncates to 800 characters. Appendix Table 14 shows the two messages sent to the answer model: system message contains guidance + retrieved history; user message contains the original request and candidate list. [1][2]

Why the Second Search Never Ran: A Budget Case Study

User 52’s user_route() produced two query groups: first for liked Spanish family comedies and dance, second for disliked ONE Championship MMA and dog‑grooming challenges ( top_k: 18). No per_record limit was set, and user_keep() only checked for non‑empty text. The shared backbone enforces a hard budget: BACKBONE['retrieval']['max_chars'] = 11,000. After each search, collect() accumulates length and decides whether to take the next query:

collect(state, rows)
if state['queries'] and state['size'] < BACKBONE['retrieval']['max_chars'] - 1:
    query = state['queries'][0]
    state['queries'] = state['queries'][1:]
    return search(query, state)

The author’s execution log shows the first search returned three records totaling 10,999 characters . The second query stayed queued. NDCG@5 for this question was zero — the positive example did not reach the top five. The model still saw the negative‑preference guidance text, but never received the records that the second search would have fetched. [1][2]

To isolate the effect of per_record, the author ran the public

backbone.py
recall

locally with a fixed first‑round return of three 4,000‑character mock records and one queued negative‑feedback keyword, varying only per_record:

Per‑record limit: Unlimited – Concatenated length: 10,999 chars – Next action: Finish retrieval

Per‑record limit: 1,000 chars – Concatenated length: 3,002 chars – Next action: Issue second search

给第二次搜索留多少空间
给第二次搜索留多少空间

With no limit, the three records kept 4,000, 4,000, and 2,997 characters (the backbone counts one delimiter per record, hitting 11,000 internally; final join uses two newlines → 10,999). Setting a 1,000‑character cap left room for the second search. Whether ranking actually improves would require a full rerank. [1]

Across all 70 test questions for user 52, the optimized generator lifted the overall score from 50.29 to 56.30 and average NDCG@5 from 14.50 to 30.50. The appendix example simply illustrates the budget mechanic; it does not prove the second search would have fixed this particular ranking. [1]

Token Cost: Build Once, Amortize Over Many Requests

HyperHarness was evaluated on three benchmarks (PersonaMemv3, Mem‑PAL, MemoryCD) with three frozen answer models (Qwen3.5‑9B, Qwen3.8‑27B, GPT‑5.6‑Luna) against seven baselines (Long Context, BM25, Rolling Memory, Mem0+RAG, Codex CLI, GEPA, Meta‑Harness). It placed first in 7 of 9 configurations, second in 2, only trailing GEPA on Qwen3.8‑27B. The smaller Qwen3.5‑9B benefited most: +5.95 on PersonaMemv3, +3.39 on Mem‑PAL over the strongest baseline. [1]

DAIR.AI cited a “90.32% token reduction” on MemoryCD (223 users, 2,676 requests, Qwen3.5‑9B): Long Context averaged 32,512 tokens/question; HyperHarness used 3,147. That 90.32% only counts the answer phase — the one‑time build cost is excluded. [1][5]

Paper Table 1 reports deployment token Tdeploy (build + execution tokens per user, divided by that user’s request count, then user‑weighted average). Units: thousand tokens/request. Scores are each benchmark’s own composite, comparable within a row. [1]

PersonaMemv3 (Qwen3.5‑9B) : HyperHarness Score / Tdeploy = 54.51 / 2.07k; BM25 Score / Tdeploy = 46.79 / 4.42k; Long Context Score / Tdeploy = 48.56 / 38.23k

Mem‑PAL (Qwen3.5‑9B) : HyperHarness Score / Tdeploy = 32.77 / 11.82k; BM25 Score / Tdeploy = 27.43 / 5.02k; Long Context Score / Tdeploy = 28.96 / 32.72k

MemoryCD (Qwen3.5‑9B) : HyperHarness Score / Tdeploy = 35.23 / 4.96k; BM25 Score / Tdeploy = 33.09 / 2.54k; Long Context Score / Tdeploy = 34.94 / 32.51k

On PersonaMemv3, HyperHarness uses less than half the tokens of BM25 while scoring 7.72 points higher. On Mem‑PAL and MemoryCD it still wins on score but consumes more tokens per request than BM25. The amortization depends heavily on requests per user (averages: 76, 8.16, 12 respectively). The Mem‑PAL row’s 11.82k comes from a separate rerun, not the run that achieved 32.77. [1, Appendix A, B]

Deployment may still require rebuilds. The PersonaMemv3 build config allows up to 7 model calls (6 retries). The host test‑runs the program with synthetic requests; errors (up to 3,000 chars) are fed back to the builder. Only interface/execution errors are available — user answer quality stays in training. An appendix estimate aligning on 200 history records suggests the shared‑training + per‑user‑build approach becomes cheaper than per‑user optimization at roughly 9–35 users, varying by benchmark and comparison method. [1, Figure 6, Appendix E]

Same History, Different Guidance: Model‑Specific Prompts

In 7 of 9 configurations, score gains coincided with shorter answer‑model inputs. On PersonaMemv3 + Qwen3.5‑9B, optimized history text was 28.8% shorter than the initial version while composite score rose from 46.55 to 54.51. [1]

MemoryCD provides a cleaner control: 2,436 paired requests where Qwen3.8‑27B and GPT‑5.6‑Luna received identical history text (avg 10.12k chars). This isolates the guidance added by each personal program. [1, Appendix C.1]

Qwen3.8‑27B : average guidance 577 chars; 87.4% of personal programs read the evidence parameter. Example from Mem‑PAL scheduling: program detects scheduling intent, finds “frequent interruptions” or “fixed meeting times” in retrieved text, returns a 263‑char scheduling reminder; returns empty string if scheduling topic but missing records. [1]

GPT‑5.6‑Luna : average guidance 326 chars; only 3.6% of programs read evidence. One user with 738 comments stored a 1‑to‑5 star histogram [30, 81, 86, 290, 251]. On a rating task, the program computed median 4 stars, noted both low and five‑star ratings were substantial, and advised the model to treat 4 stars as a weak reference and inspect the current item’s attributes. This guidance uses build‑time statistics; the answer model still sees the current retrieval. [1]

When swapping answer models, the old personal guidance should be re‑tested. Lance Martin noted that harness code often embeds assumptions about the model it was optimized for. Here those assumptions were chosen by the optimizer itself. To validate reuse, fix the request and retrieved history, then check whether the guidance still helps the new model. [1][6]

Three Production Checks Before Launch

What remains after a user deletes history? Personal programs are frozen during evaluation. Time‑forward tasks can gradually admit new records; MemoryCD uses a fixed source‑domain history. The 738‑comment user’s star histogram became a constant in the function. Deleting a comment from the store would not update those five integers. To support deletion, record the history version used at build time; on version invalidation, disable the old program and rebuild with still‑permitted records. [1]

Which history should be given to the builder? The authors ran perturbation experiments on 12 users per benchmark with Qwen3.5‑9B and a random seed. On PersonaMemv3, keeping only the most recent 10% of records still beat Long Context and BM25. On Mem‑PAL, deleting 50% of tokens hurt less than replacing them with irrelevant catalog text (the latter dropped 9.16 points). For short preference records, plausible‑looking noise is more damaging than simply having less data. [1, Figures 5, 9]

What happens when the user population shifts? The authors clustered users by history characteristics and held out entire clusters. On MemoryCD + Qwen3.5‑9B, the optimized generator’s score fell from 34.08 to 32.10, below Long Context’s 33.23 — despite winning on the standard split. If a product must recommend across categories or populations, monitor new‑cluster scores separately so overall averages don’t mask regressions. [1, Appendix C Table 4]

Finally, log every retrieval step: query order, adopted record IDs, remaining budget per round, and stop reason. In the user‑52 case, only “three records retrieved” was visible; the planned negative‑feedback search was invisible. With full logs, one can replay two fixes — reserve space for the second query, or cap per‑record length — and measure which yields a higher rank for the positive example. Next time the assistant recommends something the user marked “not interested”, check the retrieval log first: what was searched, which record filled the budget, which query stayed queued. That often pinpoints the cause faster than inspecting a static user profile.

References

[1] Zhaoxuan Tan et al., HyperHarness: Learning to Generate Personalized Agent Harnesses from User Histories, arXiv:2611.29062v1, 2026‑11‑21 (https://arxiv.org/abs/2611.29062v1)

[2] HyperHarness authors’ public implementation, PersonaMemv3 + Qwen3.5‑9B shared backbone backbone.py and build policy generation_policy.json (https://github.com/TamSiuhin/hyperharness-code/tree/4b0e3bf3d3d33df06b7d54c9613b20866d493019/learned/pm3/qwen35-9b/generator)

[3] Yoonho Lee et al., Meta‑Harness: End‑to‑End Optimization of Model Harnesses, arXiv:2603.28052 (https://yoonholee.com/meta-harness/)

[4] HyperHarness authors’ public implementation, three‑layer edit permissions with AST validation harness_permission.py (https://github.com/TamSiuhin/hyperharness-code/blob/4b0e3bf3d3d33df06b7d54c9613b20866d493019/analysis/skill_optimization_diagnosis/harness_permission.py)

[5] DAIR.AI (@dair_ai), HyperHarness paper share and discussion, 2026‑11‑27 (https://x.com/dair_ai/status/2126339269442818297)

[6] Lance Martin, Harnessing Claude's intelligence, Anthropic Blog (https://claude.com/blog/harnessing-claudes-intelligence) and X post, 2026‑04‑02 (https://x.com/RLanceMartin/status/2039783012427333751)

[7] PersonaMem‑v3 authors dataset description, recommendation candidates, time boundaries, and scoring labels (https://huggingface.co/datasets/bowen-upenn/PersonaMem-v3)

For attribution, corrections or content rights, contactadmin@besthub.dev

Report an issue with this article

Discussion 0

Write a comment

Sign in to join the discussion

No public comments on this page. Sign in to comment