# graphiti - Doramagic AI Context Pack

> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。

## 充分原则

- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。
- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。

## 给宿主 AI 的使用方式

你正在读取 Doramagic 为 graphiti 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。

## Claim 消费规则

- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。
- **事实最低状态**：`supported`
- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。
- `weak`：只能作为低置信度线索，必须要求用户继续核实。
- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。
- `unverified`：不得作为事实使用，应明确说证据不足。
- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。

## 它最适合谁

- **AI 研究者或研究型 Agent 构建者**：README 明确围绕研究、实验或论文工作流展开。 证据：`README.md` Claim：`clm_0002` supported 0.86
- **正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**：README 或插件配置提到多个宿主 AI。 证据：`README.md` Claim：`clm_0003` supported 0.86

## 它能做什么

- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md` Claim：`clm_0001` supported 0.86

## 怎么开始

- `pip install graphiti-core` 证据：`README.md` Claim：`clm_0004` supported 0.86, `clm_0005` supported 0.86, `clm_0006` supported 0.86, `clm_0007` supported 0.86 等
- `pip install graphiti-core[falkordb]` 证据：`README.md` Claim：`clm_0005` supported 0.86, `clm_0012` supported 0.86
- `pip install graphiti-core[kuzu]` 证据：`README.md` Claim：`clm_0006` supported 0.86
- `pip install graphiti-core[neptune]` 证据：`README.md` Claim：`clm_0007` supported 0.86
- `pip install graphiti-core[anthropic]` 证据：`README.md` Claim：`clm_0008` supported 0.86, `clm_0011` supported 0.86
- `pip install graphiti-core[groq]` 证据：`README.md` Claim：`clm_0009` supported 0.86
- `pip install graphiti-core[google-genai]` 证据：`README.md` Claim：`clm_0010` supported 0.86, `clm_0013` supported 0.86
- `pip install graphiti-core[anthropic,groq,google-genai]` 证据：`README.md` Claim：`clm_0011` supported 0.86
- `pip install graphiti-core[falkordb,anthropic,google-genai]` 证据：`README.md` Claim：`clm_0012` supported 0.86
- `pip install "graphiti-core[google-genai]"` 证据：`README.md` Claim：`clm_0010` supported 0.86, `clm_0013` supported 0.86

## 继续前判断卡

- **当前建议**：需要管理员/安全审批
- **为什么**：继续前可能涉及密钥、账号、外部服务或敏感上下文，建议先经过管理员或安全审批。

### 30 秒判断

- **现在怎么做**：需要管理员/安全审批
- **最小安全下一步**：先跑 Prompt Preview；若涉及凭证或企业环境，先审批再试装
- **先别相信**：工具权限边界不能在安装前相信。
- **继续会触碰**：命令执行、宿主 AI 配置、本地环境或项目文件

### 现在可以相信

- **适合人群线索：AI 研究者或研究型 Agent 构建者**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0002` supported 0.86
- **适合人群线索：正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0003` supported 0.86
- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86
- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`README.md` Claim：`clm_0004` supported 0.86, `clm_0005` supported 0.86, `clm_0006` supported 0.86, `clm_0007` supported 0.86

### 现在还不能相信

- **工具权限边界不能在安装前相信。**（unverified）：MCP/tool 类项目通常会触碰文件、网络、浏览器或外部 API，必须真实检查权限和日志。
- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。
- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。
- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。 证据：`AGENTS.md`, `CLAUDE.md`
- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。
- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。
- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。
- **安装命令是否需要网络、权限或全局写入？**（unverified）：这影响企业环境和个人环境的安装风险。 证据：`README.md`

### 继续会触碰什么

- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`
- **宿主 AI 配置**：Claude/Codex/Cursor/Gemini/OpenCode 等宿主的 plugin、Skill 或规则加载配置。 原因：宿主配置会改变 AI 后续工作方式，可能和用户已有规则冲突。 证据：`AGENTS.md`, `CLAUDE.md`
- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`README.md`
- **环境变量 / API Key**：项目入口文档明确出现 API key、token、secret 或账号凭证配置。 原因：如果真实安装需要凭证，应先使用测试凭证并经过权限/合规判断。 证据：`CLAUDE.md`, `README.md`, `examples/opentelemetry/README.md`, `examples/quickstart/README.md` 等
- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。

### 最小安全下一步

- **先跑 Prompt Preview**：用安装前交互式试用判断工作方式是否匹配，不需要授权或改环境。（适用：任何项目都适用，尤其是输出质量未知时。）
- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）
- **先备份宿主 AI 配置**：Skill、plugin、规则文件可能改变 Claude/Cursor/Codex 的默认行为。（适用：存在插件 manifest、Skill 或宿主规则入口时。）
- **不要使用真实生产凭证**：环境变量/API key 一旦进入宿主或工具链，可能产生账号和合规风险。（适用：出现 API、TOKEN、KEY、SECRET 等环境线索时。）
- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）

### 退出方式

- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。
- **准备移除宿主 plugin / Skill / 规则入口**：如果试装后行为异常，可以把宿主 AI 恢复到试装前状态。
- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。
- **准备撤销测试 API key 或 token**：测试凭证泄露或误用时，可以快速止损。
- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。

## 哪些只能预览

- 解释项目适合谁和能做什么
- 基于项目文档演示典型对话流程
- 帮助用户判断是否值得安装或继续研究

## 哪些必须安装后验证

- 真实安装 Skill、插件或 CLI
- 执行脚本、修改本地文件或访问外部服务
- 验证真实输出质量、性能和兼容性

## 边界与风险判断卡

- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0014` inferred 0.45
- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md` Claim：`clm_0015` supported 0.86
- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。
- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。
- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。

## 开工前工作上下文

### 加载顺序

- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。
- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。
- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。
- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。
- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。

### 任务路由

- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86

### 上下文规模

- 文件总数：272
- 重要文件覆盖：40/272
- 证据索引条目：80
- 角色 / Skill 条目：13

### 证据不足时的处理

- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。
- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。
- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。
- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。

## Prompt Recipes

### 适配判断

- 目标：判断这个项目是否适合用户当前任务。
- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。

```text
请基于 graphiti 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。
```

### 安装前体验

- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。
- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。

```text
请把 graphiti 当作安装前体验资产，而不是已安装工具或真实运行环境。

请严格输出四段：
1. 先问我 3 个必要问题。
2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。
3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。
4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。

硬性边界：
- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。
- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。
- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。
- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。
- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。
- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。

```

### 角色 / Skill 选择

- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。
- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。

```text
请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。
```

### 风险预检

- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。
- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。

```text
请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。
```

### 宿主 AI 开工指令

- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。
- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。

```text
请基于 graphiti 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。
```


## 角色 / Skill 索引

- 共索引 13 个角色 / Skill / 项目文档条目。

- **What is a Context Graph?**（project_doc）：Graphiti Build Temporal Context Graphs for AI Agents 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`
- **Graphiti MCP Server**（project_doc）：Graphiti is a framework for building and querying temporally-aware knowledge graphs, specifically tailored for AI agents operating in dynamic environments. Unlike traditional retrieval-augmented generation RAG methods, Graphiti continuously integrates user interactions, structured and unstructured enterprise data, and external information into a coherent, queryable graph. The framework supports incremental data upda… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`mcp_server/README.md`
- **graph-service**（project_doc）：Graph service is a fast api server implementing the graphiti https://github.com/getzep/graphiti package. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`server/README.md`
- **Azure OpenAI with Neo4j Example**（project_doc）：This example demonstrates how to use Graphiti with Azure OpenAI and Neo4j to build a knowledge graph. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/azure-openai/README.md`
- **GLiNER2 Hybrid LLM Client Example Experimental**（project_doc）：GLiNER2 Hybrid LLM Client Example Experimental 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/gliner2/README.md`
- **OpenTelemetry Stdout Tracing Example**（project_doc）：OpenTelemetry Stdout Tracing Example 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/opentelemetry/README.md`
- **Graphiti Quickstart Example**（project_doc）：This example demonstrates the basic functionality of Graphiti, including: 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/quickstart/README.md`
- **Docker Deployment for Graphiti MCP Server**（project_doc）：Docker Deployment for Graphiti MCP Server 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`mcp_server/docker/README.md`
- **Graphiti MCP Server Integration Tests**（project_doc）：Graphiti MCP Server Integration Tests 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`mcp_server/tests/README.md`
- **Repository Guidelines**（project_doc）：Project Structure & Module Organization Graphiti's core library lives under graphiti core/ , split into domain modules such as nodes.py , edges.py , models/ , and search/ for retrieval pipelines. Database drivers in graphiti core/driver/ support Neo4j, FalkorDB, Kuzu, and Neptune. Additional core modules include cross encoder/ reranking via BGE, OpenAI, and Gemini , telemetry/ OpenTelemetry tracing , namespaces/ nam… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`AGENTS.md`
- **CLAUDE.md**（project_doc）：This file provides guidance to Claude Code claude.ai/code when working with code in this repository. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CLAUDE.md`
- **Contributing to Graphiti**（project_doc）：We're thrilled you're interested in contributing to Graphiti! As firm believers in the power of open source collaboration, we're committed to building not just a tool, but a vibrant community where developers of all experience levels can make meaningful contributions. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CONTRIBUTING.md`
- **Instructions for Using Graphiti's MCP Tools for Agent Memory**（project_doc）：Instructions for Using Graphiti's MCP Tools for Agent Memory 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`mcp_server/docs/cursor_rules.md`

## 证据索引

- 共索引 80 条证据。

- **What is a Context Graph?**（documentation）：Graphiti Build Temporal Context Graphs for AI Agents 证据：`README.md`
- **Graphiti MCP Server**（documentation）：Graphiti is a framework for building and querying temporally-aware knowledge graphs, specifically tailored for AI agents operating in dynamic environments. Unlike traditional retrieval-augmented generation RAG methods, Graphiti continuously integrates user interactions, structured and unstructured enterprise data, and external information into a coherent, queryable graph. The framework supports incremental data updates, efficient retrieval, and precise historical queries without requiring complete graph recomputation, making it suitable for developing interactive, context-aware AI applications. 证据：`mcp_server/README.md`
- **graph-service**（documentation）：Graph service is a fast api server implementing the graphiti https://github.com/getzep/graphiti package. 证据：`server/README.md`
- **Azure OpenAI with Neo4j Example**（documentation）：This example demonstrates how to use Graphiti with Azure OpenAI and Neo4j to build a knowledge graph. 证据：`examples/azure-openai/README.md`
- **GLiNER2 Hybrid LLM Client Example Experimental**（documentation）：GLiNER2 Hybrid LLM Client Example Experimental 证据：`examples/gliner2/README.md`
- **OpenTelemetry Stdout Tracing Example**（documentation）：OpenTelemetry Stdout Tracing Example 证据：`examples/opentelemetry/README.md`
- **Graphiti Quickstart Example**（documentation）：This example demonstrates the basic functionality of Graphiti, including: 证据：`examples/quickstart/README.md`
- **Docker Deployment for Graphiti MCP Server**（documentation）：Docker Deployment for Graphiti MCP Server 证据：`mcp_server/docker/README.md`
- **Graphiti MCP Server Integration Tests**（documentation）：Graphiti MCP Server Integration Tests 证据：`mcp_server/tests/README.md`
- **Repository Guidelines**（documentation）：Project Structure & Module Organization Graphiti's core library lives under graphiti core/ , split into domain modules such as nodes.py , edges.py , models/ , and search/ for retrieval pipelines. Database drivers in graphiti core/driver/ support Neo4j, FalkorDB, Kuzu, and Neptune. Additional core modules include cross encoder/ reranking via BGE, OpenAI, and Gemini , telemetry/ OpenTelemetry tracing , namespaces/ namespace management , and migrations/ database migrations . Service adapters and API glue reside in server/graph service/ , while the MCP integration lives in mcp server/ with its own src/ , tests/ , config/ , and docker/ subdirectories . Shared assets sit in images/ and examples/… 证据：`AGENTS.md`
- **CLAUDE.md**（documentation）：This file provides guidance to Claude Code claude.ai/code when working with code in this repository. 证据：`CLAUDE.md`
- **Contributing to Graphiti**（documentation）：We're thrilled you're interested in contributing to Graphiti! As firm believers in the power of open source collaboration, we're committed to building not just a tool, but a vibrant community where developers of all experience levels can make meaningful contributions. 证据：`CONTRIBUTING.md`
- **License**（source_file）：Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ 证据：`LICENSE`
- **Instructions for Using Graphiti's MCP Tools for Agent Memory**（documentation）：Instructions for Using Graphiti's MCP Tools for Agent Memory 证据：`mcp_server/docs/cursor_rules.md`
- **Edges**（source_file）：logger = logging.getLogger name ⋮---- class Edge BaseModel, ABC ⋮---- uuid: str = Field default factory=lambda: str uuid4 group id: str = Field description='partition of the graph' source node uuid: str target node uuid: str created at: datetime ⋮---- @abstractmethod async def save self, driver: GraphDriver : ... ⋮---- async def delete self, driver: GraphDriver ⋮---- @classmethod async def delete by uuids cls, driver: GraphDriver, uuids: list str ⋮---- def hash self ⋮---- def eq self, other ⋮---- @classmethod async def get by uuid cls, driver: GraphDriver, uuid: str : ... ⋮---- class EpisodicEdge Edge ⋮---- async def save self, driver: GraphDriver ⋮---- result = await driver.execute query ⋮… 证据：`graphiti_core/edges.py`
- **Wall-clock watermark for the next-run filter: keeps backfilled**（source_file）：logger = logging.getLogger name ⋮---- class AddEpisodeResults BaseModel ⋮---- episode: EpisodicNode episodic edges: list EpisodicEdge nodes: list EntityNode edges: list EntityEdge communities: list CommunityNode community edges: list CommunityEdge ⋮---- class AddBulkEpisodeResults BaseModel ⋮---- episodes: list EpisodicNode ⋮---- class AddTripletResults BaseModel ⋮---- class Graphiti ⋮---- def capture initialization telemetry self ⋮---- llm provider = self. get provider type self.llm client embedder provider = self. get provider type self.embedder reranker provider = self. get provider type self.cross encoder database provider = self. get provider type self.driver ⋮---- properties = { ⋮----… 证据：`graphiti_core/graphiti.py`
- **Graphiti Types**（source_file）：class GraphitiClients BaseModel ⋮---- driver: GraphDriver llm client: LLMClient embedder: EmbedderClient cross encoder: CrossEncoderClient tracer: Tracer ⋮---- model config = ConfigDict arbitrary types allowed=True 证据：`graphiti_core/graphiti_types.py`
- **Maximum valid at episode reference time across all episodes covered**（source_file）：logger = logging.getLogger name ⋮---- class EpisodeType Enum ⋮---- message = 'message' json = 'json' text = 'text' fact triple = 'fact triple' ⋮---- @staticmethod def from str episode type: str ⋮---- class Node BaseModel, ABC ⋮---- uuid: str = Field default factory=lambda: str uuid4 name: str = Field description='name of the node' group id: str = Field description='partition of the graph' labels: list str = Field default factory=list created at: datetime = Field default factory=lambda: utc now ⋮---- model config = ConfigDict validate assignment=True ⋮---- @field validator 'labels' @classmethod def validate labels cls, value: list str - list str ⋮---- @abstractmethod async def save self, dri… 证据：`graphiti_core/nodes.py`
- **Bge Reranker Client**（source_file）：class BGERerankerClient CrossEncoderClient ⋮---- def init self ⋮---- async def rank self, query: str, passages: list str - list tuple str, float ⋮---- input pairs = query, passage for passage in passages ⋮---- loop = asyncio.get running loop scores = await loop.run in executor None, self.model.predict, input pairs ⋮---- ranked passages = sorted 证据：`graphiti_core/cross_encoder/bge_reranker_client.py`
- **Client**（source_file）：class CrossEncoderClient ABC ⋮---- @abstractmethod async def rank self, query: str, passages: list str - list tuple str, float 证据：`graphiti_core/cross_encoder/client.py`
- **Sort by score in descending order highest relevance first**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT MODEL = 'gemini-2.5-flash-lite' ⋮---- class GeminiRerankerClient CrossEncoderClient ⋮---- config = LLMConfig ⋮---- async def rank self, query: str, passages: list str - list tuple str, float ⋮---- scoring prompts = ⋮---- prompt = f"""Rate how well this passage answers or relates to the query. Use a scale from 0 to 100. ⋮---- responses = await semaphore gather ⋮---- results = ⋮---- score text = response.text.strip ⋮---- score match = re.search r'\b \d{1,3} \b', score text ⋮---- score = float score match.group 1 ⋮---- normalized score = max 0.0, min 1.0, score / 100.0 ⋮---- Sort by score in descending order highest relevance first ⋮---- Check if i… 证据：`graphiti_core/cross_encoder/gemini_reranker_client.py`
- **Openai Reranker Client**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT MODEL = 'gpt-4.1-nano' ⋮---- class OpenAIRerankerClient CrossEncoderClient ⋮---- config = LLMConfig ⋮---- async def rank self, query: str, passages: list str - list tuple str, float ⋮---- openai messages list: Any = ⋮---- responses = await semaphore gather ⋮---- responses top logprobs = scores: list float = ⋮---- norm logprobs = np.exp top logprobs 0 .logprob ⋮---- results = passage, score for passage, score in zip passages, scores, strict=True 证据：`graphiti_core/cross_encoder/openai_reranker_client.py`
- **Legacy interfaces kept for backwards compatibility during Phase 1**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT SIZE = 10 ⋮---- ENTITY INDEX NAME = os.environ.get 'ENTITY INDEX NAME', 'entities' EPISODE INDEX NAME = os.environ.get 'EPISODE INDEX NAME', 'episodes' COMMUNITY INDEX NAME = os.environ.get 'COMMUNITY INDEX NAME', 'communities' ENTITY EDGE INDEX NAME = os.environ.get 'ENTITY EDGE INDEX NAME', 'entity edges' ⋮---- class GraphProvider Enum ⋮---- NEO4J = 'neo4j' FALKORDB = 'falkordb' KUZU = 'kuzu' NEPTUNE = 'neptune' ⋮---- class GraphDriverSession ABC ⋮---- provider: GraphProvider ⋮---- async def aenter self ⋮---- @abstractmethod async def aexit self, exc type, exc, tb ⋮---- @abstractmethod async def run self, query: str, kwargs: Any - Any ⋮---- @a… 证据：`graphiti_core/driver/driver.py`
- **Entity Edge Ops**（source_file）：logger = logging.getLogger name ⋮---- class FalkorEntityEdgeOperations EntityEdgeOperations ⋮---- edge data: dict str, Any = { ⋮---- query = get entity edge save query GraphProvider.FALKORDB ⋮---- batch size: int = 100, noqa: ARG002 ⋮---- prepared: list dict str, Any = ⋮---- query = get entity edge save bulk query GraphProvider.FALKORDB ⋮---- query = """ ⋮---- edges = entity edge from record r for r in records ⋮---- cursor clause = 'AND e.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = e.uuid for e in edges ⋮---- embedding map = {r 'uuid' : r 'fact embedding' for r in records} 证据：`graphiti_core/driver/falkordb/operations/entity_edge_ops.py`
- **Entity Node Ops**（source_file）：logger = logging.getLogger name ⋮---- class FalkorEntityNodeOperations EntityNodeOperations ⋮---- entity data: dict str, Any = { ⋮---- labels = ':'.join list set node.labels + 'Entity' ⋮---- query = get entity node save query GraphProvider.FALKORDB, labels ⋮---- batch size: int = 100, noqa: ARG002 ⋮---- prepared: list dict str, Any = ⋮---- queries: list tuple str, dict str, Any = get entity node save bulk query ⋮---- query = """ ⋮---- nodes = entity node from record r for r in records ⋮---- cursor clause = 'AND n.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = n.uuid for n in nodes ⋮---- embedding map = {r 'uuid' : r 'nam… 证据：`graphiti_core/driver/falkordb/operations/entity_node_ops.py`
- **Graph Ops**（source_file）：logger = logging.getLogger name ⋮---- class FalkorGraphMaintenanceOperations GraphMaintenanceOperations ⋮---- range indices = get range indices GraphProvider.FALKORDB fulltext indices = get fulltext indices GraphProvider.FALKORDB index queries = range indices + fulltext indices ⋮---- result = await executor.execute query 'CALL db.indexes ' ⋮---- drop tasks = ⋮---- label = record 'label' entity type = record 'entitytype' ⋮---- community clusters: list list EntityNode = ⋮---- group ids = group id values 0 'group ids' if group id values else ⋮---- resolved group ids: list str = group ids or ⋮---- projection: dict str, list Neighbor = {} ⋮---- nodes = entity node from record r for r in node rec… 证据：`graphiti_core/driver/falkordb/operations/graph_ops.py`
- **Remove stopwords and empty tokens**（source_file）：logger = logging.getLogger name ⋮---- MAX QUERY LENGTH = 128 ⋮---- SEPARATOR MAP = str.maketrans ⋮---- def sanitize query: str - str ⋮---- """Replace FalkorDB special characters with whitespace.""" sanitized = query.translate SEPARATOR MAP ⋮---- """Build a fulltext query string for FalkorDB using RedisSearch syntax.""" ⋮---- group filter = '' ⋮---- escaped group ids = f'"{gid}"' for gid in group ids group values = ' '.join escaped group ids group filter = f' @group id:{group values} ' ⋮---- sanitized query = sanitize query ⋮---- Remove stopwords and empty tokens query words = sanitized query.split filtered words = word for word in query words if word and word.lower not in STOPWORDS sanitize… 证据：`graphiti_core/driver/falkordb/operations/search_ops.py`
- **Convert the result header to a list of strings**（source_file）：logger = logging.getLogger name ⋮---- class FalkorDriverSession GraphDriverSession ⋮---- provider = GraphProvider.FALKORDB ⋮---- def init self, graph: FalkorGraph ⋮---- async def aenter self ⋮---- async def aexit self, exc type, exc, tb ⋮---- async def close self ⋮---- async def execute write self, func, args, kwargs ⋮---- async def run self, query: str list, kwargs: Any - Any ⋮---- params = convert datetimes to strings params ⋮---- params = dict kwargs ⋮---- class FalkorDriver GraphDriver ⋮---- default group id: str = '\\ ' fulltext syntax: str = '@' aoss client: None = None ⋮---- loop = asyncio.get running loop ⋮---- @property def entity node ops self - EntityNodeOperations ⋮---- @propert… 证据：`graphiti_core/driver/falkordb_driver.py`
- **Kuzu doesn't support UNWIND - iterate and save individually**（source_file）：logger = logging.getLogger name ⋮---- class KuzuEntityEdgeOperations EntityEdgeOperations ⋮---- params: dict str, Any = { ⋮---- query = get entity edge save query GraphProvider.KUZU ⋮---- Kuzu doesn't support UNWIND - iterate and save individually ⋮---- query = """ ⋮---- edges = parse kuzu entity edge r for r in records ⋮---- cursor clause = 'AND e.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = e.uuid for e in edges ⋮---- embedding map = {r 'uuid' : r 'fact embedding' for r in records} 证据：`graphiti_core/driver/kuzu/operations/entity_edge_ops.py`
- **Kuzu doesn't support UNWIND - iterate and save individually**（source_file）：logger = logging.getLogger name ⋮---- class KuzuEntityNodeOperations EntityNodeOperations ⋮---- attrs json = json.dumps node.attributes or {} params: dict str, Any = { ⋮---- query = get entity node save query GraphProvider.KUZU, '' ⋮---- Kuzu doesn't support UNWIND - iterate and save individually ⋮---- cleanup query = """ delete query = """ ⋮---- Clean up RelatesToNode intermediates first ⋮---- query = """ ⋮---- nodes = parse kuzu entity node r for r in records ⋮---- cursor clause = 'AND n.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = n.uuid for n in nodes ⋮---- embedding map = {r 'uuid' : r 'name embedding' for r in re… 证据：`graphiti_core/driver/kuzu/operations/entity_node_ops.py`
- **Graph Ops**（source_file）：logger = logging.getLogger name ⋮---- class KuzuGraphMaintenanceOperations GraphMaintenanceOperations ⋮---- range indices = get range indices GraphProvider.KUZU fulltext indices = get fulltext indices GraphProvider.KUZU index queries = range indices + fulltext indices ⋮---- community clusters: list list EntityNode = ⋮---- group ids = group id values 0 'group ids' if group id values else ⋮---- resolved group ids: list str = group ids or ⋮---- projection: dict str, list Neighbor = {} ⋮---- nodes = parse kuzu entity node r for r in node records ⋮---- cluster uuids = label propagation projection ⋮---- episode uuids = episode.uuid for episode in episodes ⋮---- node uuids = node.uuid for node in… 证据：`graphiti_core/driver/kuzu/operations/graph_ops.py`
- **Kuzu uses RelatesToNode as an intermediate node for edges, so each**（source_file）：logger = logging.getLogger name ⋮---- MAX QUERY LENGTH = 128 ⋮---- words = query.split ⋮---- words = words :max query length truncated = ' '.join words ⋮---- class KuzuSearchOperations SearchOperations ⋮---- fuzzy query = build kuzu fulltext query query, group ids ⋮---- filter query = '' ⋮---- filter query = ' WHERE ' + ' AND '.join filter queries ⋮---- cypher = ⋮---- search vector var = f'CAST $search vector AS FLOAT {len search vector } ' ⋮---- filter query = ' AND ' + ' AND '.join filter queries ⋮---- Kuzu uses RelatesToNode as an intermediate node for edges, so each logical hop is actually 2 hops in the graph. We need 3 separate MATCH queries UNIONed together: 1. Episodic - MENTIONS - E… 证据：`graphiti_core/driver/kuzu/operations/search_ops.py`
- **Do not explicitly close the connection, instead rely on GC.**（source_file）：logger = logging.getLogger name ⋮---- SCHEMA QUERIES = """ ⋮---- class KuzuDriver GraphDriver ⋮---- provider: GraphProvider = GraphProvider.KUZU aoss client: None = None ⋮---- @property def entity node ops self - EntityNodeOperations ⋮---- @property def episode node ops self - EpisodeNodeOperations ⋮---- @property def community node ops self - CommunityNodeOperations ⋮---- @property def saga node ops self - SagaNodeOperations ⋮---- @property def entity edge ops self - EntityEdgeOperations ⋮---- @property def episodic edge ops self - EpisodicEdgeOperations ⋮---- @property def community edge ops self - CommunityEdgeOperations ⋮---- @property def has episode edge ops self - HasEpisodeEdgeOpera… 证据：`graphiti_core/driver/kuzu_driver.py`
- **Entity Edge Ops**（source_file）：logger = logging.getLogger name ⋮---- class Neo4jEntityEdgeOperations EntityEdgeOperations ⋮---- edge data: dict str, Any = { ⋮---- query = get entity edge save query GraphProvider.NEO4J ⋮---- prepared: list dict str, Any = ⋮---- query = get entity edge save bulk query GraphProvider.NEO4J ⋮---- query = """ ⋮---- edges = entity edge from record r for r in records ⋮---- cursor clause = 'AND e.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = e.uuid for e in edges ⋮---- embedding map = {r 'uuid' : r 'fact embedding' for r in records} 证据：`graphiti_core/driver/neo4j/operations/entity_edge_ops.py`
- **Entity Node Ops**（source_file）：logger = logging.getLogger name ⋮---- class Neo4jEntityNodeOperations EntityNodeOperations ⋮---- entity data: dict str, Any = { ⋮---- labels = ':'.join list set node.labels + 'Entity' ⋮---- query = get entity node save query GraphProvider.NEO4J, labels ⋮---- prepared: list dict str, Any = ⋮---- query = get entity node save bulk query GraphProvider.NEO4J, prepared ⋮---- query = """ ⋮---- nodes = entity node from record r for r in records ⋮---- cursor clause = 'AND n.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = n.uuid for n in nodes ⋮---- embedding map = {r 'uuid' : r 'name embedding' for r in records} 证据：`graphiti_core/driver/neo4j/operations/entity_node_ops.py`
- **Graph Ops**（source_file）：logger = logging.getLogger name ⋮---- class Neo4jGraphMaintenanceOperations GraphMaintenanceOperations ⋮---- range indices = get range indices GraphProvider.NEO4J fulltext indices = get fulltext indices GraphProvider.NEO4J index queries = range indices + fulltext indices ⋮---- community clusters: list list EntityNode = ⋮---- group ids = group id values 0 'group ids' if group id values else ⋮---- resolved group ids: list str = group ids or ⋮---- projection: dict str, list Neighbor = {} ⋮---- nodes = entity node from record r for r in node records ⋮---- cluster uuids = label propagation projection ⋮---- episode uuids = episode.uuid for episode in episodes ⋮---- node uuids = node.uuid for node… 证据：`graphiti_core/driver/neo4j/operations/graph_ops.py`
- **--- Node search ---**（source_file）：logger = logging.getLogger name ⋮---- MAX QUERY LENGTH = 128 ⋮---- group ids filter list = f'group id:"{g}"' for g in group ids if group ids is not None else group ids filter = '' ⋮---- lucene query = lucene sanitize query ⋮---- full query = group ids filter + ' ' + lucene query + ' ' ⋮---- class Neo4jSearchOperations SearchOperations ⋮---- --- Node search --- ⋮---- fuzzy query = build neo4j fulltext query query, group ids ⋮---- filter query = '' ⋮---- filter query = ' WHERE ' + ' AND '.join filter queries ⋮---- cypher = ⋮---- filter query = ' AND ' + ' AND '.join filter queries ⋮---- filter params: dict str, Any = {} group filter query = '' ⋮---- group filter query = 'WHERE c.group id IN $… 证据：`graphiti_core/driver/neo4j/operations/search_ops.py`
- **Instantiate Neo4j operations**（source_file）：logger = logging.getLogger name ⋮---- class Neo4jDriver GraphDriver ⋮---- provider = GraphProvider.NEO4J default group id: str = '' ⋮---- Instantiate Neo4j operations ⋮---- Schedule the indices and constraints to be built ⋮---- Try to get the current event loop loop = asyncio.get running loop Schedule the build indices and constraints to run ⋮---- No event loop running, this will be handled later ⋮---- --- Operations properties --- ⋮---- @property def entity node ops self - EntityNodeOperations ⋮---- @property def episode node ops self - EpisodeNodeOperations ⋮---- @property def community node ops self - CommunityNodeOperations ⋮---- @property def saga node ops self - SagaNodeOperations ⋮--… 证据：`graphiti_core/driver/neo4j_driver.py`
- **Entity Edge Ops**（source_file）：logger = logging.getLogger name ⋮---- class NeptuneEntityEdgeOperations EntityEdgeOperations ⋮---- edge data: dict str, Any = { ⋮---- query = get entity edge save query GraphProvider.NEPTUNE ⋮---- prepared: list dict str, Any = ⋮---- query = get entity edge save bulk query GraphProvider.NEPTUNE ⋮---- query = """ ⋮---- edges = entity edge from record r for r in records ⋮---- cursor clause = 'AND e.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = e.uuid for e in edges ⋮---- embedding map = {r 'uuid' : r 'fact embedding' for r in records} 证据：`graphiti_core/driver/neptune/operations/entity_edge_ops.py`
- **Entity Node Ops**（source_file）：logger = logging.getLogger name ⋮---- class NeptuneEntityNodeOperations EntityNodeOperations ⋮---- entity data: dict str, Any = { ⋮---- labels = ':'.join list set node.labels + 'Entity' ⋮---- query = get entity node save query GraphProvider.NEPTUNE, labels ⋮---- prepared: list dict str, Any = ⋮---- queries = get entity node save bulk query GraphProvider.NEPTUNE, prepared ⋮---- query = """ ⋮---- nodes = entity node from record r for r in records ⋮---- cursor clause = 'AND n.uuid < $uuid' if uuid cursor else '' limit clause = 'LIMIT $limit' if limit is not None else '' query = ⋮---- uuids = n.uuid for n in nodes ⋮---- embedding map = {r 'uuid' : r 'name embedding' for r in records} 证据：`graphiti_core/driver/neptune/operations/entity_node_ops.py`
- **Graph Ops**（source_file）：logger = logging.getLogger name ⋮---- class NeptuneGraphMaintenanceOperations GraphMaintenanceOperations ⋮---- def init self, driver: NeptuneDriver None = None ⋮---- community clusters: list list EntityNode = ⋮---- group ids = group id values 0 'group ids' if group id values else ⋮---- resolved group ids: list str = group ids or ⋮---- projection: dict str, list Neighbor = {} ⋮---- nodes = entity node from record r for r in node records ⋮---- cluster uuids = label propagation projection ⋮---- episode uuids = episode.uuid for episode in episodes ⋮---- node uuids = node.uuid for node in nodes 证据：`graphiti_core/driver/neptune/operations/graph_ops.py`
- **Neptune: fetch all embeddings, compute cosine in Python**（source_file）：logger = logging.getLogger name ⋮---- class NeptuneSearchOperations SearchOperations ⋮---- def init self, driver: NeptuneDriver None = None ⋮---- driver = self. driver res = driver.run aoss query 'node name and summary', query, limit=limit ⋮---- input ids = ⋮---- cypher = ⋮---- filter query = '' ⋮---- filter query = ' WHERE ' + ' AND '.join filter queries ⋮---- Neptune: fetch all embeddings, compute cosine in Python query = ⋮---- score = calculate cosine similarity ⋮---- filter query = ' AND ' + ' AND '.join filter queries ⋮---- --- Edge search --- ⋮---- res = driver.run aoss query 'edge name and fact', query ⋮---- Fetch all embeddings, compute cosine similarity in Python ⋮---- cypher = """… 证据：`graphiti_core/driver/neptune/operations/search_ops.py`
- **If the list contains datetime objects, we need to wrap each element with datetime**（source_file）：logger = logging.getLogger name DEFAULT SIZE = 10 ⋮---- aoss indices = ⋮---- class NeptuneDriver GraphDriver ⋮---- provider: GraphProvider = GraphProvider.NEPTUNE ⋮---- def init self, host: str, aoss host: str, port: int = 8182, aoss port: int = 443 ⋮---- endpoint = host.replace 'neptune-db://', '' ⋮---- graphId = host.replace 'neptune-graph://', '' ⋮---- session = boto3.Session ⋮---- @property def entity node ops self - EntityNodeOperations ⋮---- @property def episode node ops self - EpisodeNodeOperations ⋮---- @property def community node ops self - CommunityNodeOperations ⋮---- @property def saga node ops self - SagaNodeOperations ⋮---- @property def entity edge ops self - EntityEdgeOper… 证据：`graphiti_core/driver/neptune_driver.py`
- **Entity Edge Ops**（source_file）：class EntityEdgeOperations ABC 证据：`graphiti_core/driver/operations/entity_edge_ops.py`
- **Entity Node Ops**（source_file）：class EntityNodeOperations ABC 证据：`graphiti_core/driver/operations/entity_node_ops.py`
- **Graph Ops**（source_file）：class GraphMaintenanceOperations ABC 证据：`graphiti_core/driver/operations/graph_ops.py`
- **Search Ops**（source_file）：class SearchOperations ABC ⋮---- @abstractmethod def build node search filters self, search filters: SearchFilters - Any: ... ⋮---- @abstractmethod def build edge search filters self, search filters: SearchFilters - Any: ... 证据：`graphiti_core/driver/operations/search_ops.py`
- **Search Interface**（source_file）：class SearchInterface BaseModel ⋮---- def build node search filters self, search filters: Any - Any ⋮---- def build edge search filters self, search filters: Any - Any ⋮---- class Config ⋮---- arbitrary types allowed = True 证据：`graphiti_core/driver/search_interface/search_interface.py`
- **Azure Openai**（source_file）：logger = logging.getLogger name ⋮---- class AzureOpenAIEmbedderClient EmbedderClient ⋮---- async def create self, input data: str list str Any - list float ⋮---- text input = input data ⋮---- text input = input data ⋮---- text input = str input data ⋮---- response = await self.azure client.embeddings.create model=self.model, input=text input ⋮---- async def create batch self, input data list: list str - list list float ⋮---- """Create batch embeddings using Azure OpenAI client.""" ⋮---- response = await self.azure client.embeddings.create 证据：`graphiti_core/embedder/azure_openai.py`
- **Client**（source_file）：EMBEDDING DIM = int os.getenv 'EMBEDDING DIM', 1024 ⋮---- class EmbedderConfig BaseModel ⋮---- embedding dim: int = Field default=EMBEDDING DIM, frozen=True ⋮---- class EmbedderClient ABC ⋮---- async def create batch self, input data list: list str - list list float 证据：`graphiti_core/embedder/client.py`
- **Process each item individually**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT EMBEDDING MODEL = 'text-embedding-001' ⋮---- DEFAULT BATCH SIZE = 100 ⋮---- class GeminiEmbedderConfig EmbedderConfig ⋮---- embedding model: str = Field default=DEFAULT EMBEDDING MODEL api key: str None = None ⋮---- class GeminiEmbedder EmbedderClient ⋮---- config = GeminiEmbedderConfig ⋮---- result = await self.client.aio.models.embed content ⋮---- async def create batch self, input data list: list str - list list float ⋮---- batch size = self.batch size all embeddings = ⋮---- batch = input data list i : i + batch size ⋮---- Process each item individually ⋮---- contents= item , type: ignore arg-type mypy fails on broad union type 证据：`graphiti_core/embedder/gemini.py`
- **Openai**（source_file）：DEFAULT EMBEDDING MODEL = 'text-embedding-3-small' ⋮---- class OpenAIEmbedderConfig EmbedderConfig ⋮---- embedding model: EmbeddingModel str = DEFAULT EMBEDDING MODEL api key: str None = None base url: str None = None ⋮---- class OpenAIEmbedder EmbedderClient ⋮---- config = OpenAIEmbedderConfig ⋮---- result = await self.client.embeddings.create ⋮---- async def create batch self, input data list: list str - list list float 证据：`graphiti_core/embedder/openai.py`
- **Use the response model to define the tool**（source_file）：logger = logging.getLogger name ⋮---- AnthropicModel = Literal ⋮---- DEFAULT MODEL: AnthropicModel = 'claude-haiku-4-5-latest' ⋮---- ANTHROPIC MODEL MAX TOKENS = { ⋮---- DEFAULT ANTHROPIC MAX TOKENS = 8192 ⋮---- class AnthropicClient LLMClient ⋮---- model: AnthropicModel ⋮---- config = LLMConfig ⋮---- def extract json from text self, text: str - dict str, typing.Any ⋮---- json start = text.find '{' json end = text.rfind '}' + 1 ⋮---- json str = text json start:json end ⋮---- """ Create a tool definition based on the response model if provided, or a generic JSON tool if not. Args: response model: Optional Pydantic model to use for structured output. Returns: A list containing a single tool d… 证据：`graphiti_core/llm_client/anthropic_client.py`
- **Azure Openai Client**（source_file）：logger = logging.getLogger name ⋮---- class AzureOpenAILLMClient BaseOpenAIClient ⋮---- MAX RETRIES: ClassVar int = 2 ⋮---- supports reasoning = self. supports reasoning features model ⋮---- request kwargs = { ⋮---- temperature value = temperature if not supports reasoning else None ⋮---- def handle structured response self, response: Any - dict str, Any ⋮---- message = response.choices 0 .message ⋮---- response object = response.output text ⋮---- @staticmethod def supports reasoning features model: str - bool ⋮---- """Return True when the Azure model supports reasoning/verbosity options.""" reasoning prefixes = 'o1', 'o3', 'gpt-5' 证据：`graphiti_core/llm_client/azure_openai_client.py`
- **Remove control characters except newlines, returns, and tabs**（source_file）：DEFAULT TEMPERATURE = 0 DEFAULT CACHE DIR = './llm cache' ⋮---- def get extraction language instruction group id: str None = None - str ⋮---- logger = logging.getLogger name ⋮---- def is server or retry error exception ⋮---- class LLMClient ABC ⋮---- def init self, config: LLMConfig None, cache: bool = False ⋮---- config = LLMConfig ⋮---- def set tracer self, tracer: Tracer - None ⋮---- def clean input self, input: str - str ⋮---- cleaned = input.encode 'utf-8', errors='ignore' .decode 'utf-8' ⋮---- zero width = '\u200b\u200c\u200d\ufeff\u2060' ⋮---- cleaned = cleaned.replace char, '' ⋮---- Remove control characters except newlines, returns, and tabs cleaned = ''.join char for char in clean… 证据：`graphiti_core/llm_client/client.py`
- **1. Use explicit parameter if provided**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT MODEL = 'gemini-3-flash-preview' DEFAULT SMALL MODEL = 'gemini-2.5-flash-lite' ⋮---- GEMINI MODEL MAX TOKENS = { ⋮---- DEFAULT GEMINI MAX TOKENS = 8192 ⋮---- class GeminiClient LLMClient ⋮---- MAX RETRIES: ClassVar int = 2 ⋮---- config = LLMConfig ⋮---- def check safety blocks self, response - None ⋮---- candidate = response.candidates 0 ⋮---- safety info = safety ratings = getattr candidate, 'safety ratings', None ⋮---- category = getattr rating, 'category', 'Unknown' probability = getattr rating, 'probability', 'Unknown' ⋮---- safety details = ⋮---- def check prompt blocks self, response - None ⋮---- """Check if prompt was blocked and raise ap… 证据：`graphiti_core/llm_client/gemini_client.py`
- **Fallback: return the full user content**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT MODEL = 'fastino/gliner2-base-v1' DEFAULT THRESHOLD = 0.5 ⋮---- ENTITY EXTRACTION MODEL = 'ExtractedEntities' ⋮---- class GLiNER2Client LLMClient ⋮---- config = LLMConfig ⋮---- model id = config.model or DEFAULT MODEL small model id = config.small model or model id ⋮---- def get model for size self, model size: ModelSize - typing.Any ⋮---- def get provider type self - str ⋮---- @staticmethod def extract text from messages messages: list Message - str ⋮---- user content = messages -1 .content if len messages 1 else messages 0 .content ⋮---- pattern = rf' \s . ? \s ' match = re.search pattern, user content, re.DOTALL ⋮---- Fallback: return the ful… 证据：`graphiti_core/llm_client/gliner2_client.py`
- **Groq Client**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT MODEL = 'llama-3.1-70b-versatile' DEFAULT MAX TOKENS = 2048 ⋮---- class GroqClient LLMClient ⋮---- def init self, config: LLMConfig None = None, cache: bool = False ⋮---- config = LLMConfig max tokens=DEFAULT MAX TOKENS ⋮---- msgs: list ChatCompletionMessageParam = ⋮---- response = await self.client.chat.completions.create result = response.choices 0 .message.content or '' 证据：`graphiti_core/llm_client/groq_client.py`
- **Extract token usage**（source_file）：logger = logging.getLogger name ⋮---- DEFAULT MODEL = 'gpt-4.1-mini' DEFAULT SMALL MODEL = 'gpt-4.1-nano' DEFAULT REASONING = 'minimal' DEFAULT VERBOSITY = 'low' ⋮---- class BaseOpenAIClient LLMClient ⋮---- MAX RETRIES: ClassVar int = 2 ⋮---- config = LLMConfig ⋮---- openai messages: list ChatCompletionMessageParam = ⋮---- def get model for size self, model size: ModelSize - str ⋮---- def handle structured response self, response: Any - tuple dict str, Any , int, int ⋮---- response object = response.output text ⋮---- input tokens = 0 output tokens = 0 ⋮---- input tokens = getattr response.usage, 'input tokens', 0 or 0 output tokens = getattr response.usage, 'output tokens', 0 or 0 ⋮---- def… 证据：`graphiti_core/llm_client/openai_base_client.py`
- **Openai Client**（source_file）：class OpenAIClient BaseOpenAIClient ⋮---- config = LLMConfig ⋮---- is reasoning model = ⋮---- request kwargs = { ⋮---- temperature value = temperature if not is reasoning model else None ⋮---- response = await self.client.responses.parse request kwargs 证据：`graphiti_core/llm_client/openai_client.py`
- 其余 20 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。

## 宿主 AI 必须遵守的规则

- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`README.md`, `mcp_server/README.md`, `server/README.md`
- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`README.md`, `mcp_server/README.md`, `server/README.md`

## 用户开工前应该回答的问题

- 你准备在哪个宿主 AI 或本地环境中使用它？
- 你只是想先体验工作流，还是准备真实安装？
- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？

## 验收标准

- 所有能力声明都能回指到 evidence_refs 中的文件路径。
- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。
- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。

---

## Doramagic Context Augmentation

下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。

## Human Manual 骨架

使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。

宿主 AI 硬性规则：
- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。
- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。
- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。

- **Graphiti 概述**：importance `high`
  - source_paths: README.md, graphiti_core/__init__.py, graphiti_core/graphiti.py
- **核心概念**：importance `high`
  - source_paths: graphiti_core/nodes.py, graphiti_core/edges.py, graphiti_core/graphiti_types.py, graphiti_core/models/nodes/node_db_queries.py, graphiti_core/models/edges/edge_db_queries.py
- **系统架构**：importance `high`
  - source_paths: graphiti_core/graphiti.py, graphiti_core/driver/driver.py, graphiti_core/llm_client/client.py, graphiti_core/search/search.py
- **数据流与摄取管道**：importance `high`
  - source_paths: graphiti_core/graphiti.py, graphiti_core/utils/maintenance/combined_extraction.py, graphiti_core/utils/maintenance/node_operations.py, graphiti_core/utils/maintenance/edge_operations.py, graphiti_core/prompts/extract_nodes_and_edges.py
- **Neo4j 驱动详解**：importance `high`
  - source_paths: graphiti_core/driver/neo4j_driver.py, graphiti_core/driver/neo4j/operations/graph_ops.py, graphiti_core/driver/neo4j/operations/search_ops.py, graphiti_core/driver/neo4j/operations/entity_node_ops.py, graphiti_core/driver/neo4j/operations/entity_edge_ops.py
- **FalkorDB 驱动详解**：importance `high`
  - source_paths: graphiti_core/driver/falkordb_driver.py, graphiti_core/driver/falkordb/operations/search_ops.py, graphiti_core/driver/falkordb/operations/graph_ops.py
- **Kuzu 与 Amazon Neptune 驱动**：importance `medium`
  - source_paths: graphiti_core/driver/kuzu_driver.py, graphiti_core/driver/neptune_driver.py, graphiti_core/driver/kuzu/operations/graph_ops.py, graphiti_core/driver/neptune/operations/graph_ops.py
- **LLM 提供商集成**：importance `high`
  - source_paths: graphiti_core/llm_client/openai_client.py, graphiti_core/llm_client/azure_openai_client.py, graphiti_core/llm_client/gemini_client.py, graphiti_core/llm_client/anthropic_client.py, graphiti_core/llm_client/openai_generic_client.py

## Repo Inspection Evidence / 源码检查证据

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `34f56e65e0fe2096132c8d16f3a1a4ac9300a5f6`
- inspected_files: `pyproject.toml`, `Dockerfile`, `README.md`, `docker-compose.yml`, `uv.lock`, `examples/azure-openai/azure_openai_neo4j.py`, `examples/azure-openai/README.md`, `examples/quickstart/quickstart_falkordb.py`, `examples/quickstart/dense_vs_normal_ingestion.py`, `examples/quickstart/quickstart_neptune.py`, `examples/quickstart/README.md`, `examples/quickstart/quickstart_neo4j.py`, `examples/ecommerce/runner.py`, `examples/podcast/podcast_runner.py`, `examples/podcast/transcript_parser.py`, `examples/data/manybirds_products.json`, `examples/gliner2/gliner2_neo4j.py`, `examples/gliner2/README.md`, `examples/opentelemetry/pyproject.toml`, `examples/opentelemetry/otel_stdout_example.py`

宿主 AI 硬性规则：
- 没有 repo_clone_verified=true 时，不得声称已经读过源码。
- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。
- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。

## Doramagic Pitfall Constraints / 踩坑约束

这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。

### Constraint 1: 来源证据：NaN/Inf values from embedder silently break entity deduplication and propagate to graph storage

- Trigger: GitHub 社区证据显示该项目存在一个配置相关的待验证问题：NaN/Inf values from embedder silently break entity deduplication and propagate to graph storage
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能影响升级、迁移或版本选择。
- Evidence: community_evidence:github | cevd_2328466b52aa45579865c00657e318dd | https://github.com/getzep/graphiti/issues/1505 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 2: 来源证据：[BUG] FalkorDriver.build_fulltext_query fails on hyphens in group_id (RediSearch syntax error)

- Trigger: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：[BUG] FalkorDriver.build_fulltext_query fails on hyphens in group_id (RediSearch syntax error)
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能影响授权、密钥配置或安全边界。
- Evidence: community_evidence:github | cevd_a31b49c7d71646a48dec968318e0ba8b | https://github.com/getzep/graphiti/issues/1483 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 3: 来源证据：Neo4jDriver.__init__:57 schedules orphan create_task without cancel/await pair

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Neo4jDriver.__init__:57 schedules orphan create_task without cancel/await pair
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能影响升级、迁移或版本选择。
- Evidence: community_evidence:github | cevd_b128cabe853b4492945c209b962d8457 | https://github.com/getzep/graphiti/issues/1513 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 4: 来源证据：Suggestion: Standardized retrieval quality benchmarks for temporal knowledge graph queries

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Suggestion: Standardized retrieval quality benchmarks for temporal knowledge graph queries
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | cevd_a62b375e05dd49d18f6807c575566949 | https://github.com/getzep/graphiti/issues/1515 | 来源讨论提到 node 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 5: 来源证据：Your project is ranked #16 on HVTracker — embed a trust badge?

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Your project is ranked #16 on HVTracker — embed a trust badge?
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | cevd_c1d4750319b947bd96a2308a6fe6d3b7 | https://github.com/getzep/graphiti/issues/1518 | 来源类型 github_issue 暴露的待验证使用条件。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 6: 来源证据：add_episode is impractically slow for >5KB content — proposal: skip_extraction parameter

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：add_episode is impractically slow for >5KB content — proposal: skip_extraction parameter
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能阻塞安装或首次运行。
- Evidence: community_evidence:github | cevd_752fa6d991e844c599853b3d9f69b47e | https://github.com/getzep/graphiti/issues/1516 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 7: 能力判断依赖假设

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: 将假设转成下游验证清单。
- Why it matters: 假设不成立时，用户拿不到承诺的能力。
- Evidence: capability.assumptions | github_repo:840056306 | https://github.com/getzep/graphiti | README/documentation is current enough for a first validation pass.
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 8: 来源证据：FalkorDriver.default_group_id ('\_') is rejected by validate_group_id

- Trigger: GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：FalkorDriver.default_group_id ('\_') is rejected by validate_group_id
- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | cevd_2126d3011d414eaf8bd9ce77b0d0ce6f | https://github.com/getzep/graphiti/issues/1517 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 9: 维护活跃度未知

- Trigger: 未记录 last_activity_observed。
- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。
- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- Evidence: evidence.maintainer_signals | github_repo:840056306 | https://github.com/getzep/graphiti | last_activity_observed missing
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 10: 下游验证发现风险项

- Trigger: no_demo
- Host AI rule: 进入安全/权限治理复核队列。
- Why it matters: 下游已经要求复核，不能在页面中弱化。
- Evidence: downstream_validation.risk_items | github_repo:840056306 | https://github.com/getzep/graphiti | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。
