Source-linked AI summary

Paritok-4B: Intent-Conditioned Context Compression for Coding Agents

Jiayu Shi, Luzhuo Chen

arXiv:2608.24188v1cs.AIcs.CLcs.LGcs.SE

TL;DR

Coding agents repeatedly resend file reads and tool outputs, making context a major token-cost target, while prose-oriented compression does not fit code’s need for exact strings and changing task relevance. Paritok-4B uses intent-conditioned extractive selection and compresses context to roughly a quarter of its size while retaining much of single-shot solve quality. Its benchmark measures comprehension under compression rather than end-to-end multi-turn agent cost.

  • Problem

    Coding-agent context dominates token costs, but prose-oriented prompt compression is poorly suited to preserving exact code strings and task-dependent relevance.

  • Method

    Paritok-4B performs intent-conditioned extractive context selection one segment at a time, preserving original spans instead of rewriting them.

  • Results

    On SWE-bench Lite, Paritok-4B compresses context to roughly a quarter of its size while retaining 86.5% of single-shot solve quality, or 89.3% with line-numbered input.

  • Takeaways & Limitations

    The benchmark supports substantial context reduction without a significant paired solve-rate loss at 300 instances, while deployment uses a self-hosted adapter with no per-token compressor fee.

  • Takeaways & Limitations

    Identifier retention is not guaranteed: roughly 60% of identifier-like tokens in an input segment do not survive compression, so deployments should check target identifiers and fall back when needed.

Abstract

from arXiv · show

Coding agents re-send large file reads and tool outputs to a frontier LLM every turn, and this context dominates their token bill. General-purpose prompt compressors are trained on prose and suit code poorly: they paraphrase identifiers and drop the exact spans an agent needs to edit. We present Paritok-4B, a 4B LoRA compressor for coding-agent trajectories built on two commitments. It is extractive: it selects spans rather than rewriting them, and 96.0% of the identifiers, paths, and numbers it emits already appear in its input, holding at 96.2% on held-out SWE-bench Lite output. It is intent-conditioned: told the agent's current task, it acts chiefly inside a retained segment, selecting which lines survive (retained lines are +0.067 more intent-relevant than removed ones, paired 95% CI [+0.056, +0.078]) rather than changing how much is retained. We distil a gpt-4.1-mini teacher over 67,074 real OpenHands trajectories into 40,606 validated examples and fine-tune Qwen3-4B. On all 300 SWE-bench Lite instances, Paritok-4B compresses agent context to 25.7% of its size, 2.0x harder than a gpt-4.1-mini compressor (50.2%) and 2.4x harder than gpt-5 (61.9%), while retaining 86.5% of uncompressed single-shot solve quality. Fed the cat -n line-numbered input real agents produce, it compresses slightly less (27.8%) and retains more (89.3%); there the paired test is informative, with 30 instances solved only uncompressed and 17 only compressed, an exact McNemar p=0.079, so at this sample size compressing context to roughly a quarter of its size does not significantly reduce the solve rate. The model is a 264 MB adapter that self-hosts on one 24 GB GPU with no per-token compressor fee, which at list prices decides the economics: gpt-5 as a compressor is net-negative, costing more than the downstream tokens it saves. Weights, data, and evaluation scripts are open (Apache 2.0).

1 Introduction

Paritok-4B is an extractive, intent-conditioned compressor designed for coding-agent context, preserving exact strings while selecting content relative to the agent’s current task. It combines these commitments with a trajectory-based training and evaluation pipeline aimed at aggressive compression without sacrificing solve quality.

  • Motivation: Coding-agent compressors must preserve exact strings, account for task-dependent importance, and handle heterogeneous segments rather than apply one uniform ratio.The relevant inputs include code, tracebacks, listings, and reasoning, whose value changes with the agent’s current task.
  • Contributions: Paritok-4B selects spans instead of rewriting code and tool output, with 96.0% of emitted identifier-like tokens already present in the input.The corresponding figure is 96.2% on held-out SWE-bench Lite output.
  • Contributions: Its intent-conditioned design receives the current task or query and prioritizes entities named by that intent when deciding what to retain.This defines importance relative to the agent’s live intent rather than statically.
  • Limitations: The four-level importance-label mechanism is reported as a design that did not deliver its intended behavior because distilled targets realized only two effective bands.This mechanism is part of the pipeline but not one of the paper’s two claimed commitments.
  • Contributions: The model is trained on real coding-agent trajectories through a pipeline producing 40,606 teacher-validated compression examples from 67,074 raw OpenHands trajectories.The pipeline also assigns intent-conditioned, level-labeled, must-keep-annotated targets.
  • Contributions: On SWE-bench Lite, Paritok-4B reaches a 25.7% compression rate at comparable single-shot solve quality, roughly twice as aggressively compressed as strong GPT compressors.The reported evaluation covers raw-source and line-numbered regimes, with no paired degradation resolvable at 300 instances.

2 Related Work

Prior prompt compressors target prose with task-agnostic token selection, whereas Paritok-4B adapts extractive compression to typed agent segments and explicit task intent. The paper therefore emphasizes end-to-end comparisons under a shared coding-agent evaluation rather than a potentially mismatched head-to-head protocol.

  • Prompt compression: LLMLingua and Selective Context use perplexity signals to drop low-information tokens, while LLMLingua-2 distils GPT-4 into an extractive token-classification compressor.These methods are presented as prompt-compression approaches developed for prose or passage-level inputs.
  • Prompt compression: Paritok-4B differs by compressing typed agent segments with explicit task-query and importance-level conditioning, trained on agent trajectories rather than documents.Its design treats the agent’s current intent as available information for deciding what to keep.
  • Comparison boundary: The paper omits a direct LLMLingua-2 comparison because the systems require different inputs and express different actions, including whole-segment drops.It identifies same-context, same-downstream-agent end-to-end measurement of tokens and solve rate as the relevant future comparison.
  • Coding agents and benchmarks: The training data come from trajectory corpora containing the file reads, tool results, and histories seen by deployed agents, including cat -n framing and tool wrappers.These inputs differ sharply from raw source files.

3 Task Formulation

Paritok-4B formulates coding-agent context compression as intent-conditioned, extractive selection over typed segments. The design supports parallel, incremental, recoverable compression while preserving exact code and tool-output spans under explicit structural and rewriting rules.

  • 3 Task Formulation: A coding-agent request is represented as an ordered sequence of typed segments, and each compressible segment is processed using the current task plus its kind and importance level.The gateway performs segmentation, kind classification, and level labelling before model invocation.
  • 3 Task Formulation: Per-segment compression keeps model calls short, enables parallel and incremental processing, and preserves a direct mapping from compressed units to original segments.The median prompt is approximately 4K tokens, allowing a 4B model with a 16K window to suffice.
  • 3 Task Formulation: The intended hierarchy assigns budgets of ≤0.50, ≤0.35, ≤0.25, and ≤0.20 to protected, recent, mid-history, and stale levels respectively.These levels cover protected prompts and recent results, recent reads and actions, mid-history reads and reasoning, and stale superseded context.
  • 3 Task Formulation: The realized targets collapse the intended four-level hierarchy into two effective bands, so the specified four-way budget split does not survive training.The reported asymmetry is between protected/recent and stale context, but at half the specified resolution.
  • 3 Task Formulation: The output reuses each input seg_id inside structural markers, allowing the gateway to map compressed spans back to their origins and recover untouched bytes.Dropping an entire segment is a first-class action for unrelated helpers, build noise, and superseded re-reads.
  • 3.1 What “extractive” means here, precisely: Extractive compression selects and deletes spans rather than freely generating replacements, using a closed vocabulary of structural markers for removed content.Markers carry counts and names taken from the input, and any marker outside the enumerated vocabulary is a format violation.
  • 3.1 What “extractive” means here, precisely: Retained code lines, identifiers, paths, line numbers, imports, error text, commands, and edit payloads are copied in full, while a few content types permit bounded rewriting.Permitted rewriting includes selected long literals, assistant_thinking, meta_action plans, mid-docstrings, and JSON tool calls.
  • 3.1 What “extractive” means here, precisely: 96.0% of emitted identifier-like tokens appear in the input across the distilled corpus, rising to 98.3% without assistant_thinking and reaching 96.2% on held-out SWE-bench Lite output.On the held-out instances, 92.2% of lines are byte-identical and the median per-instance token-copy rate is 97.0%.

4 Data Pipeline

The pipeline converts real OpenHands trajectories into validated, intent-conditioned compression examples through scripted filtering, labeling, pooling, and teacher distillation. Its audits show that the intended four-level control collapses into two effective bands, while intent mainly selects lines within retained segments.

  • Data construction: 67,074 OpenHands trajectories are processed into a reproducible distillation pipeline, with 40,606 teacher-validated compression examples after filtering and validation.The source data come from real GitHub-issue resolution trajectories, while SWE-bench Lite is held out for evaluation.
  • Segmentation and filtering: File reads preserve literal cat -n framing, and long segments or requests are split or truncated at line boundaries during filtering.Samples retain real agent input structure rather than replacing line-numbered reads with raw file text.
  • Labeling and distillation: Teacher targets are distilled per segment with prompts conditioned on agent intent, segment level, compression budget, and must-keep spans.Separate teacher prompts are used for file_read and other segment kinds, with validated targets produced through the OpenAI Batch API.
  • Level-design audit: The L0–L3 design does not yield four distinct compression levels: realized targets form two effective bands, with protected/recent segments near 0.40 and stale segments near 0.20.The level-boundary probabilities and drop rates show that only the L1/L2 boundary separates reliably.
  • Level-design audit: The failed level control reflects both teacher targets that collapse four budgets into two bands and a student interface that hides the numeric budget behind a level tag.The proposed v2 fix is to pass the token budget explicitly and derive it from the teacher’s realized distribution.
  • Intent audit: Intent conditioning is weak at segment survival but stronger within retained file reads, where kept lines are +0.067 more intent-relevant than removed lines.The paired 95% confidence interval is [+0.056, +0.078], and this within-segment comparison controls for several confounds.

5 Training

Training builds Paritok-4B as a compact extractive compressor, with backbone selection constrained by deployment memory and checkpoint selection based on held-out behavior rather than training loss. Drop supervision weighting backfired, so the released model uses a conservative keep-biased policy.

  • Training setup: 264 MB is the resulting adapter size from Qwen3-4B LoRA training.The model uses bf16 training, 8-bit AdamW, gradient checkpointing, and a single-GPU setup.
  • Training dynamics: Training loss plateaued below 0.09, with token accuracy near 0.975 and one transient spike peaking at 0.177 around step 1,130.The spike recovered within roughly 100 steps and corresponded to unusually long file-operation targets.
  • Backbone selection: The 4B backbone was selected because 7B exceeded the single 24 GB GPU deployment envelope.The comparison also found no realized code-pretraining advantage for this span-copying, intent-driven task.
  • Drop supervision: Weighting drop examples by 20 caused 42–47% drop accuracy, below the 59% always-keep baseline, so the shipped model uses weight 1.The intervention over-dropped across every checkpoint; duplication of drop samples performed worse at high multiples.
  • Checkpoint selection: The released step-2,000 checkpoint was chosen behaviorally despite step 2,200 being marginally best on aggregate metrics.Steps 2,000–2,400 were near-equivalent intrinsically, while the final checkpoint had better teacher agreement but worse compression and drop recall.

6 Evaluation

Evaluation shows aggressive compression with substantial retained single-shot solve quality, but the harness measures comprehension rather than full multi-turn agent economics or exact-match editing. Line-numbered input improves retained quality while reducing compression slightly, and cost comparisons favor local self-hosting over API compression.

  • Intrinsic evaluation: 100% of segments produced a well-formed single [SEG] output, with a Wilson 95% CI of [0.963, 1.000].Malformed outputs cannot be safely spliced into an agent request and require fallback to the original.
  • Intrinsic evaluation: Drop accuracy was 0.49 with drop recall 0.24, below the 0.59 always-keep baseline because the model misses roughly three-quarters of teacher-dropped segments.This under-dropping is the main remaining compression headroom.
  • Evaluation scope: The harness is single-shot: one no-tool API call receives oracle file context and produces a unified diff scored by the official SWE-bench harness.Thus the quality results are a floor on comprehension under compression, not an end-to-end agent-cost claim.
  • End-to-end evaluation: 86.5% of uncompressed single-shot solve quality is retained on raw source, while cat -n input yields 27.8% compression and 89.3% retained quality.The line-numbered regime matches the framing used by real agents and is the recommended configuration.
  • End-to-end evaluation: The paired SWE-bench comparison found 30 instances solved only uncompressed and 17 only compressed, with exact McNemar p=0.079.At 300 instances, this does not significantly resolve a paired solve-rate reduction.

7 Discussion and Limitations

The discussion links extractive selection with intent conditioning as the basis for aggressive, task-aware compression while documenting practical deployment safeguards and unresolved limitations. The main boundaries are under-dropping, identifier loss, line reflow, Python-heavy training, absent level control, and single-shot evaluation.

  • Discussion: Extractiveness preserves exact-string-match safety, while intent conditioning selects verbatim spans relative to the agent’s current task.Together, these choices support aggressive compression without a proportional quality loss in the reported setting.
  • Limitations: Roughly 60% of identifier-like tokens are discarded by design, so deployments should check for the current target identifier and fall back to the original segment when absent.The gateway’s read_original path provides byte-exact recovery.
  • Limitations: Drop recall of 0.24 and drop accuracy of 0.49 versus the 0.59 always-keep baseline leave under-dropping as the dominant known gap.The failed loss-weighting intervention worsened rather than improved this behavior.
  • Limitations: Occasional line reflow of retained signatures can break exact-match edits unless the gateway realigns the output.Removing this issue requires training data that never reflows retained code.
  • Limitations: Version 1 is trained on SWE-bench-style Python repositories, leaving other languages unbenchmarked despite a language-agnostic architecture.Its heuristics and constants are Python-tuned.
  • Limitations: The four-level importance scheme collapses to two effective bands, and deployments cannot currently dial compression with a numeric budget.The model effectively distinguishes protected-or-recent content from stale content.
  • Limitations: The single-shot harness does not measure multi-turn agent cost or exact-match editing, and fuzzy patching can hide some failures.The reported quality therefore bounds comprehension under compression rather than end-to-end agent performance.

8 Conclusion

Paritok-4B compresses coding-agent context to roughly a quarter of its size while retaining substantial solve quality, and the paper releases the materials needed to reproduce its results.

  • 8 Conclusion: 86.5% of uncompressed single-shot solve quality is retained on SWE-bench Lite, rising to 89.3% with line-numbered input.The paired comparison against uncompressed context is not significant at 300 instances (p=0.079).
  • 8 Conclusion: Roughly a quarter of agent context is retained while preserving the reported solve-quality levels.The conclusion summarizes this operating point as the central compression result.
  • 8 Conclusion: The weights, five-stage data pipeline, training configurations, audit scripts, intrinsic evaluation harness, and end-to-end SWE-bench harness are released under Apache 2.0.The release includes the components behind the paper’s reported numbers.
  • 8 Conclusion: Cached outputs allow line-numbered compression rates and held-out extractiveness figures to be rechecked without rerunning compression.The audit path requires no GPU or API calls for these two checks.
Loading 2608.24188v1…