Skip to content

[Examples] Add agentic search example demonstrating multi-hop RAG pattern#1825

Merged
chr-hertel merged 1 commit intosymfony:mainfrom
wachterjohannes:feature/agentic-search-example
Apr 17, 2026
Merged

[Examples] Add agentic search example demonstrating multi-hop RAG pattern#1825
chr-hertel merged 1 commit intosymfony:mainfrom
wachterjohannes:feature/agentic-search-example

Conversation

@wachterjohannes
Copy link
Copy Markdown
Contributor

@wachterjohannes wachterjohannes commented Mar 27, 2026

Q A
Bug fix? no
New feature? no
Docs? no
Issues -
License MIT

Summary

Adds an example demonstrating the agentic search pattern inspired by Chroma's Context 1 model. Instead of single-hop RAG (one query → one result set), an LLM agent iteratively explores a document corpus using four specialized tools:

  • corpus_search — Semantic vector search for broad topic discovery (deduplicated across calls)
  • corpus_grep — Line-by-line keyword matching on full document content
  • corpus_read_document — Full document retrieval by ID, adds to working set
  • corpus_prune — Permanently exclude irrelevant documents from future results

Key design decisions

  • Search/grep are discovery-only; only read_document adds to the working set
  • Search results are deduplicated across calls (already-seen documents are filtered)
  • Pruned documents are permanently excluded from all future search and grep results
  • Grep searches original document content line-by-line (not embeddings), making it genuinely different from semantic search
  • One document per movie (detailed markdown preferred over short descriptions)

Files

  • fixtures/AgenticSearch/DocumentCorpus.php — Shared state: store, deduplication, pruning, working set
  • fixtures/AgenticSearch/AgenticSearchTools.php — 4 tools in one class using multi-#[AsTool] pattern
  • examples/rag/agentic-search.php — Example wiring with event-based tool call logging

Usage

cd examples && php rag/agentic-search.php

@wachterjohannes wachterjohannes force-pushed the feature/agentic-search-example branch from db0133a to 2c7826a Compare March 28, 2026 21:24
@wachterjohannes wachterjohannes marked this pull request as ready for review March 28, 2026 21:24
@carsonbot carsonbot changed the title Add agentic search example demonstrating multi-hop RAG pattern Add agentic search example demonstrating multi-hop RAG pattern Mar 28, 2026
@chr-hertel
Copy link
Copy Markdown
Member

Super interesting - feels like we need more movies :D

@wachterjohannes
Copy link
Copy Markdown
Contributor Author

@chr-hertel added movies and improved the script :)

Comment thread fixtures/AgenticSearch/DocumentCorpus.php Outdated
@wachterjohannes
Copy link
Copy Markdown
Contributor Author

@chr-hertel removed unused method

@chr-hertel chr-hertel changed the title Add agentic search example demonstrating multi-hop RAG pattern [Examples] Add agentic search example demonstrating multi-hop RAG pattern Apr 17, 2026
@chr-hertel chr-hertel force-pushed the feature/agentic-search-example branch from 87ee718 to a0132e2 Compare April 17, 2026 21:46
@chr-hertel
Copy link
Copy Markdown
Member

Thank you @wachterjohannes.

@chr-hertel chr-hertel merged commit 68f62e5 into symfony:main Apr 17, 2026
5 checks passed
@wachterjohannes wachterjohannes deleted the feature/agentic-search-example branch April 17, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants