Skip to content

Cross-collection agentic retrieval + live schema discovery#150

Open
aryan-410 wants to merge 17 commits into
AzureCosmosDB:mainfrom
aryan-410:feat/cross-collection-live-discovery
Open

Cross-collection agentic retrieval + live schema discovery#150
aryan-410 wants to merge 17 commits into
AzureCosmosDB:mainfrom
aryan-410:feat/cross-collection-live-discovery

Conversation

@aryan-410

Copy link
Copy Markdown

Summary

Upgrades the cosmos-retriever agentic search service to (1) search across all collections in a database and (2) discover each container's schema/capabilities live instead of assuming a hardcoded chunked schema.

Key changes

  • Live discovery (retrieval/discovery/, retrieval/binding.py): infers vector/full-text indexes, partition keys, and dimensions from container metadata. Removes the hardcoded default_chunked_schema (defaults.py deleted).
  • Cross-collection retrieval (retrieval/orchestration.py): container="*" fans out across every searchable collection in a database and fuses hits with RRF. Per-collection depth tracks the fused limit so a gold doc ranked deep within its own collection isn't truncated before fusion.
  • Structured schema overrides (retrieval/schema_override.py): user-supplied JSON override (document_id_path, chunk_order_path, dunder codec, …) via the corpus registry, replacing the none/legacy_chunked enum.
  • Database-aware corpus registry: per-database embedding endpoint/model, with fallback to the default endpoint+key when an entry lists only a model.
  • container is now optional — omit to search the whole database; database is required (no silent server defaults).
  • Admin + tuning: GET/PATCH /config, per-request RuntimeConfig overrides, per-turn timing instrumentation, bounded-TTL retriever cache.
  • .NET agentic_search: optional container, JSON schemaOverride, and a Managed-Identity-excluded Cosmos credential so the native tools fall through to developer CLI auth locally.

Tests

Adds unit tests for binding, discovery, orchestration, cache, and runtime config. All pass (pytest, 38).

Notes

  • Retrieval is token-neutral vs. the previous per-collection depth; the deeper fusion improved paired recall by ~+0.07 on a 9-collection enterprise benchmark with no change in turns/tokens.

cosmos-dev and others added 17 commits June 26, 2026 21:57
FastAPI service (POST /search, GET /health) wrapping CosmosRetriever, which
runs a multi-turn retrieval agent over a Cosmos DB corpus. Pluggable inference
backend: harmony_vllm (fine-tuned pat-jj/harness-1), openai_chat (any
OpenAI-compatible chat model), or openai_responses (reasoning models such as
gpt-5.4 on Azure AI Foundry). Includes tests for the server and agent loops.

The .NET agentic_search tool calls this service over HTTP.
Add a 9th MCP tool, agentic_search, that runs the Cosmos Retriever agent over
a Cosmos DB corpus and returns ranked, curated documents.

- AgenticSearchExecutor: calls the cosmos-retriever service over HTTP
  (COSMOS_RETRIEVER_URL, COSMOS_RETRIEVER_TIMEOUT_S); always returns parseable
  JSON (error envelope on failure).
- Wire into Program.cs, MCPProtocolController (tools/list + tools/call),
  MCPTestController, and McpToolRequestValidator.
- CosmosClientFactory: exclude ManagedIdentityCredential (fall through to az
  login); accept the standard MCP _meta params field.
- Docs: docs/AGENTIC_SEARCH.md, README + CHANGELOG + .env.example.
…rness

- Move VllmTokenCompleter + run_single_episode into inference/vllm_policy.py
- Delete inference/evaluate_harness1_vllm.py (eval/benchmark code)
- Repoint retriever.py to vllm_policy; update env_rl docstring
- Include pre-existing: pool_doc_ids trajectory pooling (openai_chat), optional baseten import (rerank)
The datagen/ package deletion was previously only staged, never committed, so
it still appeared in the PR. Actually remove it (search_dataset.py,
generate_sft_rl_splits.py, BrowseComp-Plus, README, __init__) along with the
unit tests folder, the datagen TYPE_CHECKING import in tasks.py, the stale
datagen comment in config.py, and the now-dangling pytest/respx dev deps and
pytest/ruff test config in pyproject.toml.
…lResult

Add a trajectory field to RetrievalResult populated by the harmony_vllm
backend: the search queries issued (search_history), per-turn tool calls
(turn_tools), programmatic per-turn status summaries (turn_summaries), and the
final per-doc importance tags from curation (curated_importance).
…ed retrieval layer

- Add schema-driven retrieval package (planner/compiler/executor/strategies/
  document-resolvers) decoupled from physical Cosmos paths
- Endpoint-only inference (OpenAI chat/responses); drop vLLM/RL runtime
- Add foundry-harness and retrieval/agent benchmark scripts
…lt corpus profile); rename LegacyDunderCodec -> DunderChunkCodec
…loop.py and ChatSearchResult -> AgentSearchResult (both backends live there); keep backend-id strings
…undry Messages API); refresh backend docs/.env
- Live discovery of container schema/capabilities (retrieval/discovery/, binding.py),
  replacing the hardcoded default_chunked_schema (defaults.py removed)
- Cross-collection retrieval: container="*" fans out across all searchable
  collections in a database and fuses with RRF (orchestration.py); per-collection
  depth tracks the fused limit so gold docs ranked deep in a collection aren't dropped
- Structured, user-supplied schema overrides (schema_override.py) via the corpus
  registry, replacing the none/legacy_chunked enum
- Database-aware corpus registry: per-database embedding endpoint/model with
  default-endpoint fallback
- container is now optional (defaults to whole-database); database required,
  no silent server defaults
- /config admin endpoints, per-request RuntimeConfig overrides, timing
  instrumentation, bounded-TTL retriever cache
- .NET agentic_search: optional container, JSON schemaOverride, Managed-Identity-
  excluded Cosmos credential for the native tools
- Tests: binding, discovery, orchestration, cache, runtime config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant