Manuscript Offprint

arXiv:2609.30967

MoMHa: Multi-Objective Optimization of LLM Harnesses over Accuracy, Safety, and Tokens

Subhojyoti Mukherjee, Md Mehrab Tanjim

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Most work on improving large language models treats accuracy as the sole objective. We argue that the harness, the Python code surrounding the model that constructs prompts, routes calls, and parses outputs, is a first-class design surface whose quality is inherently multi-objective: an accurate harness that refuses no unsafe request, or that consumes an order of magnitude more tokens, is not a good harness. We present META-HARNESS, a system that casts harness design as search over three per-domain objectives (accuracy, behavioural safety, and token cost) solved by an agentic proposer (CLAUDE CODE) with full filesystem access to prior harness source, execution traces, and scoring artifacts. Our central finding is that a single-phase joint-reward proposer (MoMHa) outperforms every alternative, including a two-phase “accuracy then tokens” ablation, scalar-only feedback, and an accuracy-only baseline. We evaluate on seventeen domains: seven synthetic capability suites, seven real-world public benchmarks (HumanEval, MBPP, Spider, FEVER, MMLU-Pro, LawBench, NuminaMath), and three U-SafeBench-derived user-specific safety domains, using a 12-model fleet spanning four families. On the synthetic track MoMHa achieves a joint mean of 0.482 versus 0.198–0.422 for ten baselines, winning 7/10 per-domain columns; on the real-world track it scores 0.461 versus 0.377 for the strongest baseline (DSPy), winning 5/7 columns, demonstrating that harness strategies transfer to unseen benchmarks without retraining on 8 of 12 target models. MoMHa attains the highest measured behavioral safety composite (U-SafeBench, 0.781) and uses 95 fewer tokens per example than the two-phase alternative. We will release all harness code, evaluation infrastructure, and cross-model logs.

1 Introduction

The performance of a large language model on a downstream task depends not only on the model itself but also on the harness: the surrounding Python code that constructs prompts, routes calls, parses outputs, and orchestrates multi-turn interactions. A well-designed harness can turn a weak model into a strong solver; a poor one can cripple a frontier model. Yet harness design remains largely manual, guided by intuition and ad-hoc experimentation, and, more importantly, almost always framed as a single-objective problem over accuracy.

Harness quality is not a scalar. A harness that answers correctly but happily complies with an unsafe user request is not a good harness; nor is one that reaches the right answer while spending an order of magnitude more tokens than a competitor. Real deployments trade off accuracy, safety, and cost simultaneously. Prior work on automatic prompt optimization [Zhou et al., 2023, Pryzant et al., 2023] and DSPy-style program synthesis [Khattab et al., 2024] has demonstrated that programmatic search over LLM interaction patterns yields consistent accuracy gains, but these systems collapse feedback into a scalar reward and ignore safety and token objectives almost entirely.

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

META-HARNESS. We present META-HARNESS, a system that treats harness design as explicit multi-objective search over three per-domain objectives (accuracy, behavioural safety, and token cost) and solves it with an agentic proposer (CLAUDE CODE) given full filesystem access to prior harness source, per-example execution traces, and scoring artifacts. Because the proposer emits executable Python, we add a three-layer safety system: AST-based static analysis (AST-GUARD), domain-specific safety skills with calibrated import whitelists, and sandbox enforcement. Harnesses are then evaluated on seventeen domains: seven synthetic capability suites, seven real-world public benchmarks, and three U-SafeBench-derived user-specific safety domains [In et al., 2025] against a 12-model fleet spanning Claude, GPT, Gemini, and DeepSeek.

Central finding: joint beats two-phase. The natural way to do multi-objective search with an agentic proposer is staged: first optimize accuracy subject to safety, then in a second phase optimize tokens holding accuracy roughly fixed. We implement this as 2-phase and treat it as the strongest ablation. Our headline system, MoMHa, instead exposes all three objectives to the proposer simultaneously in a single phase, and rewards a joint utility R=acc+λssafety−λttokensR = \text{acc} + \lambda_s \text{safety} - \lambda_t \text{tokens}. MoMHa achieves the highest 3D hypervolume indicator (HV=0.481) among all 15 variants, a +0.119 gain over MH (0.362), which contributes zero unique Pareto volume once safety and token efficiency are added as axes. MoMHa also outperforms the 2-phase ablation on 7 of 10 domains by joint metric J, with a mean accuracy composite of 0.611 versus 0.584 at 95 fewer tokens per example. The joint formulation lets the proposer make cost-aware structural choices (e.g. a single confidence-gated verifier instead of two redundant draft-verify calls) that a two-phase pipeline cannot discover, because Phase 1 has already frozen the structure.

MoMHa versus external baselines. The closest baseline is MH [Lee et al., 2026], the only other system that fully rewrites Python harness code via search, but MH optimizes accuracy only, with no safety or token objectives. Moving from MH to MoMHa (i.e., the MOO extension) yields +0.177 in joint mean J (0.482 vs. 0.305) and +21.2 pp in behavioral safety (0.781 vs. 0.569). The remaining eight baselines (CoT, APE, OPRO, DSPy, MIPROv2, TextGrad, GEPA, Rand) are prompt-optimization methods that fix the harness structure and tune prompts only, a fundamentally different search space. AH [Lou et al., 2026] (AutoHarness) also emits full Python harnesses but is single-objective (accuracy only, no safety signal, no Pareto pool).

Against all ten baselines, MoMHa leads on both evaluation tracks. On the synthetic track MoMHa achieves a ten-domain joint mean J=0.482J=0.482 versus 0.198–0.422 for ten baselines, winning 7/10 per-domain columns; the nearest rival is TextGrad (0.422, +0.060 in joint JJ). On the real-world track MoMHa scores J=0.461J=0.461 versus 0.084–0.377, winning 5/7 columns; the nearest rival is DSPy (0.377, +0.084 in joint JJ). MoMHa attains the highest U-SafeBench behavioral safety composite (0.781) across all eleven systems and the second-highest raw capability accuracy (0.539; DSPy reaches 0.542 but at 2,229 tokens per example versus MoMHa's 672, which explains its lower joint score). No external baseline clears 0.75 safety.

Cross-model generalization. Strategies discovered on a small Haiku-class proposer-evaluator loop transfer without modification to 8 of 12 target models; on the remaining 4, GPT-5-mini, o4-mini, and DeepSeek-R1 prefer DSPy's terse prompts (which add fewer harness tokens on top of model-internal CoT), while GPT-5.4 goes to GEPA (Section 4.4). Despite these exceptions, the mean cross-model joint score for MoMHa (J=0.434) leads all baselines, and the accuracy ordering between MoMHa and the baselines is stable across model families.

Contributions. (1) Harness search as explicit multi-objective optimization. We cast harness design as multi-objective search over per-domain accuracy, safety, and token cost, solved via a scalarized joint reward, with an agentic proposer that reads traces and edits source (Section 3). (2) Joint reward beats staged optimization. Our central empirical result is that a single-phase joint-reward proposer (MoMHa) outperforms a two-phase accuracy-then-tokens proposer (2-phase) by +2.7 overall points at 95 fewer tokens per example (Section K). MoMHa leads all 15 variants on the 3D hypervolume indicator (HV=0.481 vs. MH's 0.362, Section K). (3) Trace-level feedback is measurable. Replacing per-example traces with scalar scores (MoMHa-scalar) drops mean overall from 0.611 to 0.604 and safety from 0.781 to 0.754, confirming that the proposer extracts causal signal from traces beyond what scores carry (Section K). (4) Safety as a first-class objective. Removing the domain-specific safety skill (MoMHa-ns) drops safety from 0.781 to 0.716 while capability accuracy is largely unchanged, isolating the skill's contribution (Section 4.5). All ten external baselines score below 0.75 on the U-SafeBench composite. (5) Seventeen-domain, twelve-model evaluation. Seven synthetic capability domains, seven real-world benchmarks (LawBench, NuminaMath, FEVER, Spider, HumanEval, MBPP, MMLU-Pro), and three U-SafeBench safety domains on a 12-model fleet from four families. (6) Open artifacts. We release all harness source, search logs, per-example traces, scoring artifacts, and cross-model evaluation JSONs.

Key findings. Overall: MoMHa leads the synthetic-track joint mean (J=0.482 vs. 0.198–0.422 for ten baselines, +6.0 over TextGrad) and the real-world joint mean (J=0.461 vs. 0.084–0.377, +7.9 over DSPy). Capability: mean accuracy across seven skill domains improves from 0.478 (MH) to 0.539 (MoMHa), a +6.1-point gain. Safety: U-SafeBench behavioral safety composite improves from 0.569 (MH) to 0.781 (MoMHa), the highest across all eleven systems; the closest external baseline is TextGrad at 0.747. Joint vs. two-phase: MoMHa beats 2-phase by +2.7 overall points while using 95 fewer tokens per example. Hypervolume: MoMHa attains HV=0.481 (highest of 15 variants); MH scores 0.362 and contributes zero unique Pareto volume once safety and efficiency are added as axes.

References (33)