You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(eval-harness): default retrieval to auto search via strategy module
Move context retrieval into retrieval_strategy.build_context_block so evals use scope=auto with a 10k character budget, prepend the user-node summary, and drop per-type search limit constants.
Co-authored-by: Cursor <[email protected]>
Copy file name to clipboardExpand all lines: zep-eval-harness/.claude/commands/zep-eval-harness/SKILL.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ The pipeline has four steps:
15
15
16
16
### Scope: Single-Shot Retrieval
17
17
18
-
**The harness evaluates single-shot retrieval only.** Every test case issues one fixed batch of scoped searches from the raw test question (nodes + edges, optionally episodes, across the user graph and any document graph), then hands the resulting context block to the response model in a single turn — no second retrieval round, no query reformulation. This mirrors deterministic/programmatic retrieval, not the tool-based pattern where an agent is handed Zep search tools (e.g. `search_graph` from the Zep MCP server) and decides when and what to search.
18
+
**The harness evaluates single-shot retrieval only.** Every test case issues one retrieval from the raw test question via auto search (`config/evaluation_config/retrieval_strategy.py`), then hands the resulting context block to the response model in a single turn — no second retrieval round, no query reformulation. This mirrors deterministic/programmatic retrieval, not the tool-based pattern where an agent is handed Zep search tools (e.g. `search_graph` from the Zep MCP server) and decides when and what to search.
19
19
20
20
That makes the harness a clean instrument for the ingestion and search configuration, but it says nothing about agent tool-use behavior. A tool-based agent may do better (several targeted searches, reformulating after a weak result) or worse (never searching, poorly phrased queries, running out of turns). When reporting results, scope conclusions to the config under test and never present them as a prediction of production agent performance.
21
21
@@ -28,7 +28,7 @@ That makes the harness a clean instrument for the ingestion and search configura
28
28
29
29
This is the metric that matters most. It directly measures Zep's retrieval quality — whether the knowledge graph and search surface the right facts, entities, and relationships.
30
30
31
-
When completeness is low, the key diagnostic question is: **does the graph contain the right information but search failed to retrieve it, or is the information missing from the graph entirely?** Use `zep_graph_inspect.py` to examine what's actually in the graph. If the information is there but not retrieved, the issue is search configuration (limits, reranker, query phrasing). If the information is absent from the graph, the issue is upstream — ingestion, ontology, or custom instructions need adjustment.
31
+
When completeness is low, the key diagnostic question is: **does the graph contain the right information but search failed to retrieve it, or is the information missing from the graph entirely?** Use `zep_graph_inspect.py` to examine what's actually in the graph. If the information is there but not retrieved, the issue is retrieval strategy (auto-search character budget, query phrasing). If the information is absent from the graph, the issue is upstream — ingestion, ontology, or custom instructions need adjustment.
32
32
33
33
**Answer Accuracy (SECONDARY)** — Did the LLM produce a correct answer from the retrieved context?
34
34
-**CORRECT**: Answer conveys the same key information as the golden answer
@@ -38,15 +38,13 @@ This measures whether the response model uses the context well. It depends on th
38
38
39
39
Metrics are calculated in aggregate, per-category (based on test case `category` field), and per-user.
40
40
41
-
### Context Block: Edges vs Nodes vs Episodes
41
+
### Context Block: Auto Search
42
42
43
-
The evaluation script constructs a context block from graph search results. Understanding what each component contributes:
43
+
The evaluation script retrieves context via `build_context_block()` in `config/evaluation_config/retrieval_strategy.py`. The default strategy uses `scope="auto"` with `MAX_CHARACTERS = 10000`, and prepends the user-node summary (fetched separately — auto search does not include it).
44
44
45
-
-**Edges (facts)**: Relationships extracted by Zep between entities — e.g., "Sarah WORKS_FOR TechCorp", "Biscuit IS_OWNED_BY Sarah". These are the primary source of structured knowledge. Controlled by `USER_FACTS_LIMIT` / `DOC_FACTS_LIMIT`.
46
-
-**Nodes (entities)**: Entity summaries — e.g., a Person node with name, relationship type, and a description synthesized from all conversations mentioning them. Controlled by `USER_ENTITIES_LIMIT` / `DOC_ENTITIES_LIMIT`.
47
-
-**Episodes (raw data)**: The original messages, document chunks, or JSON data that was ingested. These provide verbatim source text but are bulkier. Disabled by default (`*_EPISODES_LIMIT = 0`). Enable by setting limits > 0 in `config/evaluation_config/constants.py`.
45
+
Auto search packs relevant edges (facts), nodes (entities), episodes, observations, and thread summaries into a pre-assembled context string. ``limit`` and ``reranker`` do not apply under auto — volume is controlled by the character budget.
48
46
49
-
Most evaluations work best with edges + nodes (structured, concise). Enable episodes when verbatim source text is needed for answering questions that require exact quotes or details not captured in the graph extraction.
47
+
To change retrieval (e.g. manual multi-scope searches with per-type limits and a reranker), edit `build_context_block` in that module. That function is the source of truth for the strategy.
50
48
51
49
All commands run from `zep-eval-harness/` using `uv run`. Depending on the user's request, either run the scripts directly or provide the terminal commands for the user.
3.**Generate Response**: Use LLM with retrieved context to answer questions
180
180
4.**Grade Answer**: Evaluate answers against golden answers using LLM judge (SECONDARY METRIC)
181
181
182
182
### Scope: Single-Shot Retrieval
183
183
184
-
**This harness evaluates single-shot retrieval only.** Each test case issues one fixed batch of searches — the raw test question against nodes and edges (plus episodes if enabled), across the user graph and any document graph, all in parallel — assembles the results into a context block, and hands it to the response model in a single turn. There is no second retrieval round and no query reformulation. That mirrors *deterministic/programmatic* retrieval, where your application searches on every turn and injects the context itself.
184
+
**This harness evaluates single-shot retrieval only.** Each test case issues one retrieval — the raw test question via auto search on the user graph (and any document graph), using the strategy in `config/evaluation_config/retrieval_strategy.py` — and hands the resulting context block to the response model in a single turn. There is no second retrieval round and no query reformulation. That mirrors *deterministic/programmatic* retrieval, where your application searches on every turn and injects the context itself.
185
185
186
186
Production agents are frequently built the other way: Zep is exposed to the model as **tools** — for example `search_graph` from the [Zep MCP server](../mcp/zep-mcp-server/), or your own tool definitions — and the LLM decides when to search, how to phrase each query, and whether to search again after seeing results.
187
187
188
188
Read the scores accordingly:
189
189
190
-
-**What they measure**: whether your ingestion and search configuration (ontology, custom instructions, chunking, search limits, reranker) puts the right facts within reach of one well-formed query. Pinning retrieval to a single deterministic search is what keeps runs comparable — the config stays the only variable.
190
+
-**What they measure**: whether your ingestion and retrieval strategy (ontology, custom instructions, chunking, auto-search character budget) puts the right facts within reach of one well-formed query. Pinning retrieval to a single deterministic search is what keeps runs comparable — the config stays the only variable.
191
191
-**What they do not measure**: agent behavior. A tool-based agent can beat these numbers by issuing several targeted searches and reformulating after a weak result, or fall short of them by not searching at all, phrasing a query poorly, or running out of turns. Tool choice, query formulation, and multi-turn dynamics are untested here.
192
192
193
193
If your production path exposes Zep through tools, treat a strong result here as a prerequisite rather than a verdict, and evaluate the agent end-to-end as well. See [Evaluate Zep for your use case](https://help.getzep.com/evaluate-zep-for-your-use-case).
└── response_prompt.py # get_response_system_prompt() — the system prompt for AI responses
215
216
```
216
217
217
-
Each script imports only from its relevant config subfolder. The response prompt used during evaluation is defined in `config/evaluation_config/response_prompt.py` and can be customized independently from the evaluation logic.
218
+
Each script imports only from its relevant config subfolder. The response prompt used during evaluation is defined in `config/evaluation_config/response_prompt.py` and can be customized independently from the evaluation logic. Retrieval behavior lives entirely in `retrieval_strategy.py`.
218
219
219
220
## Run Tracking
220
221
@@ -390,15 +391,16 @@ To add more users:
390
391
391
392
## Advanced Evaluation
392
393
393
-
### Tune Zep Search Parameters
394
+
### Tune Zep Retrieval Strategy
394
395
395
-
The evaluation script uses `cross_encoder` reranker by default for best accuracy. Search parameters and LLM models are configured in `config/evaluation_config/constants.py`:
396
-
-`USER_FACTS_LIMIT = 20`: Number of facts (edges) from user graph
397
-
-`USER_ENTITIES_LIMIT = 10`: Number of entities (nodes) from user graph
398
-
-`USER_EPISODES_LIMIT = 0`: User episodes disabled by default (set >0 to enable)
399
-
-`DOC_FACTS_LIMIT = 10`: Number of facts from document graph
400
-
-`DOC_ENTITIES_LIMIT = 5`: Number of entities from document graph
401
-
-`DOC_EPISODES_LIMIT = 0`: Document episodes disabled by default
396
+
Retrieval is defined by a single module: `config/evaluation_config/retrieval_strategy.py`. Its `build_context_block()` function is the source of truth — edit that function (and the constants it uses) to change how context is retrieved and assembled.
397
+
398
+
Default strategy:
399
+
-`SCOPE = "auto"`: Zep packs edges, nodes, episodes, observations, and thread summaries into a pre-assembled context string
400
+
-`MAX_CHARACTERS = 10000`: character budget for auto search (``limit`` and ``reranker`` do not apply under auto)
401
+
- User-node summary is fetched via `user.get_node()` and prepended (auto search does not include it)
402
+
403
+
LLM models remain in `config/evaluation_config/constants.py`:
402
404
-`LLM_RESPONSE_MODEL`: Model for generating responses
403
405
-`LLM_JUDGE_MODEL`: Model for grading answers
404
406
@@ -407,20 +409,15 @@ Chunking-specific constants are in `config/document_chunking_config/constants.py
407
409
-`CHUNK_OVERLAP`: Characters of overlap between consecutive chunks (default: 100)
408
410
-`LLM_CONTEXTUALIZATION_MODEL`: Model for document chunk contextualization
409
411
410
-
You can experiment with different rerankers by modifying the `reranker` parameter in `perform_graph_search()`:
For guidance, check out the [Searching the Graph documentation](https://help.getzep.com/searching-the-graph).
412
+
For guidance, check out the [Searching the Graph documentation](https://help.getzep.com/searching-the-graph) (including Auto Search).
416
413
417
414
### Customize Response Prompt
418
415
419
416
The system prompt used when generating AI responses during evaluation is defined in `config/evaluation_config/response_prompt.py`. Edit the `get_response_system_prompt()` function to customize the AI's persona, response style, or instructions for your use case. This is snapshotted into each evaluation run for reproducibility.
420
417
421
-
### Customize Context Block
418
+
### Customize Context Block / Retrieval
422
419
423
-
The harness constructs a custom context block from graph search results. You can modify the `construct_context_block()` function in `zep_evaluate.py` to format results differently. See the [Customize Your Context Block documentation](https://help.getzep.com/cookbook/customize-your-context-block) for best practices.
420
+
Change retrieval by editing `build_context_block()` in `config/evaluation_config/retrieval_strategy.py`. For example, you can switch to manual multi-scope searches with per-type limits and a chosen reranker, or adjust the auto-search character budget. See the [Customize Your Context Block documentation](https://help.getzep.com/cookbook/customize-your-context-block) and [Searching the Graph](https://help.getzep.com/searching-the-graph) for best practices.
424
421
425
422
### Add JSON/Text Data
426
423
@@ -485,12 +482,9 @@ Results are saved to `runs/evaluations/{run_number}_{timestamp}/results.json` wi
0 commit comments