| SPD-RAG: Sub-Agent Per Document Retrieval-Augmented Generation |
| | | YagizCanAkay1 | | | MuhammedYusufKartal1 | | | EsraAlparslan1 | | | | | |
| | --- | ------------- | --- | ------------------- | -------------------- | ------------ | --- | -------------- | --- | --- | --- | --- | |
| | | | | FarukOrtakoyluoglu1 | | ArdaAkpinar2 | | | | | | | |
| 1TOBBUniversityofEconomicsandTechnology 2OSTIMTechnicalUniversity |
| {y.akay, m.kartal, ealparslan, fortakoyluoglu}@etu.edu.tr 230206003@ostimteknik.edu.tr |
| | | | Abstract | | | andcommon,yetexposecriticalcoverageandrea- | | | | | | | |
| | --- | --- | -------- | --- | --- | ------------------------------------------ | --- | --- | --- | --- | --- | --- | |
| soningbottlenecksincurrentNLPsystems. |
| Answeringcomplex,real-worldqueriesoften |
| 6202 raM 9 ]LC.sc[ 1v92380.3062:viXra Traditionalsingle-indexorsingle-agentretrieval |
| requiressynthesizingfactsscatteredacrossvast |
| | | | | | | systemsstruggleto | | maintainbothscalability | | | | and | |
| | -------- | -------- | -------- | --------- | ----- | ----------------- | --- | ----------------------- | --- | --- | --- | --- | |
| | document | corpora. | In these | settings, | stan- | | | | | | | | |
| contextualrelevanceoverlarge,heterogeneouscor- |
| | dard retrieval-augmented | | | generation | (RAG) | | | | | | | | |
| | ------------------------ | --- | --- | ---------- | ----- | ---------------- | --- | -------- | --------------- | --- | ------- | --- | |
| | | | | | | pora, especially | | for long | or structurally | | complex | | |
| pipelinessufferfromincompleteevidencecov- |
| erage,whilelong-contextlargelanguagemod- documents. Standard RAG pipelines retrieve a |
| | | | | | | fixed number | | of documents | K | and process | | them | |
| | ---------- | -------- | --------- | -------- | ---- | ------------ | --- | ------------ | --- | ----------- | --- | ---- | |
| | els (LLMs) | struggle | to reason | reliably | over | | | | | | | | |
| massive inputs. We introduce SPD-RAG, a withinasinglecontextwindow(Lewisetal.,2020), |
| hierarchicalmulti-agentframeworkforexhaus- |
| whichfailswhenanswersdependoninformation |
| tivecross-documentquestionansweringthatde- |
| distributedacrossmanydocuments,sinceevidence |
| composestheproblemalongthedocumentaxis. |
| | | | | | | beyondthetop-K | | resultsistypicallydiscardedin | | | | | |
| | ---- | -------- | ------------ | ---- | --------- | -------------- | --------- | ----------------------------- | ------------ | --- | ---- | --- | |
| | Each | document | is processed | by a | dedicated | | | | | | | | |
| | | | | | | a single | retrieval | pass. | Long-context | | LLMs | ex- | |
| document-levelagentoperatingonlyonitsown |
| content,enablingfocusedretrieval,whileaco- tendcontextwindowsto128K–2Mtokens(Gemini |
| | | | | | | Teametal.,2024), | | butempiricalevidenceshows | | | | | |
| | --------- | ---------- | ----- | ----------- | ------ | ---------------- | --- | ------------------------- | --- | --- | --- | --- | |
| | ordinator | dispatches | tasks | to relevant | agents | | | | | | | | |
| and aggregates their partial answers. Agent thatreasoningqualitydegradessignificantlyascon- |
| outputsaresynthesizedbymergingpartialan- text length increases (Liu et al., 2023). This sug- |
| swersthroughatoken-boundedsynthesislayer |
| | | | | | | gests that | the | bottleneck | is not | only | retrieval, | but | |
| | --- | --- | --- | --- | --- | ---------- | --- | ---------- | ------ | ---- | ---------- | --- | |
| (whichsupportsrecursivemap-reduceformas- |
| alsoreasoningatscaleovermanydocumentsand |
| | sivecorpora). | | Thisdocument-levelspecializa- | | | | | | | | | | |
| | ------------- | --- | ----------------------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| hundredsofthousandsoftokens. |
| tionwithcentralizedfusionimprovesscalabil- |
| ityandanswerqualityinheterogeneousmulti- In this work, we introduce SPD-RAG |
| | | | | | | (Sub-agent | per | Document | Retrieval-Augmented | | | | |
| | -------- | -------- | ----- | -------- | ---------- | ---------- | --- | -------- | ------------------- | --- | --- | --- | |
| | document | settings | while | yielding | a modular, | | | | | | | | |
| extensibleretrievalpipeline. OntheLOONG Generation),ahierarchicalmulti-agentarchitecture |
| benchmark (EMNLP 2024) for long-context forexhaustivemulti-documentquestionanswering |
| multi-document QA, SPD-RAG achieves an thatfactorstheproblemalongthedocumentaxis |
| AvgScoreof58.1(GPT-5evaluation),outper- |
| | | | | | | rather than | the | task axis. | Instead | | of forcing | a | |
| | --- | --- | --- | --- | --- | ----------- | --- | ---------- | ------- | --- | ---------- | --- | |
| formingNormalRAG(33.0)andAgenticRAG |
| | | | | | | single model | | to hunt through | | a massive | | global | |
| | --- | --- | --- | --- | --- | ------------ | --- | --------------- | --- | --------- | --- | ------ | |
| (32.8)whileusingonly38%oftheAPIcostof |
| | | | | | | index, SPD-RAG | | uses | a central | coordinator | | to | |
| | --- | --- | --- | --- | --- | -------------- | --- | ---- | --------- | ----------- | --- | --- | |
| afull-contextbaseline(68.0). |
| | | | | | | decompose | the | user’s | query into | shared | instruc- | | |
| | --- | --- | --- | --- | --- | --------- | --- | ------ | ---------- | ------ | -------- | --- | |
| 1 Introduction tions. It then deploys a dedicated, cost-efficient |
| | | | | | | sub-agenttoeachdocumentinthecorpus. | | | | | | These | |
| | --- | --- | --- | --- | --- | ----------------------------------- | --- | --- | --- | --- | --- | ----- | |
| Large language models (LLMs) and the agentic agents operate entirely in parallel, treating their |
| systems built around them are increasingly used assigneddocumentsasisolatedretrievaluniverses |
| forcomplexinformationsearchtasks(Guoetal., |
| | | | | | | to extract | relevant | findings. | Finally, | | a synthesis | | |
| | --- | --- | --- | --- | --- | ---------- | -------- | --------- | -------- | --- | ----------- | --- | |
| 2024). Real-worldquestionsoftenrequiresynthe- |
| | | | | | | model | aggregates | these | document-grounded | | | | |
| | --- | --- | --- | --- | --- | ----- | ---------- | ----- | ----------------- | --- | --- | --- | |
| sizingevidencescatteredacrossmanydocuments, findings—employingarecursivemergingfallback |
| suchasassessingacompany’sfinancialrisksacross |
| | | | | | | for exceptionally | | large | corpora—to | | construct | a | |
| | --- | --- | --- | --- | --- | ----------------- | --- | ----- | ---------- | --- | --------- | --- | |
| yearsofreportsorintegratingfindingsfrommul- |
| | | | | | | comprehensive, | | final answer. | | Our codebase | | and | |
| | --- | --- | --- | --- | --- | -------------- | --- | ------------- | --- | ------------ | --- | --- | |
| tiplescientificpapers.1 |
| | | | Suchquestionsarenatural | | | datasetsusedinthispapercanbefoundat | | | | | | | |
| | --- | --- | ----------------------- | --- | --- | ----------------------------------- | --- | --- | --- | --- | --- | --- | |
| https://github.com/NebulAICompany/ |
| | 1Examples | inspired | by scenarios | in the | Loong bench- | | | | | | | | |
| | ---------------------- | -------- | ------------ | ------ | ------------ | -------- | --- | --- | --- | --- | --- | --- | |
| | mark(Wangetal.,2024a). | | | | | SPD-RAG. | | | | | | | |
|
|
| Ourcontributionsareasfollows: tasks,butthatmulti-agentoverheadgrowssuperlin- |
| early. Theirresultthatindependentagentsamplify |
| • WeproposeSPD-RAG,ahierarchicalmulti- |
| errorsby17.2×comparedto4.4×forcentralized |
| agentframeworkthatcombinesper-document |
| systemsdirectlymotivatesourcoordinator-based |
| agentic RAG with a centralized synthesis design. Thetaxonomyofhierarchicalmulti-agent |
| layer, where cost-efficient document agents systemsbyMoore(2025)furtherclassifiesdesign |
| | are coordinated | by a | smarter coordinator | | | | | | | |
| | --------------- | ---- | ------------------- | --- | ---------------------- | --- | ------------------------- | --- | --- | |
| | | | | | patternsalongfiveaxes: | | controlhierarchy,informa- | | | |
| agent,enablingdocument-levelspecialization |
| | | | | | tion flow, | role delegation, | temporal | layering, | and | |
| | ----------------- | -------------- | --------------- | --------- | ----------------------- | ---------------- | -------- | --------- | --- | |
| | and parallel | execution | while allowing | each | communicationstructure. | | | | | |
| | document | to be analyzed | in depth | to ensure | | | | | | |
| | that all relevant | information | is incorporated | | | | | | | |
| 2.2 LongDocumentandMulti-DocumentQA |
| withoutmissingcriticalevidence. |
| | | | | | Long documents | that | exceed | LLM context | win- | |
| | --- | --- | --- | --- | -------------- | ---- | ------ | ----------- | ---- | |
| • WeevaluateontheLoongbenchmark(Wang |
| | | | | | dows are | often handled | via | divide-and-conquer | | |
| | --- | --- | --- | --- | -------- | ------------- | --- | ------------------ | --- | |
| etal.,2024a),whichincludesmulti-document |
| | | | | | strategies. | LLM×MapReduce(Zhouetal.,2025) | | | | |
| | ------------ | -------------- | ---------- | -------- | --------------------------- | ----------------------------- | --- | ----------------- | --- | |
| | QA instances | over financial | reports | and aca- | | | | | | |
| | | | | | formalizestwokeychallenges: | | | inter-chunkdepen- | | |
| | demic papers | with an | average of | 11 docu- | | | | | | |
| dency(onechunkdependsoncontextfromanother) |
| mentsperinstanceandcontextlengthsfrom |
| andinter-chunkconflict(chunksprovidecontradic- |
| | 10K to beyond | 250K | tokens, and | show that | | | | | | |
| | ------------- | ---- | ----------- | --------- | --- | --- | --- | --- | --- | |
| toryinformation),andproposesstructuredinforma- |
| oursystemsubstantiallyoutperformsstandard |
| tionprotocolsandin-contextconfidencecalibration |
| RAGandAgenticRAGbaselinesunderGPT- |
| | | | | | tomitigatethem. | ToM(Guoetal.,2025)extends | | | | |
| | -------- | ------------------ | ---- | ------- | --------------- | ------------------------- | ------------ | ------- | ------ | |
| | 5-judged | Avg Score (adapted | from | Loong’s | | | | | | |
| | | | | | this approach | with a | hierarchical | DocTree | repre- | |
| GPT-4-judgedprotocol;see§4.3),withgains |
| sentationforrecursivereasoning. |
| | of around | +25 points | (76% higher | average | | | | | | |
| | --------- | ---------- | ----------- | ------- | --- | --- | --- | --- | --- | |
| Formulti-documentQA,LongAgent(Zhaoetal., |
| score)comparedtoNormalRAGandAgentic |
| | | | | | 2024) splits | a 128K-token | document | | into chunks | |
| | --- | --- | --- | --- | ------------ | ------------ | -------- | --- | ----------- | |
| RAGbaselines. |
| | | | | | assigned | to member | agents, with | a leader | agent | |
| | --- | --- | --- | --- | ------------- | -------------- | ------------ | ---------------- | ----- | |
| | | | | | orchestrating | discussionsand | | inter-membercom- | | |
| • Weanalyzeablations,documenttypeandtask |
| complexityeffects,andcost–qualitytradeoffs, munication to reduce hallucinations. However, |
| showingthat SPD-RAGattainsover85%of LongAgenttargetsasinglelongdocumentrather |
| thanmultipleindependentdocumentsthatmaycon- |
| | full-context | baseline quality | at roughly | 38% | | | | | | |
| | ------------ | ---------------- | ---------- | --- | --------------- | ---- | ------------- | ---- | -------- | |
| | | | | | flict. DocAgent | (Sun | et al., 2025) | uses | a multi- | |
| oftheAPIcost. |
| | | | | | agent framework | that | mimics | human | reading via | |
| | --- | --- | --- | --- | --------------- | ---- | ------ | ----- | ----------- | |
| 2 RelatedWork |
| atree-structuredoutlineandrevieweragent,while |
| | | | | | MDocAgent | (Han et | al., 2025) | employs | five spe- | |
| | --- | --- | --- | --- | --------- | ------- | ---------- | ------- | --------- | |
| 2.1 LLM-BasedMulti-AgentSystems |
| | | | | | cialized | agents for multi-modal | | document | under- | |
| | --- | --- | --- | --- | -------- | ---------------------- | --- | -------- | ------ | |
| LLM-basedmulti-agentsystemsareincreasingly |
| standing. |
| | used for complex | task solving. | Guo et | al. (2024) | | | | | | |
| | ---------------- | ------------- | ------ | ---------- | --- | --- | --- | --- | --- | |
| provideacomprehensivesurveyofagentprofiles, |
| 2.3 HierarchicalandRecursive |
| communicationprotocols,andcollaborationstrate- |
| Summarization |
| | gies. Hierarchical | architectures | such | as MegaA- | | | | | | |
| | ------------------ | ------------- | ---- | --------- | --- | --- | --- | --- | --- | |
| gent(Wangetal.,2024b),whichdemonstratesau- Ourhierarchicalmergingmechanismbuildsontree- |
| tonomouscooperationamongupto590agentsvia basedretrievalandrecursivesummarization. RAP- |
| multi-leveltaskdecomposition,andAgentOrches- TOR(Sarthietal.,2024)recursivelyembeds,clus- |
| tra(Zhangetal.,2025),whichachievesstate-of-the- ters, and summarizes text chunks to construct a |
| artperformanceonGAIAusingacentralplanning bottom-uptreewithmultipleabstractionlevels;re- |
| agent and specialized sub-agents, exemplify this trievingfromtheappropriatelevelyieldsa20%ab- |
| | trend. | | | | soluteaccuracygainonQuALITY.OuandLapata | | | | | |
| | ------ | --- | --- | --- | --------------------------------------- | --- | --- | --- | --- | |
| Scalinglawsformulti-agentsystemsofferquan- (2025)showthathierarchicalmergingcanamplify |
| titativeguidanceforarchitecturedesign. Kimetal. hallucinationsduringrecursivesummarizationand |
| (2025)evaluate180configurationsacrossfivear- proposecontext-awareaugmentationstrategiesthat |
| chitectures, finding that centralized coordination replaceintermediatesummarieswithrelevantinput |
| yields an 80.9% improvement on parallelizable context,whichweadoptinourmergingprotocol. |
|
|
| 2.4 Graph-BasedDocumentAnalysis 3 Methodology |
| Figure 1 presents an overview of the SPD-RAG |
| Graph-based document analysis is particu- |
| architecture. Thesystemprocessesaquerythrough |
| larly effective for global sensemaking queries. |
| three layers: the Coordination Layer (§3.1), the |
| GraphRAG(Edgeetal.,2024)constructsaknowl- |
| ParallelRetrievalLayer(§3.2),andtheSynthesis |
| edge graph of entities and relations from source |
| Layer(§3.3). |
| documents and applies hierarchical community |
| detection(e.g.,theLeidenalgorithm(Traagetal., |
| 3.1 CoordinationLayer |
| 2019)) to obtain multi-level communities with |
| Given a query q and corpus D, the system first |
| textual summaries. At query time, it retrieves |
| processes the query through a coordinator agent. |
| relevant communities, elicits community-level |
| The coordinator’s role is to decompose the user |
| partial answers, and aggregates them via a |
| query into a Shared Instruction Set for Docu- |
| map–reduce–styleprocedure. AsurveyonLLM- |
| ments and Synthesis Directives. It generates a |
| empoweredknowledgegraphconstruction(Bian, |
| WriteTodosstructuredobjectcontaining(a)alist |
| 2025) highlights how LLMs are reshaping the |
| of sub_agent_todos: atomic, self-contained ex- |
| classical knowledge graph pipeline across three |
| traction tasks specifying exactly what fields, en- |
| key stages: ontology engineering, knowledge |
| tities, or numeric values to extract (the shared in- |
| extraction, and knowledge fusion. Our work is |
| structions);and(b)asynthesis_directive(2–4 |
| complementary: instead of inducing an explicit |
| sentences) instructing the downstream Synthesis |
| knowledge graph, SPD-RAG operates directly |
| Layeronhowtoprioritizeandstructurethemerged |
| over agent-produced textual summaries and |
| response. |
| performs similarity-guided recursive synthesis |
| acrossmanydocuments. 3.2 ParallelRetrievalLayer |
| Weassignadedicatedsub-agentα toeachdocu- |
| i |
| mentd inthecorpus. Eachsub-agentoperatesas |
| 2.5 BenchmarksforMulti-Document i |
| anindependentRAGloopoveritsassigneddocu- |
| Reasoning |
| ment,guidedbythesharedinstructionsetfromthe |
| The Loong benchmark (Wang et al., 2024a) CoordinationLayer. |
| evaluates long-context LLMs on extended multi- |
| Document-Scoped Retrieval and Reasoning. |
| document QA where every document is relevant |
| Each document d serves as an isolated retrieval |
| i |
| ("Leave No Document Behind") across financial, |
| universe; the assigned sub-agent is strictly con- |
| legal, and academic domains in English and Chi- |
| strainedtosearchtoolcallswithind , preventing |
| i |
| nese. Itspansfourtasktypeswithcontextlengths |
| cross-documentdistractorchunksfromdegrading |
| from 10K to over 250K tokens, and even strong |
| local extraction. Each sub-agent receives the |
| frontier models achieve only modest Avg Scores |
| originalqueryq,itsassigneddocumentname,and |
| andmediumperfect-answerrates,underscoringthe |
| thesharedinstructionset(todolist),thenoperates |
| difficultyofreasoningovermanylong,all-relevant |
| in an iterative retrieve-and-reason loop. On each |
| documents. |
| turn, the agent either issues a search action (a |
| Complementarydatasetsprobeotheraspectsof focused query string) or a finalize action that |
| multi-document reasoning. MoNaCo (Wolfson terminates the loop and emits the document- |
| et al., 2025) focuses on natural questions over groundedfindings. Thesub-agentpromptinstructs |
| dozensofWikipediapages,MEBench(Linetal., the agent to attempt at least 2 focused searches |
| 2025)onhigh-entity-densityQA,FanOutQA(Zhu before concluding a piece of information is |
| et al., 2024) on multi-hop questions with absent, with a total cap of 5 search calls across |
| long cross-document evidence chains, and all tasks. Each search action triggers dense |
| HoloBench (Maekawa et al., 2024) on database- vector retrieval over the sub-agent’s dedicated |
| style aggregation over unstructured text. Taken per-documentQdrantindex. ThisretrievalusesCo- |
| together, these benchmarks show that scalable hereembed-v4.0embeddings(1536-dimensional, |
| multi-document reasoning remains an open cosine similarity) to fetch the top k = 15 most |
| challenge,withLoongemphasizingtheespecially similar chunks. These chunks are then re-ranked |
| demandingall-relevant,long-contextregime. byCoherererank-v4.0-fasttoyieldafinalset |
| |
| | | | | | Figure1: | OverviewofSPD-RAGArchitecture. | | | | | | | | | |
| | --- | --- | --- | --- | -------- | ------------------------------ | --- | --- | --- | --- | --- | --- | --- | --- | |
| of top_n = 5 chunks per search. The documents Similarity-Ordered Merge & Synthesis. |
| t, |
| are split into chunks offline using LangChain’s In iteration we maintain a set of find- |
| RecursiveCharacterTextSplitter in Mark- ings/summaries S(t) = {s (t) ,...,s (t) }. We |
| | | | | | | | | | | | | 1 | n | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| downmodewithachunksizeof1000tokensand embed each summary using Cohere embed-v4.0 |
| | 250-tokenoverlap. | | | | | | | and compute | | a cosine-similarity | | | matrix | via | |
| | ----------------- | --- | --- | --- | --- | --- | --- | ----------- | --- | ------------------- | --- | --- | ------ | --- | |
| sklearn.metrics.pairwise.cosine_similarity. |
| | FindingsOutput. | | | Wedenotethefindingsofeach | | | | | | | | | | | |
| | --------------- | --- | --- | ------------------------- | --- | --- | --- | ---- | ------------ | --- | ---- | -------- | ------ | --- | |
| | | | | | | | | This | is converted | | to a | distance | matrix | | |
| sub-agentas |
| | | | | | | | | | | | (t) (t) | | | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | ----- | ------- | ----- | --------- | --- | |
| | | | | | | | | D = | 1 − | cos(s | ,s ), | which | is passed | to | |
| | | | | | | | | ij | | | i j | | | | |
| o = α (q,d ) = ⟨s ,r ⟩ (1) AgglomerativeClustering with n_clusters=1, |
| | | | i | i i | i | i | | | | | | | | | |
| | ----- | ---- | ----------- | --- | -------- | -------- | --- | ----------------- | --- | --- | -------- | --- | --------- | --- | |
| | | | | | | | | linkage="average" | | | (UPGMA), | | producing | a | |
| | where | s is | the natural | | language | findings | re- | | | | | | | | |
| i |
| completedendrogramoverallcurrentsummaries. |
| | port from | d | and | r ∈ | [0,1] is | a scalar | rele- | | | | | | | | |
| | ---------------------- | --- | --- | --------------------- | -------- | -------- | ----- | ------------ | --- | ----- | ------------ | ---------- | -------- | --- | |
| | | i | | i | | | | | | | | | | | |
| | | | | | | | | We traverse | the | merge | tree | bottom-up, | greedily | | |
| | vance/confidencescore. | | | Theseoutputsarepassed | | | | | | | | | | | |
| | | | | | | | | accumulating | | nodes | into a batch | as | long as | the | |
| totheSynthesisLayer. |
| | | | | | | | | total tiktoken | | count | does not | exceed | the target | | |
| | ------------ | --- | --- | --- | --------- | --- | ----- | -------------- | ---- | --------- | -------- | ------ | ------------ | --- | |
| | Parallelism. | | All | RAG | loops for | the | docu- | | | | | | | | |
| | | | | | | | | budget | of B | = 750,000 | tokens. | | Semantically | | |
| ments are dispatched concurrently via Lang- similarsummariesaregroupedfirst,soeachbatch |
| Graph’s Send API fan-out, which emits one contains the most similar available summaries |
| | Send("document_sub_agent_node", | | | | | ...) | per | | | | | | | | |
| | ------------------------------- | --- | --- | --- | --- | ---- | --- | --- | --- | --- | --- | --- | --- | --- | |
| withinthetokenlimit. |
| documentandexecutesalltargetsinparallelwithin |
| LangGraph’sasyncruntime. AggregateandSynthesizeFindings. Foreach |
| batch,anLLMispromptedwiththeconcatenated |
| 3.3 SynthesisLayer |
| | | | | | | | | findings, | the synthesis | | directive, | and | the original | | |
| | --- | --- | --- | --- | --- | --- | --- | --------- | ------------- | --- | ---------- | --- | ------------ | --- | |
| WhilemodernLLMsfeatureextensivecontextwin- queryq toproduceanaggregatedandsynthesized |
| dows,synthesizinghundredsofdocumentreports |
| | | | | | | | | summary. | Allbatchsynthesiscallswithinanitera- | | | | | | |
| | --- | --- | --- | --- | --- | --- | --- | -------- | ------------------------------------ | --- | --- | --- | --- | --- | |
| can still exceed these limits or cause ’lost in the tionareissuedconcurrentlyviaasyncio.gather. |
| middle’degradation. Tofuture-proofthearchitec- Themergedsummariesformtheinputforthenext |
| | ture for | massive | corpora, | | the Synthesis | Layer | is | | | | | | | | |
| | -------- | ------- | -------- | --- | ------------- | ----- | --- | --------- | ------- | --- | ---- | --------- | ------ | --- | |
| | | | | | | | | iteration | S(t+1). | The | same | SYNTHESIS | prompt | | |
| designedasadynamicmap-reducepipelinethatag- |
| | | | | | | | | used at | every | level | of the | merging | tree is | ap- | |
| | --- | --- | --- | --- | --- | --- | --- | ------- | ----- | ----- | ------ | ------- | ------- | --- | |
| gregatesfindingsrecursively. TheSynthesisLayer plied even at the final level—there is no separate |
| receives the synthesis directives from the Coor- synthesis-onlyprompt. |
| | dination | Layer | and | the findings | {o | ,o ,...,o | } | | | | | | | | |
| | -------- | ----- | --- | ------------ | --- | --------- | --- | --- | --- | --- | --- | --- | --- | --- | |
| | | | | | | 1 2 | n | | | | | | | | |
| from the Parallel Retrieval Layer. It aggregates ContextSizeConditionandOutput. Thelayer |
| andsynthesizesthefindingsrecursivelythrougha evaluates whether the total findings size exceeds |
| similarity-orderedprocessuntilthetotalfindings the context size threshold (i.e., |S(t+1)| > 1). If |
| sizefallswithinthetargetcontextsizetoproduce theconditionistrue,theprocessloopsbacktothe |
| thefinaloutput. similarity-orderedmergeandsynthesisstep. Ifthe |
| |
| Algorithm1RecursiveSynthesis Locating, Comparison, Clustering, or Chain of |
| Reasoning,withcontextlengthsrangingfrom10K |
| | Require: | FindingsS | = {s ,...,s | },queryq, | | | | | | | | | |
| | -------- | --------- | ----------- | --------- | --- | --------- | ---- | ------- | --- | ----------- | --- | ---------- | |
| | | | 1 | n | | | | | | | | | |
| | | | | | | to beyond | 250K | tokens. | | We evaluate | | on the En- | |
| synthesisdirectived,contextsizebudgetB |
| Ensure: FinalOutputs⋆ glishandSet4(200k-250ktokens)portionofthe |
| | | | | | | benchmarkonly. | | Ourevaluationsetcomprises40 | | | | | |
| | ----------- | ----- | --- | --- | --- | -------------- | --- | --------------------------- | --- | --- | --- | --- | |
| | 1: while|S| | > 1do | | | | | | | | | | | |
| instancesinvolvingacademicpapersand62involv- |
| | 2: E | ← COHEREEMBED(S) | | | | | | | | | | | |
| | ---- | ---------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| D ← 1−COSINESIMILARITY(E) ingfinancialreports(102instancestotal),withthe |
| 3: |
| tree ← AGGLOMERATIVECLUSTER( fourtasktypesdistributedas: SpotlightLocating |
| 4: |
| (27),Comparison(15),Clustering(49),andChain |
| | | D, linkage | = “average”) | | | | | | | | | | |
| | --- | ---------- | ------------ | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| ofReasoning(11). |
| | 5: batches | ← | GROUPBYTOKENS( | | | | | | | | | | |
| | ---------- | -------- | -------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| | | S, tree, | B) | | | | | | | | | | |
| 4.2 Baselines |
| | 6: if|batches| | | ≥ |S|then | | | | | | | | | | |
| | -------------- | --------- | --------- | --- | --- | --------------------- | --- | ------- | --- | --------- | -------- | --- | |
| | | | | | | We compare | | against | the | following | systems, | all | |
| | 7: | batches ← | [S] | | | | | | | | | | |
| | endif | | | | | backedbyGemini2.5Pro: | | | | | | | |
| 8: |
| | 9: S | ← ASYNCGATHER( | | | | | | | | | | | |
| | ---- | ------------------- | --- | --- | -------- | ------------------------ | --- | --- | --- | --- | --------------- | --- | |
| | | | | | | • Baseline(FullContext): | | | | | Alldocumentsfor | | |
| | | SYNTHESIZE(b,q,d)∀b | | ∈ | batches) | | | | | | | | |
| eachinstanceareconcatenatedandprovided |
| 10: endwhile |
| directlyinthecontextwindowofGemini2.5 |
| | return | S[0] | | | | | | | | | | | |
| | ------ | ---- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| 11: |
| Pro,representingtheoraclelong-contextup- |
| perbound. |
| conditionisfalse(thetotalfindingssizeiswithin |
| • NormalRAG:Standardvectorsearchtop-K |
| thecontextsize,leavingasinglefinalsummarys⋆), |
| | | | | | | retrieval | | over | the full | document | | corpus, fol- | |
| | ----------- | ---------- | --------------------------- | --- | ------------ | --------- | --- | ---- | --------- | -------- | -------- | ------------ | |
| | the process | terminates | and yields | s⋆ | as the final | | | | | | | | |
| | | | | | | lowed | by | LLM | reasoning | | over the | retrieved | |
| | | If|S(t+1)| | |S(t)|(no-progresscase),the | | | | | | | | | | |
| | output. | | ≥ | | | | | | | | | | |
| chunks. |
| entirecurrentlevelisforcedintoasinglebatchto |
| guaranteetermination. |
| | | | | | | • Agentic | | RAG: | A single-agent | | ReAct-style | | |
| | --- | --- | --- | --- | --- | --------- | --- | ---- | -------------- | --- | ----------- | --- | |
| Algorithm1givesthepseudocodeforthegeneral RAG system (implemented via Lang- |
| recursivesynthesisprocedure. Graph/LangChain) that can issue multiple |
| | | | | | | iterative | | retrieval | calls | over | the | full global | |
| | ---------------- | --- | ------------------------ | --- | --- | --------- | --- | --------- | ----- | ---- | --- | ----------- | |
| | BehavioronLoong. | | Inpractice,withGemini2.5 | | | | | | | | | | |
| Pro’s 1M-token context window and a budget of corpus. It uses the same embedding and |
| | | | | | | re-rankingpipelineas | | | | SPD-RAG,butlacks | | | |
| | --- | --- | --- | --- | --- | -------------------- | --- | --- | --- | ---------------- | --- | --- | |
| B = 750,000tokens,thecombinedsub-agentfind- |
| per-documentspecialization. |
| ingsforallinstancesinourLoongevaluationsetfit |
| withinasinglebatch,sotheconditionalcheckal- |
| 4.3 EvaluationMetrics |
| | lowedoutputafteroneiteration. | | | Therecursiveloop | | | | | | | | | |
| | ----------------------------- | --- | --- | ---------------- | --- | --------- | --- | --------- | --- | -------- | --------- | --- | |
| | | | | | | We report | the | following | | metrics, | following | the | |
| isthereforeadesigncapabilityintendedformuch |
| Loongevaluationprotocol(Wangetal.,2024a): |
| largercorpora,wheretotalfindingssizegenuinely |
| exceedsthecontextsize. |
| | | | | | | • Avg | Score: | An | LLM-judged | | score | (0–100) | |
| | --- | --- | --- | --- | --- | ----- | ------ | --- | ---------- | --- | ----- | ------- | |
| measuringthedegreetowhichthepredicted |
| 4 ExperimentalSetup |
| | | | | | | answer | | accurately | covers | | the gold | answer, | |
| | --- | --- | --- | --- | --- | ------ | --- | ---------- | ------ | --- | -------- | ------- | |
| 4.1 Dataset |
| | | | | | | following | | the | evaluation | protocol | | of Loong | |
| | --- | --- | --- | --- | --- | ------------------ | --- | --- | ---------- | -------- | --- | -------- | |
| | | | | | | (Wangetal.,2024a). | | | | 2 | | | |
| WeevaluateSPD-RAGontheLoongbenchmark |
| | (Wangetal.,2024a). | | Loongisanextendedmulti- | | | | | | | | | | |
| | ------------------ | ------------ | ----------------------- | ------- | -------- | ------------------- | --- | --- | --- | ------------------- | --- | --- | |
| | | | | | | • PerfectRate(PR%): | | | | Percentageofqueries | | | |
| | document | QA instances | in both | English | and Chi- | | | | | | | | |
| wherethesystemreceivesaperfectscoreof |
| | nese, with | an average | of 11 documents | | per test | | | | | | | | |
| | ---------- | ---------- | --------------- | --- | -------- | --- | --- | --- | --- | --- | --- | --- | |
| 100. |
| | casespanningtworeal-worldscenarios: | | | | financial | | | | | | | | |
| | ----------------------------------- | --- | --- | --- | --------- | --- | --- | --- | --- | --- | --- | --- | |
| reports and academic papers. Each test case is 2BecausetheoriginallegacyGPT-4modelAPIisunavail- |
| ablefornewscaledevaluations,weadoptGPT-5astheeval- |
| constructedsothateverydocumentisrelevantto |
| | | | | | | uator. Recent | literature | | increasingly | | adopts | GPT-5 as the | |
| | --- | --- | --- | --- | --- | ------------- | ---------- | --- | ------------ | --- | ------ | ------------ | |
| the final answer ("Leave No Document Behind", standard for LLM-as-a-judge protocols due to its superior |
| meaningacorrectresponserequiressynthesizing alignmentwithhumangrading(Wolfsonetal.,2025).While |
| ourbaselinenumbersarere-computedunderthisGPT-5judge |
| evidencefromallprovideddocuments),andisan- |
| forstrictfairness,rawscoresmaynotbeperfectly1-to-1com- |
| notated under one of four task types: Spotlight parablewiththeoriginallypublishedLoongleaderboard. |
| |
| • AvgTokenUsage: Meanper-querytotal(in- Cost tracking. Per-query costs are computed |
| put+output)tokenusage. fromLangSmithrunmetadata(totaltokencounts |
| ×per-tokenpricing. |
| | • Avg | Cost | (USD): | Mean | per-query | | API cost, | | | | | | | |
| | ----------------------------------- | ---- | ------ | ---- | --------- | --- | --------- | --------- | --- | --- | --- | --- | --- | |
| | enablingcost-efficiencycomparisons. | | | | | | | 5 Results | | | | | | |
| 5.1 MainResults |
| | • AvgLatency(s): | | | Meanper-querywall-clock | | | | | | | | | | |
| | ---------------- | --- | --- | ----------------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| time. |
| Table1reportsthemainresultsacrossallsystems |
| | | | | | | | | on our Loong | evaluation | | set. | Figure | 2 illustrates | |
| | --- | --- | --- | --- | --- | --- | --- | ------------ | ---------- | --- | ---- | ------ | ------------- | |
| 4.4 ImplementationDetails |
| theseperformancedifferencesacrossthefourspe- |
| | AllsystemsuseGemini2.5Pro(temperature0.0) | | | | | | | cifictasktypes. | | | | | | |
| | ----------------------------------------- | --- | --- | --- | --- | --- | --- | --------------- | --- | --- | --- | --- | --- | |
| asthebackboneLLMforthecoordinator,merging SPD-RAGachievesanAvgScoreof58.1,sub- |
| | layer, and | synthesis | | layer. | SPD-RAG | | document | | | | | | | |
| | ---------- | --------- | --- | ------ | ------- | --- | -------- | --- | --- | --- | --- | --- | --- | |
| stantiallyoutperformingbothNormalRAG(33.0) |
| | sub-agents | use | Gemini | 2.5 | Flash | for | document- | | | | | | | |
| | ---------- | --- | ------ | --- | ----- | --- | --------- | ----------- | --- | ------- | --- | ---------------- | --- | |
| | | | | | | | | and Agentic | RAG | (32.8). | | This corresponds | to | |
| scopedretrieval,reducingper-documentcostwhile roughly a 25-point absolute improvement (about |
| preserving reasoning quality at the merging and 76% relative gain) over standard RAG baselines. |
| | synthesisstages. | | GPT-5isusedexclusivelyasthe | | | | | | | | | | | |
| | ---------------- | --- | --------------------------- | --- | --- | --- | --- | ------------ | ------- | --- | ---- | ---- | ----------- | |
| | | | | | | | | Furthermore, | SPD-RAG | | more | than | doubles the | |
| LLMjudgefortheevaluationoftheAvgscoreand Perfect Rate (PR) of Agentic RAG (18.6% vs. |
| is not part of the pipeline itself. Prompts for all 8.8%),indicatingthatexhaustivedocument-level |
| | systems, | including | baselines, | | were | optimized | for | | | | | | | |
| | -------- | --------- | ---------- | --- | ---- | --------- | --- | --- | --- | --- | --- | --- | --- | |
| processingmorefrequentlycapturesthecomplete |
| informationextractionandsynthesistoensurefair set of required facts. Notably, the Agentic RAG |
| comparison. Fullprompttemplatesforallsystems baseline,despiteconsuming∼3×moretokensthan |
| areprovidedinthecoderepository. NormalRAG,doesnotyieldscoreimprovements, |
| suggestingthatuninstructediterativeretrievalwith- |
| | Indexing. | Each | | document | | is | pre- | | | | | | | |
| | --------- | ---- | --- | --------- | --- | ------ | ---- | ---------------- | --- | -------------- | --- | ---- | ---------- | |
| | | | | | | | | out per-document | | specialization | | does | not effec- | |
| | indexed | into | a | dedicated | | Qdrant | vec- | | | | | | | |
| tivelyaddressthecoveragechallengeinexhaustive |
| | tor | collection | | using | | LangChain’s | | | | | | | | |
| | ------------------------------ | ---------- | --- | ----- | --- | ----------- | ------- | -------------- | ------- | ----------- | ----- | ------------ | ------------ | |
| | | | | | | | | multi-document | | settings. | While | the | full-context | |
| | RecursiveCharacterTextSplitter | | | | | | (Imple- | | | | | | | |
| | | | | | | | | baseline | attains | the highest | | quality with | an Avg | |
| mentationdetailsareprovidedintheAppendix.). |
| | | | | | | | | Score of | 68.0, | SPD-RAG | reaches | 85.4% | of this | |
| | --- | --- | --- | --- | --- | --- | --- | -------- | ----- | ------- | ------- | ----- | ------- | |
| Retrievalpersub-agent. Eachsearchtoolcall performancewhileconsumingonly37.9%ofthe |
| performs dense vector retrieval over the docu- API cost, demonstrating a highly favorable cost- |
| | | | | | | | | quality trade-off. | | The | full-context | baseline | pro- | |
| | --------------------------- | --- | --- | --- | --- | -------------- | --- | ------------------ | --- | --- | ------------ | -------- | ---- | |
| | mentindex,returningthetop-K | | | | | (k = 15)chunks | | | | | | | | |
| using cosine similarity in Qdrant. These can- vides a strong upper bound that benefits from all |
| didates are subsequently re-ranked with Cohere documents in one pass. Despite this, SPD-RAG |
| narrowsthegapto9.9pointswhilecostingless. |
| | rerank-v4.0-fast,andthetoptop_n | | | | | = | 5chunks | | | | | | | |
| | ------------------------------- | --- | --- | --- | --- | --- | ------- | --- | --- | --- | --- | --- | --- | |
| arepassedtothesub-agentLLM. |
| 5.2 AnalysisbyTaskType |
| | Merging | layer. | The | token | budget | | per merge | | | | | | | |
| | ------- | ------ | --- | ----- | ------ | --- | --------- | --- | --- | --- | --- | --- | --- | |
| Table2breaksdownperformancebyLoong’sfour |
| | batchisB | = 750,000tokens(75%ofGemini2.5 | | | | | | | | | | | | |
| | -------- | ------------------------------ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| tasktypes. |
| | Pro’s1Mcontextcap). | | | Agglomerativeclustering | | | | | | | | | | |
| | ------------------- | --- | --- | ----------------------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| Thetask-typebreakdownrevealsaclearpattern. |
| usessklearnwithUPGMAlinkageandprecom- |
| | | | | | | | | For Spotlight | Locating—which | | | requires | finding | |
| | --- | --- | --- | --- | --- | --- | --- | ------------- | -------------- | --- | --- | -------- | ------- | |
| putedcosine-distancematrix. |
| asinglesalientfactacrossdocuments—allRAG- |
| | | | | | | | | based systems | | perform | reasonably | well | (69–74), | |
| | ------------- | --------------- | ----------------------------- | ----- | --------- | ----------- | ---------- | -------------------------------------------- | ------------ | ------- | ---------- | ----- | ----------- | |
| | Parallelism. | | Documentagentsrunconcurrently | | | | | | | | | | | |
| | | | | | | | | while the | full-context | | baseline | leads | (86.6). The | |
| | via LangGraph | | Send | API | fan-out. | Batch | synthe- | | | | | | | |
| | | | | | | | | largest gaps | between | | SPD-RAG | and | the RAG | |
| | sis calls | within | each | merge | iteration | | are paral- | | | | | | | |
| | | asyncio.gather. | | | | | | baselinesappearinClustering(+40.5ptsoverNor- | | | | | | |
| | lelized | with | | | | Synchronous | Co- | | | | | | | |
| malRAG)andChainofReasoning(+26.2ptsover |
| hereAPIcallsareoffloadedtothethreadpoolvia |
| | | | | | | | | Agentic RAG), | | tasks | that require | aggregating | or | |
| | --- | --- | --- | --- | --- | --- | --- | ------------- | --- | ----- | ------------ | ----------- | --- | |
| asyncio.to_thread. |
| reasoningoverevidencefrommanydocumentssi- |
| Safety limits. Each document sub-agent’s iter- multaneously. Ontheotherhand,itnearlymatches |
| ative retrieval loop is capped at 5 iterations; the the full-context baseline (42.2 vs. 42.7) on Com- |
| | AgenticRAGbaselinecapsat10iterations. | | | | | | | parisontasks. | | | | | | |
| | ------------------------------------- | --- | --- | --- | --- | --- | --- | ------------- | --- | --- | --- | --- | --- | |
| |
| System AvgScore PR(%) AvgInputTok AvgTotalTok AvgCost($) AvgLatency(s) |
| OracleLong-ContextBaseline |
| | Baseline(FullContext) | | 68.0 | 31.4 253,085 | 255,345 | 0.273 | 45.6 | |
| | --------------------- | --- | ---- | ------------ | ------- | ----- | ---- | |
| RAGBaselines |
| | NormalRAG | | 33.0 | 13.7 22,174 | 27,430 | 0.080 | 42.6 | |
| | ---------- | --- | ---- | ----------- | ------ | ----- | ---- | |
| | AgenticRAG | | 32.8 | 8.8 81,877 | 85,290 | 0.098 | 40.6 | |
| OurSystem |
| | SPD-RAG | | 58.1 | 18.6 193,954 | 205,683 | 0.103 | 54.8 | |
| | ------- | --- | ---- | ------------ | ------- | ----- | ---- | |
| Table1: MainresultsonourLoongevaluationset(102instances: 40academicpaper,62financialreport). Bold: |
| | bestoverall. | Underline: | bestamongRAG-basedsystems. | | | | | |
| | ------------ | ---------- | -------------------------- | --- | --- | --- | --- | |
| Figure2: ComparisonofAverageScoreacrossthefoursystems,brokendownbytasktype(SpotlightLocating, |
| Comparison,Clustering,andChainofReasoning). |
| 5.3 AnalysisbyDocumentDomain |
| | As shown | in Table 3 | and Figure | 3 the domain | | | | |
| | -------- | ---------- | ---------- | ------------ | --- | --- | --- | |
| breakdownexposesastrikingfailuremodeofstan- |
| | dard RAG: | both Normal | RAG and | Agentic RAG | | | | |
| | --------- | ----------- | ------- | ----------- | --- | --- | --- | |
| achieve0%PRonacademicpaperinstances(Avg |
| | Scoresof15.2and16.8,respectively). | | | Academic | | | | |
| | ---------------------------------- | --- | --- | -------- | --- | --- | --- | |
| paperinstancesinLoongtendtoinvolvelong,tech- |
| nicaldocumentswithdistributedevidence,making |
| top-K retrievalespeciallysusceptibletocoverage |
| failures. SPD-RAGdramaticallyrecoversonthis |
| domain(60.0AvgScore),closingmostofthegap |
| | with the | full-context | baseline (78.8). | On finan- | | | | |
| | -------- | ------------ | ---------------- | --------- | --- | --- | --- | |
| Figure3: Averagescorebydocumentdomaincompar- |
| cialreportinstances—whichtendtobeshorterand ingtheBaseline(FullContext),NormalRAG,Agentic |
| morestructured—allRAG-basedsystemsperform |
| RAG,andSPD-RAGsystems. |
| better,andthegapbetweenSPD-RAG(56.9)and |
| thebaseline(61.0)issmaller. |
| |
| | | System | | SpotlightLoc. | | Comparison | Clustering | ChainofReasoning | | | | | |
| | --- | ------ | --- | ------------- | --- | ---------- | ---------- | ---------------- | ------ | --- | --- | --- | |
| | | | | (n=27) | | (n=15) | (n=49) | | (n=11) | | | | |
| Baseline(FullContext) 86.6/55.6% 42.7/26.7% 67.1/14.3% 60.9/54.5% |
| | | NormalRAG | | 69.7/37.0% | | 37.7/26.7% | 15.4/0.0% | | 14.8/0.0% | | | | |
| | --- | ---------- | --- | ---------- | --- | ---------- | --------- | --- | ---------- | --- | --- | --- | |
| | | AgenticRAG | | 73.4/22.2% | | 23.3/20.0% | 16.7/0.0% | | 17.9/0.0% | | | | |
| | | SPD-RAG | | 74.2/44.4% | | 42.2/20.0% | 57.2/4.1% | | 44.1/18.2% | | | | |
| Table2: AvgScore/PR(%)byLoongtasktype. EachcellshowsAvgScore/PR%. |
| | | | | | | Crucially, | thearchitectureof | | | SPD-RAG | | enables | |
| | -------- | --- | ----------- | --------------- | --- | ---------- | ----------------- | --- | --------------- | ------- | --------- | ------- | |
| | System | | Paper(n=40) | Financial(n=62) | | | | | | | | | |
| | | | | | | this | cost efficiency: | | by constraining | | retrieval | to | |
| | Baseline | | 78.8/30.0% | 61.0/32.3% | | | | | | | | | |
| NormalRAG 15.2/0.0% 44.5/22.6% isolated,single-documentspaces,wecanreliably |
| | AgenticRAG | | 16.8/0.0% | 43.1/14.5% | | | | | | | | | |
| | ---------- | --- | --------- | ---------- | --- | --- | --- | --- | --- | --- | --- | --- | |
| offloadtheiterativereasoningtoacheapermodel |
| | SPD-RAG | | 60.0/7.5% | 56.9/25.8% | | | | | | | | | |
| | ------- | --- | --------- | ---------- | --- | ------- | ----------- | --- | ------------ | --- | ------ | --------- | |
| | | | | | | (Gemini | 2.5 Flash). | | In contrast, | | global | iterative | |
| baselinesrequirethereasoningcapacityofafron- |
| Table3: AvgScore/PR(%)bydocumentdomain. |
| | | | | | | tier | model (Gemini | 2.5 | Pro) | to navigate | | the fully | |
| | --- | --- | --- | --- | --- | ---- | ------------- | --- | ---- | ----------- | --- | --------- | |
| concatenatedcorpus,drivingupcosts. |
| | System | | AvgScore | AvgCost($) | Score/$ | | | | | | | | |
| | ---------- | --- | -------- | ---------- | ------- | ------------------- | ---------- | --- | ---- | ------------------- | --- | --------- | |
| | Baseline | | 68.0 | 0.273 | 249.1 | | | | | | | | |
| | NormalRAG | | 33.0 | 0.080 | 412.5 | 6 | Discussion | | | | | | |
| | AgenticRAG | | 32.8 | 0.098 | 334.7 | | | | | | | | |
| | SPD-RAG | | 58.1 | 0.103 | 564.1 | | | | | | | | |
| | | | | | | WhereSPD-RAGexcels. | | | | Thetask-typeresults | | | |
| | | | | | | in Table | 2 confirm | our | core | hypothesis: | | architec- | |
| Table4: Cost–qualitytradeoff. |
| turaldecompositionalongthedocumentaxisyields |
| | | | | | | the largest | gains | precisely | | for tasks | that | require | |
| | --- | --- | --- | --- | --- | ----------- | -------------- | --------- | --- | ---------- | ---------- | ------- | |
| | | | | | | exhaustive | multi-document | | | synthesis. | Clustering | | |
| 5.4 Cost–QualityTradeoff |
| tasks(+40.5overNormalRAG)andChainofRea- |
| | | | | | | soning | tasks (+26.2 | over | Agentic | | RAG) | both de- | |
| | --- | --- | --- | --- | --- | ------ | ------------ | ---- | ------- | --- | ---- | -------- | |
| mandthatthesystemformacoherentanswerfrom |
| evidencedistributedacrossallrelevantdocuments— |
| exactlythescenarioforwhichper-documentagents |
| | | | | | | aredesigned. | ForLoong’sComparisonquestions, | | | | | | |
| | --- | --- | --- | --- | --- | ------------ | ------------------------------ | --- | --- | --- | --- | --- | |
| theanswerisprimarilydeterminedbyreadingout |
| asmallsetofcomparablenumericattributesfrom |
| | | | | | | each | report and | aggregating | | them, | so once | docu- | |
| | --- | --- | --- | --- | --- | -------- | -------------- | ----------- | --------- | ----- | ------------ | -------- | |
| | | | | | | ment | agents have | extracted | | those | fields, | the syn- | |
| | | | | | | thesizer | is effectively | | operating | over | a structured | | |
| table,whichhelpsexplainwhySPD-RAG’sscore |
| onComparisontasks(42.2)nearlymatchesthefull- |
| Figure4: Cost–Qualitytradeoff. Thescatterplotillus- contextbaseline(42.7). |
| tratestheParetofrontierformulti-documentQA. |
| | | | | | | Remaining | gap | with | the | full-context | | baseline. | |
| | --- | --- | --- | --- | --- | --------- | --- | ---- | --- | ------------ | --- | --------- | |
| SPD-RAG outperforms the RAG baselines in Despite strong gains over RAG baselines, SPD- |
| the cost–quality trade-off. It achieves a 76% RAG lags the full-context baseline by 9.9 Avg |
| higheraveragescorethanNormalRAG(58.1vs. Score points overall. Three factors likely con- |
| 33.0)whileincreasingtheper-querycostbyonly tribute: (1) Gemini 2.5 Flash, used for document |
| $0.023 (Table 4). In contrast, Agentic RAG is agents due to its cost efficiency, may provide |
| Pareto-dominated, as it incurs higher cost than weaker agentic reasoning capabilities compared |
| NormalRAG($0.098vs.$0.080)whiledelivering to larger models. (2) The coordinator’s sub-task |
| nearlyidenticalquality(32.8vs.33.0). Compared generation may under-specify queries for highly |
| tothefull-contextbaseline,whichachievesanAvg technical academic content, leading to incom- |
| Score of 68.0, SPD-RAG reaches 85.4% of the pleteinformationextractionatthedocument-agent |
| qualityatonly37.9%ofthecost, resultingina level. (3) The maximum context length observed |
| 2.25× improvement in cost–quality efficiency. inLoongquerieswasapproximately250ktokens— |
| |
| onlyabout25%ofthe1M-tokencontextwindow onthecoordinator’sabilitytogeneratecomprehen- |
| of Gemini 2.5 Pro—potentially limiting the pres- sivesub-tasks: under-specifiedtasksleadtoincom- |
| sureonthefull-contextbaseline. SinceSPD-RAG plete document-level extractions, as observed on |
| isdesignedtooperateonsubstantiallylargercon- technicalacademicpaperinstances. Ourevaluation |
| texts,itsadvantagesmaybecomemorepronounced islimitedtotwodomains(academicpapersandfi- |
| undermoreextremelong-contextconditions. nancialreports)fromtheLoongbenchmark;legal, |
| medical,orenterprisedocumentcorporamayhave |
| | RAG baseline | | failure | on papers. | | The 0% | PR | | | | | | | |
| | ------------ | --- | ------- | ---------- | --- | ------ | --- | --- | --- | --- | --- | --- | --- | |
| differentstructuralcharacteristicsthatalterrelative |
| | rate and | 15.2-16.8% | | Avg Score | of | both Normal | | | | | | | | |
| | -------- | ---------- | --- | --------- | --- | ----------- | --- | --- | --- | --- | --- | --- | --- | |
| performance. |
| | RAG and | Agentic | RAG | on | academic | paper | in- | | | | | | | |
| | ------- | ------- | --- | --- | -------- | ----- | --- | --- | --- | --- | --- | --- | --- | |
| ThesynthesislayerofSPD-RAGisdesignedto |
| top-K |
| | stances | highlights | a systematic | | failure | of | | | | | | | | |
| | ------- | ---------- | ------------ | --- | ------- | --- | --- | --- | --- | --- | --- | --- | --- | |
| handlecorporawherethecombinedsub-agentout- |
| | retrieval | under | dense, | distributed | evidence. | | Aca- | | | | | | | |
| | --------- | ----- | ------ | ----------- | --------- | --- | ---- | --- | --- | --- | --- | --- | --- | |
| putsexceedthemodel’scontextwindow,triggering |
| | demic | papers | in Loong | often | require | synthesiz- | | | | | | | | |
| | ----- | ------ | -------- | ----- | ------- | ---------- | --- | --- | --- | --- | --- | --- | --- | |
| multi-roundsimilarity-basedclusteringandrecur- |
| ingfactsspreadacrossabstracts,methods,results, |
| | | | | | | | | sive synthesis. | | In our Loong | experiments, | | how- | |
| | --- | --- | --- | --- | --- | --- | --- | --------------- | --- | ------------ | ------------ | --- | ---- | |
| andappendicesofmultipledocuments—aregime |
| ever,Gemini2.5Pro’s1M-tokencontextwassuffi- |
| | where exhaustive | | per-document | | coverage | proves | | | | | | | | |
| | ---------------- | --- | ------------ | --- | -------- | ------ | --- | --- | --- | --- | --- | --- | --- | |
| cienttoprocessallsub-agentsummariesinasingle |
| | highly | effective. | The | recovery | by SPD-RAG | | to | | | | | | | |
| | ------ | ---------- | --- | -------- | ---------- | --- | --- | ----------- | --- | -------------- | ---- | --- | ----------- | |
| | | | | | | | | merge step, | so | this recursive | path | was | never acti- | |
| 60.0AvgScore/7.5%PRinthisdomaindemon- |
| | | | | | | | | vated. Asaresult,thescalabilitypropertiesofthe | | | | | | |
| | --- | --- | --- | --- | --- | --- | --- | ---------------------------------------------- | --- | --- | --- | --- | --- | |
| stratesthepracticalvalueofper-documentspecial- |
| recursivesynthesispipeline—itsimpactonanswer |
| ization. |
| | | | | | | | | quality, | redundancy | reduction, | | and cost | as docu- | |
| | --- | --- | --- | --- | --- | --- | --- | -------- | ---------- | ---------- | --- | -------- | -------- | |
| Latencyoverhead. SPD-RAG incursamodest mentcountsgrowintothehundredsorthousands— |
| latency overhead (54.8 s vs. 40.6–45.6 s for the remainempiricallyunvalidated. EvaluatingSPD- |
| | baselines), | primarily | | due to | its multi-agent | | archi- | | | | | | | |
| | ----------- | --------- | --- | ------ | --------------- | --- | ------ | --- | --- | --- | --- | --- | --- | |
| RAGonmuchlargercorpora,andideallyonanew |
| tecture. Although document agents run in paral- benchmarkspecificallytargetinghundredstothou- |
| lel,end-to-endlatencyisstillgatedbythelayered sands of documents per query instance, is an im- |
| pipeline, which requires at least three sequential portantdirectionforfutureworkthatwouldmore |
| LLM calls (coordination, per-document retrieval, directlytesttheper-documentagentdesignandthe |
| andsynthesis)ratherthanasinglepass. intendedlarge-databaseregime. |
| | | | | | | | | 8 Conclusion | | | | | | |
| | --- | --- | --- | --- | --- | --- | --- | -------------------------- | --- | -------- | ---------------- | ---------- | ------ | |
| | | | | | | | | We presented | | SPD-RAG, | a hierarchical | | multi- | |
| | | | | | | | | agent framework | | designed | for | exhaustive | multi- | |
| | | | | | | | | documentquestionanswering. | | | Byassigningaded- | | | |
| icatedagenticRAGmoduletoeachdocumentand |
| mergingtheirfindingsthroughasimilarity-ordered, |
| | | | | | | | | token-bounded | | tree, our | system | effectively | miti- | |
| | --- | --- | --- | --- | --- | --- | --- | ----------------------------------------- | ---------- | --------- | --------- | ----------- | ---------- | |
| | | | | | | | | gatesthelimitationsofbothtraditionaltop-K | | | | | re- | |
| | | | | | | | | trieval (incomplete | | coverage) | and | isolated | long- | |
| | | | | | | | | context | processing | (degraded | reasoning | | at scale). | |
| Figure5: Averageper-querylatencyacrosssystems. ExperimentsonthechallengingLoongbenchmark |
| demonstratethatSPD-RAGachievesanaverage |
| scoreof58.1,outperformingNormalRAG(33.0) |
| 7 LimitationsandFutureWork |
| andAgenticRAG(32.8)byapproximately25ab- |
| SPD-RAG incurs higher per-query LLM call solute points (76% higher average score), while |
| countsthansingle-passsystems—onecallperdoc- operating at only 37.9% of the API cost of the |
| ument agent plus a final synthesis step—which oracle full-context baseline (68.0). These per- |
| increasestotaltokenusagecomparedtostandard formance gains are most pronounced in tasks re- |
| RAGbaselines,thoughitremainsatroughlyone- quiring deep cross-document synthesis—such as |
| thirdthecostofthefull-contextbaseline($0.10vs. Clustering(+40.5points)andChainofReasoning |
| $0.27perquery)duetotheuseofGemini2.5Flash (+26.2points)—aswellasondenseacademicpa- |
| fordocumentsub-agents. Systemqualitydepends perswherestandardRAGmethodsentirelyfail. |
| |
| Ultimately, our findings demonstrate that for TaichengGuo,XiuyingChen,YaqiWang,RuidiChang, |
| complex information-seeking queries over large ShichaoPei,NiteshV.Chawla,OlafWiest,andXi- |
| | | | | | | | | angliangZhang.2024. | | | Largelanguagemodel-based | | | |
| | -------- | --- | ----------- | --- | ------------ | --- | -------- | ------------------- | --- | ------------------------------- | ------------------------ | --- | --- | |
| | corpora, | how | information | | is processed | is | crucial. | | | | | | | |
| | | | | | | | | multi-agents: | | Asurveyofprogressandchallenges. | | | | |
| Specifically,ensuringthateachdocumentreceives |
| | | | | | | | | Preprint,arXiv:2402.01680. | | | ArXiv:2402.01680. | | | |
| | --- | --- | --- | --- | --- | --- | --- | -------------------------- | --- | --- | ----------------- | --- | --- | |
| exhaustive,dedicatedagenticattentionprovestobe |
| | | | | | | | | Siwei Han, | Peng | Xia, Ruiyi | Zhang, | Tong | Sun, Yun | |
| | --- | --- | --- | --- | --- | --- | --- | ---------- | ---- | ---------- | ------ | ---- | -------- | |
| amoreeffective,cost-efficient,andscalablestrat- |
| | | | | | | | | Li, Hongtu | Zhu, | and | Huaxiu Yao. | 2025. | MDocA- | |
| | --- | --- | --- | --- | --- | --- | --- | ---------- | ---- | --- | ----------- | ----- | ------ | |
| egythansimplyexpandinghowmuchrawcontext |
| gent: Amulti-modalmulti-agentframeworkfordoc- |
| asinglemodelcanconsumeinonepass. umentunderstanding. Preprint,arXiv:2503.13964. |
| ArXiv:2503.13964. |
| 9 EthicsStatement |
| | | | | | | | | Yubin Kim, | Ken | Gu, Chanwoo | Park, | Chunjong | Park, | |
| | --- | --- | --- | --- | --- | --- | --- | ---------- | --- | ----------- | ----- | -------- | ----- | |
| SPD-RAG is a retrieval-augmented generation SamuelSchmidgall,A.AliHeydari,YaoYan,Zhi- |
| hanZhang,YuchenZhuang,MarkMalhotra,PaulPu |
| | framework | intended | | to improve | access | | to infor- | | | | | | | |
| | --------- | -------- | --- | ---------- | ------ | --- | --------- | --- | --- | --- | --- | --- | --- | |
| Liang,HaeWonPark,YuzheYang,XuhaiXu,Yilun |
| | mation | distributed | across | | large document | | collec- | | | | | | | |
| | ------ | ----------- | ------ | --- | -------------- | --- | ------- | ----------- | --- | ---------- | -------- | ------ | ------- | |
| | | | | | | | | Du, Shwetak | | Patel, Tim | Althoff, | Daniel | McDuff, | |
| tions. ThesystemreliesoncommercialLLMAPIs and Xin Liu. 2025. Towards a science of scal- |
| (Gemini2.5,Cohere),andaswithanyLLM-based ing agent systems. Preprint, arXiv:2512.08296. |
| ArXiv:2512.08296. |
| | pipeline, | outputs | may | contain | factual | errors | and | | | | | | | |
| | --------- | ------- | --- | ------- | ------- | ------ | --- | --- | --- | --- | --- | --- | --- | |
| should not be treated as authoritative without hu- PatrickLewis,EthanPerez,AleksandraPiktus,Fabio |
| man verification. The increased number of API Petroni,VladimirKarpukhin,NamanGoyal,Hein- |
| | | | | | | | | richKüttler, | | MikeLewis, | Wen-tauYih, | | TimRock- | |
| | --------- | ------ | -------- | ------------ | ----------- | ------- | --------- | ------------------- | --------- | ---------- | ----------- | ----- | ------------ | |
| | calls per | query | relative | to | single-pass | systems | re- | | | | | | | |
| | | | | | | | | täschel, | Sebastian | Riedel, | and | Douwe | Kiela. 2020. | |
| | sults in | higher | energy | consumption, | | a | cost that | | | | | | | |
| | | | | | | | | Retrieval-augmented | | | generation | for | knowledge- | |
| should be weighed against the accuracy gains in intensiveNLPtasks. InAdvancesinNeuralInforma- |
| deploymentdecisions. Ourbenchmarkevaluations tionProcessingSystems. |
| | are conducted | | on publicly | | available | datasets | and | | | | | | | |
| | ------------- | --- | ----------- | --- | --------- | -------- | --- | -------- | -------- | ------------- | --- | ------------- | --- | |
| | | | | | | | | TengLin, | YuyuLuo, | HonglinZhang, | | JichengZhang, | | |
| involvenohumansubjectsorpersonaldata. Dur- Chunlin Liu, Kaishun Wu, and Nan Tang. 2025. |
| ingthepreparationofthismanuscript,AI-assisted MEBench: Benchmarkinglargelanguagemodelsfor |
| | | | | | | | | cross-documentmulti-entityquestionanswering. | | | | | In | |
| | --- | --- | --- | --- | --- | --- | --- | -------------------------------------------- | --- | --- | --- | --- | --- | |
| writingtoolswereusedtohelprefinelanguageand |
| ProceedingsoftheConferenceonEmpiricalMethods |
| | improveclarity. | | Allresearchdesign,experiments, | | | | | | | | | | | |
| | --------------- | --- | ------------------------------ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| inNaturalLanguageProcessing(EMNLP). |
| analysis,andfinaldecisionsregardingthecontent |
| NelsonF.Liu,KevinLin,JohnHewitt,AshwinParan- |
| wereconductedandverifiedbytheauthors. |
| jape,MicheleBevilacqua,FabioPetroni,andPercy |
| | | | | | | | | Liang.2023. | | Lostinthemiddle: | | Howlanguagemod- | | |
| | --- | --- | --- | --- | --- | --- | --- | ------------------- | --- | ---------------------------- | --- | --------------- | --- | |
| | | | | | | | | elsuselongcontexts. | | TransactionsoftheAssociation | | | | |
| References |
| forComputationalLinguistics,12. |
| | Haonan | Bian. | 2025. | LLM-empowered | | | knowl- | | | | | | | |
| | ------ | ----- | ----- | ------------- | --- | --- | ------ | --- | --- | --- | --- | --- | --- | |
| SeijiMaekawa,HayateIso,andNikitaBhutani.2024. |
| | edge | graph | construction: | | A survey. | | Preprint, | | | | | | | |
| | ----------------- | ----- | ------------- | ----------------- | --------- | --- | --------- | ------------------------------------- | --- | --- | --- | --- | ------- | |
| | | | | | | | | Holisticreasoningwithlong-contextLMs: | | | | | Abench- | |
| | arXiv:2510.20345. | | | ArXiv:2510.20345. | | | | | | | | | | |
| markfordatabaseoperationsonmassivetextualdata. |
| Darren Edge, Ha Trinh, Newman Cheng, Joshua Preprint,arXiv:2410.11996. ArXiv:2410.11996. |
| | Bradley, | Alex | Chao, | | Apurva | Mody, | Steven | | | | | | | |
| | -------- | ---- | ----- | --- | ------ | ----- | ------ | -------- | ------ | ----- | ---------- | --- | ------------ | |
| | | | | | | | | David J. | Moore. | 2025. | A taxonomy | of | hierarchical | |
| Truitt, Dasha Metropolitansky, Robert Osazuwa multi-agentsystems: Designpatterns,coordination |
| | Ness, | and | Jonathan | Larson. | 2024. | | From lo- | | | | | | | |
| | --------------------- | ------- | -------- | -------------------------- | -------- | --- | --------- | ----------------- | --- | ----------------- | ------------- | --- | --------- | |
| | | | | | | | | mechanisms, | | and industrial | applications. | | Preprint, | |
| | cal to | global: | A graph | RAG | approach | | to query- | | | | | | | |
| | | | | | | | | arXiv:2508.12683. | | ArXiv:2508.12683. | | | | |
| | focusedsummarization. | | | Preprint,arXiv:2404.16130. | | | | | | | | | | |
| ArXiv:2404.16130. |
| | | | | | | | | LituOuandMirellaLapata.2025. | | | | Context-awarehier- | | |
| | --- | --- | --- | --- | --- | --- | --- | ---------------------------- | --- | --- | --- | ------------------ | --- | |
| archicalmergingforlongdocumentsummarization. |
| | Gemini | Team, | Petko | Georgiev, | Ving | Ian Lei, | Ryan | | | | | | | |
| | -------- | ----- | ----- | --------- | ------- | -------- | ------- | -------------------------- | --- | --- | ----------------- | --- | --- | |
| | | | | | | | | Preprint,arXiv:2502.00977. | | | ArXiv:2502.00977. | | | |
| | Burnell, | Libin | Bai, | Anmol | Gulati, | Garrett | Tanzer, | | | | | | | |
| DamienVincent,ZhufengPan,ShiboWang,and1 Parth Sarthi, Salman Abdullah, Aditi Tuli, Shubh |
| others. 2024. Gemini 1.5: Unlocking multimodal Khanna, Anna Goldie, and Christopher D. Man- |
| understandingacrossmillionsoftokensofcontext. ning. 2024. RAPTOR: Recursive abstractive pro- |
| Preprint,arXiv:2403.05530. ArXiv:2403.05530. cessing for tree-organized retrieval. Preprint, |
| | | | | | | | | arXiv:2401.18059. | | ArXiv:2401.18059. | | | | |
| | ---------- | ------ | --- | ------- | ------- | ----- | --- | ----------------- | --- | ----------------- | --- | --- | --- | |
| | Jiani Guo, | Zuchao | Li, | Jie Wu, | Qianren | Wang, | Yun | | | | | | | |
| Li, Lefei Zhang, Hai Zhao, and Yujiu Yang. 2025. LiSun,LiuHe,ShuyueJia,YangfanHe,andChenyu |
| ToM:Leveragingtree-orientedMapReduceforlong- You. 2025. DocAgent: An agentic framework for |
| contextreasoninginlargelanguagemodels. InPro- multi-modallong-contextdocumentunderstanding. |
| ceedingsoftheConferenceonEmpiricalMethodsin InProceedingsoftheConferenceonEmpiricalMeth- |
| NaturalLanguageProcessing(EMNLP). odsinNaturalLanguageProcessing(EMNLP). |
| |
| V.A.Traag,L.Waltman,andN.J.vanEck.2019. From extraction tasks and write a synthesis |
| louvaintoleiden: Guaranteeingwell-connectedcom- directive to guide the downstream |
| | munities. | ScientificReports,9(1):5233. | | | | | | synthesizer. | | | | | | |
| | --------- | ---------------------------- | --- | --- | --- | --- | --- | ------------- | --- | ------ | --- | ---- | -------- | |
| | | | | | | | | 2. Sub-agents | | (next) | — | Each | document | |
| Minzheng Wang, Longze Chen, Cheng Fu, Shengyi is assigned one worker that runs your |
| Liao,XinghuaZhang,BingliWu,HaiyangYu,Nan tasks independently. Workers search |
| Xu,LeiZhang,RunLuo,YunshuiLi,MinYang,Fei their document and report raw findings. |
| | | | | | | | | They run | in parallel | | and | cannot | see each | |
| | ------------------------- | --- | --- | --- | --------------- | --- | --- | -------- | ----------- | --- | --- | ------ | -------- | |
| | Huang,andYongbinLi.2024a. | | | | Leavenodocument | | | | | | | | | |
| other’s results. |
| | behind: | Benchmarkinglong-contextLLMswithex- | | | | | | | | | | | | |
| | ------------------ | ----------------------------------- | --- | -------------------------- | --- | --- | --- | -------------- | -------- | ------ | ------ | ------------ | -------- | |
| | | | | | | | | 3. Synthesizer | | (last) | — | A downstream | | |
| | tendedmulti-docQA. | | | Preprint,arXiv:2406.17419. | | | | | | | | | | |
| | | | | | | | | agent | receives | ALL | worker | | findings | |
| ArXiv:2406.17419. |
| | | | | | | | | and merges | | them | into | a | single | |
| | ---------- | ------ | --- | ----- | -------- | ----- | ------ | ------------------- | --------- | ---- | --------- | ------- | ------- | |
| | | | | | | | | coherent | response. | | It | follows | your | |
| | Qian Wang, | Tianyu | | Wang, | Zhenheng | Tang, | Qinbin | | | | | | | |
| | | | | | | | | synthesis_directive | | | to decide | | what to | |
| Li,NuoChen,JingshengLiang,andBingshengHe. |
| | | | | | | | | prioritize | and | how | to | structure | the | |
| | ------ | ---------- | --- | -------------------------- | --- | --- | --- | ---------- | --- | --- | --- | --------- | --- | |
| | 2024b. | Megaagent: | | Alarge-scaleautonomousLLM- | | | | | | | | | | |
| output. |
| basedmulti-agentsystemwithoutpredefinedSOPs. |
| | | | | | | | | You CANNOT | see | the | names, | types, | or | |
| | -------------------------- | --- | --- | --- | ----------------- | --- | --- | ---------- | ------ | ---------- | ------ | ------ | --- | |
| | Preprint,arXiv:2408.09955. | | | | ArXiv:2408.09955. | | | | | | | | | |
| | | | | | | | | content | of the | documents. | | | | |
| TomerWolfson,HarshTrivedi,MorGeva,YoavGold- Your ONLY job in this step: |
| | berg, | Dan Roth, | Tushar | Khot, | Ashish | | Sabharwal, | | | | | | | |
| | ------------------ | --------- | ------ | -------------------------- | ------- | --------- | ---------- | ---------- | ---------- | ---------------------- | ----------- | -------------- | ------- | |
| | | | | | | | | • Produce | | a list | of | subagent_todos | | |
| | and Reut | Tsarfaty. | | 2025. | Monaco: | | More nat- | | | | | | | |
| | | | | | | | | (as | structured | | output): | | precise | |
| | ural and | complex | | questions | for | reasoning | across | | | | | | | |
| | | | | | | | | extraction | | tasks | | that | will be | |
| | dozensofdocuments. | | | Preprint,arXiv:2508.11133. | | | | | | | | | | |
| | | | | | | | | executed | | independently | | against | EACH | |
| | ArXiv:2508.11133. | | | | | | | document | | by the | sub-agents. | | | |
| | | | | | | | | • Produce | | a synthesis_directive: | | | a | |
| Wentao Zhang, Liang Zeng, Yuzhen Xiao, Yong- concise instruction (2–4 sentences) |
| cong Li, Ce Cui, Yilei Zhao, Rui Hu, Yang Liu, for the synthesizer. |
| | Yahui | Zhou, | and Bo | An. | 2025. | AgentOrchestra: | | | | | | | | |
| | ----- | ----- | ------ | --- | ----- | --------------- | --- | --- | --- | --- | --- | --- | --- | |
| A hierarchical multi-agent framework for general- Todo-writing rules: |
| | purpose | task | solving. | Preprint, | arXiv:2506.12508. | | | | | | | | | |
| | ----------------- | ---- | -------- | --------- | ----------------- | --- | --- | ----------- | --- | ----------- | ---- | ------------- | ---- | |
| | | | | | | | | • Decompose | | the | user | query | into | |
| | ArXiv:2506.12508. | | | | | | | concrete | | information | | requirements. | | |
| Jun Zhao, Can Zu, Hao Xu, Yi Lu, Wei He, Yiwen • Each todo must be self-contained |
| and unambiguous. |
| | Ding, | Tao Gui, | Qi | Zhang, | and | Xuanjing | Huang. | | | | | | | |
| | ----- | ---------- | --- | --------------------------- | --- | -------- | ------ | -------- | --- | ------ | ----- | ---- | ----- | |
| | | | | | | | | • Prefer | | atomic | tasks | over | broad | |
| | 2024. | LongAgent: | | Scalinglanguagemodelsto128k | | | | | | | | | | |
| tasks. |
| | contextthroughmulti-agentcollaboration. | | | | | | Preprint, | | | | | | | |
| | --------------------------------------- | ----- | --- | ----------------- | ----- | ---- | --------- | --------- | --- | --------------- | ------------ | ------------ | -------- | |
| | | | | | | | | • Include | | coverage | for: | definitions, | | |
| | arXiv:2402.11550. | | | ArXiv:2402.11550. | | | | | | | | | | |
| | | | | | | | | numeric | | values, | constraints, | | edge | |
| | | | | | | | | cases, | | error | modes, | and | any | |
| | Zihan Zhou, | Chong | | Li, Xinyi | Chen, | Shuo | Wang, | | | | | | | |
| | | | | | | | | explicit | | recommendations | | | required | |
| YuChao,ZhiliLi,HaoyuWang,QiShi,ZhixingTan, |
| | | | | | | | | by | the user | query. | | | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | -------- | ------ | --- | --- | --- | |
| XuHan,XiaodongShi,ZhiyuanLiu,andMaosong |
| | | | | | | | | • Design | a | robust | extraction | | list | |
| | ---------- | ---------- | -------------- | ----- | ----- | ---------- | ------- | -------- | ----- | ------ | ------------ | --- | ------ | |
| | Sun. 2025. | | LLM×MapReduce: | | | Simplified | long- | | | | | | | |
| | | | | | | | | that | works | for | ANY document | | in the | |
| | sequence | processing | | using | large | language | models. | | | | | | | |
| set. |
| InProceedingsoftheAnnualMeetingoftheAssocia- |
| | tionforComputationalLinguistics(ACL). | | | | | | | Important | Constraints: | | | | | |
| | ---------------------------------------- | --- | ----- | --------- | --- | --- | ---------- | --------- | ------------ | ----- | -------- | ------- | -------- | |
| | | | | | | | | Do | not assume | any | document | | contains | |
| | AndrewZhu,AlyssaHwang,LiamDugan,andChris | | | | | | | • | | | | | | |
| | | | | | | | | the | answer. | Write | | todos | that can | |
| | Callison-Burch. | | 2024. | FanOutQA: | | A | multi-hop, | | | | | | | |
| | | | | | | | | be | answered | with | either | “Found” | or | |
| multi-documentquestionansweringbenchmarkfor |
| | | | | | | | | “Not | found | in | this document.” | | | |
| | -------------- | --- | ------- | --- | ----------- | --- | ---------- | ------ | ----- | ------ | --------------- | ----------- | --- | |
| | large language | | models. | In | Proceedings | | of the An- | | | | | | | |
| | | | | | | | | • Tell | the | worker | WHAT | to extract, | not | |
| nualMeetingoftheAssociationforComputational |
| | | | | | | | | HOW | to extract | | it. | | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | ---------- | --- | --- | --- | --- | |
| Linguistics(ACL). |
| | | | | | | | | • Do | not | synthesize, | | summarize, | or | |
| | --- | --- | --- | --- | --- | --- | --- | ------- | --- | ----------- | --- | ---------- | ----- | |
| | | | | | | | | attempt | | to answer | | the user | query | |
| A Prompts |
| yourself. |
| | All | prompts | | are | | defined | in | | | | | | | |
| | --- | ------- | --- | --- | --- | ------- | --- | --- | --- | --- | --- | --- | --- | |
| A.2DocumentSub-AgentPrompt |
| backend/core/prompts.py. |
| (RESEARCH_SYSTEM_PROMPT) |
| | A.1CoordinatorPrompt | | | | | | | You are | a sub-agent | | investigating | | a | |
| | ------------------------ | --- | --- | --- | --- | --- | --- | ---------------- | ----------- | ------------ | ------------- | --- | --- | |
| | (LEAD_RESEARCHER_PROMPT) | | | | | | | single document: | | {file_name}. | | | | |
| You are a lead researcher coordinating You operate inside an iterative |
| a RAG-based analysis to answer a user retrieval loop. On each turn you output |
| | query. | | | | | | | exactly | one structured | | action: | | | |
| | -------- | --- | ------------- | --- | --- | --- | --- | ------------------ | -------------- | --- | ------- | --- | ------- | |
| | Pipeline | | Architecture: | | | | | • action="search": | | | Issue | a | focused | |
| 1. YOU (now) — Decompose the query into query to retrieve information from |
| |
| the document. Set query to a • Follow the synthesis directive |
| specific, targeted search string. above — it defines your main goal, |
| Set reasoning to why this query is priorities, and output structure. |
| | | needed. | | | | | | • | Keep only | information | | that | directly | |
| | --- | ------- | --- | --- | --- | --- | --- | --- | --------- | ----------- | --- | ---- | -------- | |
| • action="finalize": You have helps answer the query. Discard |
| | | gathered | | sufficient | evidence | to | | | tangential | content. | | | | |
| | --- | -------- | --- | ---------- | -------- | ---------- | --- | --- | ------------ | ------------ | -------- | ------ | ------ | |
| | | address | ALL | assigned | | tasks. Set | | | | | | | | |
| | | | | | | | | • | Preserve | exact | numbers, | | names, | |
| | | findings | to | your | complete | extracted | | | | | | | | |
| | | | | | | | | | dates, | and caveats. | | | | |
| | | report. | Set | reasoning | | to a brief | | | | | | | | |
| | | | | | | | | • | Remove | redundancy. | | If the | same | |
| | | summary | of | what you | found. | | | | | | | | | |
| | | | | | | | | | fact appears | | multiple | times, | keep | |
| it once. |
| | | Investigation | principles: | | | | | | | | | | | |
| | --- | ------------- | -------------- | ---- | ----- | --------- | --- | --- | ------- | -------- | --------- | ----- | -------- | |
| | | | | | | | | • | Do NOT | invent | or infer | facts | not | |
| | | | | | | | | | present | in the | findings. | | | |
| | | 1. Start | by identifying | | the | key facts | | | | | | | | |
| | | required | for | each | task. | | | • | Same | language | as | the | findings | |
| 2. Issue ONE focused query per turn (default English if mixed). |
| | | — prefer | specific | | terms | over broad | | | | | | | | |
| | --- | --------- | -------- | -------- | ----- | ----------- | --- | --------------------- | --- | --- | --- | --- | --- | |
| | | phrases. | | | | | B | ImplementationDetails | | | | | | |
| | | 3. Expand | to | synonyms | or | paraphrases | | | | | | | | |
| Models. |
| if initial results are incomplete. The coordinator, the merging layer, |
| 4. Issue separate queries for and the synthesis layer use gemini-2.5-pro |
| | | different | | aspects | of a | task. | | | | | | | | |
| | --- | --------- | --------- | ------- | ----- | ------- | ------------ | --- | ----- | --- | -------- | --- | ---------- | |
| | | | | | | | (temperature | | 0.0). | | Document | | sub-agents | |
| | | 5. Keep | searching | until | every | task is | | | | | | | | |
| covered with concrete evidence or use gemini-2.5-flash (temperature 0.0) for |
| | | confirmed | | absent. | | | document-scoped | | | retrieval. | | The | LLM judge | |
| | --- | --------- | --- | ------- | --- | --- | --------------- | --- | --- | ---------- | --- | --- | --------- | |
| 6. Do NOT attempt to answer the user (GPT-5) is separate and is used only for the |
| | | query | directly | — | extract | raw facts | | | | | | | | |
| | --- | ----- | -------- | --- | ------- | --------- | ------------------------ | --- | --- | --- | ----------------- | --- | --- | |
| | | | | | | | evaluationoftheAvgscore. | | | | Modelconstantsare | | | |
| only. |
| definedinbackend/shared/constants.py. |
| | | 7. Do | NOT finalize | | a task | as ’Not | | | | | | | | |
| | --- | ----------------- | ------------ | ------------ | ---------- | ----------- | ----------------------------- | --- | --- | --- | ------------------------- | --- | ----------- | |
| | | found’ | after | only | a single | focused | | | | | | | | |
| | | search. | | At | least | attempt 2 | Hyperparameters. | | | | | | | |
| | | focused | searches | | before | concluding | | | | | | | | |
| | | information | | is absent. | | | | | | | | | | |
| | | | | | | | Parameter | | | | Value | | | |
| | | 8. Do NOT | focus | on very | specific | terms, | | | | | | | | |
| | | | | | | | Chunksize(tokens) | | | | 1000 | | | |
| | | but | rather | on the | general | context | | | | | | | | |
| | | | | | | | Chunkoverlap(tokens) | | | | 250 | | | |
| | | of the | task. | Always | try | to find the | | | | | | | | |
| | | | | | | | Tokenizer | | | | tiktoken | | cl100k_base | |
| | | most | relevant | information. | | | | | | | | | | |
| | | | | | | | Embeddingmodel | | | | Cohereembed-v4.0 | | | |
| | | 9. You | must use | AT MOST | 5 | searches to | | | | | | | | |
| | | | | | | | Embeddingdimension | | | | 1536 | | | |
| | | answer | a task. | DO | NOT | OVERUSE THE | | | | | | | | |
| | | | | | | | Similaritymetric | | | | Cosine | | | |
| | | SEARCH | TOOL. | | | | | | | | | | | |
| | | | | | | | MergetokenbudgetB | | | | 750,000tokens | | | |
| | | | | | | | Denseretrievaltop-K | | | | 15 | | | |
| | | Finalize | report | format: | | For each | | | | | | | | |
| | | | | | | | Reranker | | | | Coherererank-v4.0-fast | | | |
| | | assigned | task, | output | either | “Found: | | | | | | | | |
| | | | | | | | Rerankertop-N | | | | 5 | | | |
| | | [exact answer | with | supporting | | evidence]” | | | | | | | | |
| | | | | | | | Sub-agentiterationsafetylimit | | | | 5 | | | |
| | | or “Not found | in | this | document.” | Always | | | | | | | | |
| | | | | | | | Clusteringalgorithm | | | | Agglomerative(UPGMA) | | | |
| | | report exact | numbers, | | names, | and dates. | | | | | | | | |
| | | | | | | | Clusteringmetric | | | | Precomputedcosinedistance | | | |
| | | Never approximate | | or | infer | beyond the | | | | | | | | |
| document. |
| | | | | | | | Cost | | measurement. | | Per-query | | costs | |
| | --- | --- | --- | --- | --- | --- | ---- | ------ | ------------ | --------- | --------- | --- | -------- | |
| | | | | | | | are | pulled | from | LangSmith | | run | metadata | |
| A.3Merge/SynthesisPrompt |
| | (SYNTHESIS_PROMPT) | | | | | | (extract_langsmith_info.py) | | | | | using | model- | |
| | ------------------ | --- | --- | --- | --- | --- | --------------------------- | --- | --- | --- | --- | ----- | ------ | |
| specificper-tokenpricing. |
| Thispromptisuseduniformlyateverylevelofthe |
| recursivemergingtree,includingthefinalsynthesis |
| step. Thereisnoseparatefinal-answerprompt. |
| | | You are | a research | synthesizer. | | Merge | | | | | | | | |
| | --- | ------------- | ----------------- | ------------ | -------- | -------- | --- | --- | --- | --- | --- | --- | --- | |
| | | the following | | sub-agent | findings | into | | | | | | | | |
| | | one compact, | information-dense | | | response | | | | | | | | |
| | | for the user. | | | | | | | | | | | | |
| | | Query: {query | } | | | | | | | | | | | |
| | | Synthesis | Directive: | | | | | | | | | | | |
| {synthesis_directive} |
| | | Findings | Batch: | {findings | } | | | | | | | | | |
| | --- | -------- | ------ | --------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | |
| Rules: |