{"slug": "smart-query-multi-hop-retrieval", "title": "Smart Query: multi-hop retrieval", "summary": "Zep released Smart Query, an agentic retrieval API exposed as graph.query that plans and executes multi-hop retrievals in a single call, according to a blog post by Preston Rasmussen. The API returns records grouped by type (edges, nodes, episodes, observations and thread summaries), caps responses at 300 records with a truncated flag, and offers a default fast mode of up to three search rounds plus a deep mode that returns complete lists and counts. Setting generate_answer to true makes Zep write an answer whose citations resolve to graph item UUIDs, while guidance, stream and graph.query_stream let developers constrain output and watch each retrieval step.", "body_md": "# Smart Query: multi-hop retrieval\n\nSome agent tasks need multi-hop retrieval. The agent retrieves one record, learns from it, and then decides what to retrieve next. Smart Query plans and runs these retrievals in one API call.\n\n**· 6 min read**\n\n[Preston Rasmussen](https://www.getzep.com/blog/author/preston/)\nUntil now, Zep's retrieval has been single-shot. You search one record type, or you get context across all record types in one call. Single-shot retrieval is fast, and it works well for many retrieval tasks.\n\nSome agent tasks need context that one search can't retrieve. The agent knows what context it needs, but it does not know which records hold that context or how to get to them. It has to retrieve one record, learn from it, and then plan what to retrieve next. Retrieval of this type is multi-hop retrieval. Single-shot retrieval is weak on multi-hop retrieval.\n\nSmart Query is Zep's agentic retrieval API, `graph.query`. It explores your graph and plans each retrieval from what the previous retrievals returned. Zep returns the graph records that it retrieved, and it can also write an answer from them. You don't have to build this search logic into every agent.\n\n## Multi-hop retrieval\n\nIn multi-hop retrieval, each retrieval depends on what the previous retrieval returned. The agent can't write all of its searches at the start. The agent learns what to retrieve next from the records that it already has. The agent must explore the graph and plan each retrieval.\n\nAn example from the graph in the video: which weekly meetings covered workload and prioritization in February? To answer that, the agent first finds the agenda email, learns which meeting the email describes, and then retrieves that meeting and its date.\n\nSome tasks also need a complete list or a count, for example every meeting that one person attended. A count is correct only when the retrieval finds every matching record.\n\nAn agent with search tools can run this retrieval itself. Each agent then needs its own retrieval logic: which search to run, what to retrieve next, and when to stop. Each new agent must implement and tune this logic again. Smart Query runs this logic in Zep.\n\n## How a query works\n\n`graph.query` takes a natural-language query and the UUID of one graph. The graph can be a standard graph or a user graph. The operation is read-only, and it does not keep conversation state. Each request is one query.\n\nZep returns the records grouped by type: edges (facts), nodes (entities), episodes, observations, and thread summaries. The response contains every distinct record that a successful retrieval call returned. The response includes records that the answer does not cite. The response holds at most 300 records. When Zep must omit records, it keeps the cited records first and sets `truncated` to `true`.\n\nWhen you set `generate_answer` to `true`, Zep also writes an answer from the records. Each citation in the answer resolves to the UUID of a graph item, so your application can show the source of each statement. When you do not set it, the response has only the records, and your agent can write its own answer.\n\nYou can also add `guidance`, for example the rules of your domain or the format that you want for the answer. To see each retrieval call as it runs, set `stream` to `true`. Zep then streams the response as server-sent events. In the Python SDK, call `graph.query_stream`.\n\n## Fast mode and Deep mode\n\nThe `mode` field selects the retrieval loop. The default is `fast`.\n\n| Mode | How it retrieves | What it does | \n|---|---|---|\n| `fast` | Up to three search rounds. Stops when it has enough context. | Optimized for latency. Answers multi-hop queries. | \n| `deep` | Plans its retrieval, and can read more records before it answers. | Runs more retrieval steps. Returns complete lists (up to 300 records) and counts. Takes longer. | \n\nIn Fast mode, each round can run several searches in parallel, for example a search of facts and a search of entities. The loop stops when it has enough context, or when a round finds no new evidence.\n\nIn Deep mode, Zep first plans the retrieval, and then runs the retrieval steps. It can list all the nodes or edges that match a filter, so it can return a complete list or a count. Deep mode runs more retrieval steps than Fast mode, so it takes longer.\n\nIn the video above, the graph comes from one company's email and calendar. For \"Which weekly meetings covered workload and prioritization in February?\", Fast mode found the meeting in about a second. Single-shot context retrieval didn't find it. For \"How many meetings has Emilia Anglada attended?\", Fast mode returned 20 of her meetings, and Deep mode found all 47 in about seven seconds. These times are from the runs in the video.\n\n## Smart Query and the Context Block\n\nSmart Query does not replace the Context Block. Smart Query and the Context Block retrieve different context.\n\nThe Context Block is single-shot. In one call, the Context Block retrieves the context for the current agent turn. The context can include facts that the agent did not know to ask for, for example a preference from two months ago. We wrote about this problem in [Stop letting your agent decide what it needs to know](https://www.getzep.com/blog/stop-letting-your-agent-decide-what-it-needs-to-know/).\n\nSmart Query retrieves the context for a specific query. Smart Query explores the graph and plans each retrieval. Smart Query can thus retrieve multi-hop context, complete lists, and counts.\n\nFor more about the decisions behind a context architecture, see [3 decisions that shape every agent's context architecture](https://www.getzep.com/blog/three-decisions-that-shape-every-agents-context-architecture/).\n\n## Models, BYOM, and BYOC\n\nYou cannot select the model, the tools, or the loop limits in the request. Zep runs the models of the managed service.\n\nIf your project uses its own LLM provider (BYOM), or if you run Zep in your own cloud (BYOC), Deep mode sends its model calls to your provider. Fast mode then needs a decision model in your LLM provider configuration. Without a decision model, set `mode` to `deep`.\n\n## Getting started with Smart Query\n\nSmart Query is now available to every Zep account and free for the next 90 days. Because it is experimental, the request, the response, the events, and the modes can change without a new API version. The operation is available through the Zep API and the Python, TypeScript, and Go SDKs. For the full reference, see the Zep guide [Querying a Graph](https://help.getzep.com/querying-a-graph).\n\nAfter the 90 days, Zep will charge for each use of Smart Query.\n\n## FAQ\n\n## What is Smart Query in Zep?\n\nSmart Query is Zep's agentic retrieval API, the experimental `graph.query` operation. You send one natural-language query about one Zep graph. Zep explores the graph, plans each retrieval from what the previous retrievals returned, and returns the graph records that it retrieved. If you set `generate_answer`, Zep also returns an answer with citations to graph items.\n\n## How is Smart Query different from graph search?\n\nGraph search is single-shot. One call runs one search and returns one ranked list of a fixed size. Smart Query runs several retrieval steps for one query. It reads the results of each step and plans the next step, until it has enough context or reaches its limit. Smart Query can thus retrieve multi-hop context. In Deep mode, Smart Query also returns complete lists and counts.\n\n## What is the difference between Fast mode and Deep mode?\n\nFast mode, the default, is optimized for latency, and it answers multi-hop queries. It runs at most three search rounds and stops when it has enough context. Deep mode runs more retrieval steps, and it returns complete lists and counts. It takes longer.\n\n## Does Smart Query replace the Context Block?\n\nSmart Query does not replace the Context Block. In one call, the Context Block retrieves the context for an agent turn, including facts that the agent did not know to ask for. Smart Query retrieves the context for a specific query that needs multi-hop retrieval, a complete list, or a count.\n\n## Can Smart Query search more than one graph?\n\nSmart Query cannot query more than one graph at this time. Each request accepts the UUID of exactly one graph, which can be a standard graph or a user graph. To query several graphs, send one request for each graph, and then combine the results in your application.\n\n## Does Smart Query cost money?\n\nSmart Query is free on all Zep accounts for the first 90 days. After that, Zep will charge for each use of Smart Query. Until then, you can test both modes on your own graphs. Because Smart Query is experimental, the request, the response, and the modes can change without a new API version.", "url": "https://wpnews.pro/news/smart-query-multi-hop-retrieval", "canonical_source": "https://www.getzep.com/blog/smart-query-api/", "published_at": "2026-11-24 15:00:00+00:00", "updated_at": "2026-11-24 17:48:42.266376+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["Zep", "Smart Query", "graph.query", "Preston Rasmussen", "graph.query_stream"], "also_reported_by": [], "takeaway": "Zep's graph.query runs multi-hop retrieval in one read-only call, defaulting to fast mode's up to three parallel search rounds and returning at most 300 records with a truncated flag, while deep mode returns complete lists and counts.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/smart-query-multi-hop-retrieval", "markdown": "https://wpnews.pro/news/smart-query-multi-hop-retrieval.md", "text": "https://wpnews.pro/news/smart-query-multi-hop-retrieval.txt", "jsonld": "https://wpnews.pro/news/smart-query-multi-hop-retrieval.jsonld"}}