Programmatic Search Agents: Extending Agentic Search Beyond Query Reformulation

Jiaming Qian, Huiyan Yang, Mandi Liu, Jie Liu, Wenkai Shen, Pengyang Zhou, Jing Jin, Jin Ma, Dezhi Ye, Chaochao ChenarXiv 2026

TL;DR

Traditional search agents are limited by fixed interfaces that hide relevant evidence behind "black-box" ranking and extraction pipelines. This paper introduces the Programmatic Search Agent (PSA), which empowers agents to write and execute local code to process, filter, and reuse retrieved candidates, leading to significant gains in task success and a ~30% reduction in token usage.

What Problem Does This Paper Address?

Large Language Model (LLM) agents typically interact with search engines by reformulating queries. However, a fixed search pipeline—which decides which pages to rank and which snippets to extract—acts as a bottleneck. The authors' analysis reveals a startling "evidence-delivery gap": 42.7% of verified supporting passages are never shown to the agent, even when the underlying documents have been successfully retrieved.

When an agent can't see the evidence, it often resorts to redundant, expensive search cycles. The core challenge is that current interfaces leave candidate processing outside the agent's direct control. PSA addresses this by shifting the unit of a search action from a simple "query" to a "programmatic cell" that the agent controls.

Evidence-delivery limitations showing that a substantial fraction of supporting evidence is retrieved but never delivered to the agent.

Methods

The authors propose the Programmatic Search Agent (PSA), which treats search as an iterative execution of code over a persistent workspace.

  • Program Cells: Instead of just sending a query, the agent generates a restricted-Python cell. This cell can compose multiple operations—like retrieving new documents, filtering a previously saved pool, reranking specific candidates, and extracting evidence—all within a single turn.
  • Persistent Candidate Workspace: Unlike standard agents that "forget" candidates not shown in the immediate observation, PSA maintains a background workspace. The agent can revisit, combine, or re-process these candidates in later turns without re-retrieving them.
  • Selective Evidence Presentation: The agent explicitly chooses what information to pull into its main context window (the "observation") and what to keep in the background workspace. This prevents context overflow while keeping the "raw" data accessible.
  • Runtime Execution: A dedicated runtime resolves data dependencies within the cell (e.g., "if I find fewer than $k$ results, retrieve more") before returning control to the LLM for high-level reasoning.
Comparison of Query-based, Tool-based, and Programmatic Search Agents.

Datasets

The researchers evaluated PSA across five different LLM backbones (including DeepSeek-V4.1-Flash and GPT-5.6-Luna) using two deep-search benchmarks:

  • BrowseComp-Plus: 830 search-intensive questions paired with a fixed webpage corpus and supporting-document annotations.
  • InfoSeek-Eval: 300 questions synthesized from hierarchical research trees, requiring the resolution of interdependent constraints.

Key Insights and Ideas

  • The "Found but Lost" Phenomenon: The bottleneck in agentic search isn't just finding the right page; it's the extraction logic that discards the "needle" before the LLM ever sees it. Giving the agent control over extraction (the extract primitive) directly solves this.
  • Local Computation as an Action: By making an executable program the unit of interaction, the agent can handle "low-level" data dependencies (like deduplication or conditional retrieval) without wasting expensive model turns.
  • Separating Storage from Observation: PSA proves that an agent doesn't need to see everything to use everything. Keeping a large pool of candidates in a persistent workspace while only observing a "compact frontier" of evidence is both more accurate and more token-efficient.

Key Results

PSA consistently outperformed both standard Query-based agents and stepwise Tool-based agents:

  • Higher Success: PSA improved macro-averaged task success by 4.00 percentage points on InfoSeek-Eval and 7.56 percentage points on BrowseComp-Plus compared to Query-based agents.
  • Token Efficiency: PSA achieved these gains while using significantly fewer tokens. Within-backbone reductions in final-step tokens averaged 28.3% and 33.9% across the two benchmarks.
  • Better Recall: PSA achieved higher supporting-document recall across all five backbones, proving it is better at actually "seeing" the evidence it retrieves.
  • Quality-Token Trade-off: As shown in Figure 5, PSA attains a superior trade-off; even when given a larger decision budget, standard query-based agents cannot match PSA's success rate on the analyzed cohort.
Decision-budget sensitivity showing PSA achieves higher success with fewer tokens compared to query-based baselines.

Limitations and Future Work

  • Program Generation: The system relies on the LLM's ability to generate valid, effective search programs. While the backbones used were capable, smaller or less "code-literate" models might struggle.
  • Self-Distillation: The authors suggest that a promising next step is Self-Distillation Policy Optimization (SDPO). By reflecting on successful search trajectories, the agent could be trained to generate even more effective and concise search programs.
  • Code Availability: The authors intend to release the code and experimental configurations, subject to approval, which will be vital for the community to build upon this "Search as Code" paradigm.

Summary updated

BibTeX
@misc{qian2026programmatic,
  author = {Jiaming Qian and Huiyan Yang and Mandi Liu and Jie Liu and Wenkai Shen and Pengyang Zhou and Jing Jin and Jin Ma and Dezhi Ye and Chaochao Chen},
  title = {{Programmatic Search Agents: Extending Agentic Search Beyond Query Reformulation}},
  year = {2026},
  eprint = {2610.06689},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.06689},
}
Figure