# agentic-rag-jdemo-4-chat **Repository Path**: createmaker/agentic-rag-jdemo-4-chat ## Basic Information - **Project Name**: agentic-rag-jdemo-4-chat - **Description**: agentic-rag-jdemo-4-chat - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-03 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # agentic-rag-jdemo-4-chat Demo 4 (Java) — multi-turn conversational RAG with sliding-window summarization + coreference query rewriting. Mirror of the Python sibling. ## What's new vs baseline - `Conversation` class — rolling state (turn list + summary), passed to every `agent.ask()` call - **Sliding window** — keeps last `CHAT_KEEP_TURNS` (default 3) turn-pairs verbatim; older turns get LLM-summarized via `maybeCompress()` - **Coreference rewriting** — `Conversation.rewriteStandalone()` asks the LLM to rewrite the user's question to inline missing referents; heuristic `needsRewrite()` short-circuits when not needed - REPL commands: `:q` / `:reset` / `:history` / `:compress` ## Setup ```powershell cd D:\javacode\agentic-rag-jdemo-4-chat mvn package copy .env.example .env java -jar target\arag.jar # multi-turn REPL ``` Try a coref-heavy session: ``` ? What's the envelope format? [answer ...] ? 和 REST 有什么区别? [blue panel: rewritten: envelope 格式和 REST 标准有什么区别?] [answer using prior context] ? :history # show turn count + summary + token estimate ? :reset # start fresh ``` ## Files ``` src/main/java/com/agentic/rag/ ├── Conversation.java # NEW — state + summarization + coref rewriter ├── Agent.java # wraps baseline loop with conversation context ├── App.java # REPL with :reset / :history / :compress ├── ... (other baseline classes unchanged) src/test/java/com/agentic/rag/ ├── SafeEvalTest.java └── ConversationTest.java # NEW (11 tests, no LLM) ``` ## Tests ```powershell mvn test # 10 SafeEval + 11 Conversation = 21 tests ```