refactor(memory-config): refactor memory config to use workspace models and remove reflection model - #1994
Conversation
…ls and remove reflection model - Remove reflection_model_id from memory config schema, repository, and service - Resolve embedding, llm, rerank, vision, and audio models from workspace defaults instead of per-config overrides - Update redis_cache to support UUID return types and add shared invalidation helpers - Switch emotion_config_service to AsyncSession and drop emotion_model_id validation
审阅者指南(Reviewer's Guide)重构了内存(memory)及相关配置,使其依赖工作区(workspace)级别的模型分配,而不是每个配置的模型 ID;改进了 Redis 缓存行为及失效逻辑;并从 API 和存储中移除了显式的反思(reflection)/情绪(emotion)模型配置,改为依赖工作区模型。 使用工作区 LLM 模型的 reflection_run 时序图sequenceDiagram
actor User
participant MemoryReflectionController
participant MemoryConfigRepository
participant Workspace
participant ModelConfigService
User->>MemoryReflectionController: reflection_run(config_id)
MemoryReflectionController->>MemoryConfigRepository: get_config_with_workspace_async(config_id)
MemoryConfigRepository-->>MemoryReflectionController: (MemoryConfig, Workspace)
MemoryReflectionController->>Workspace: read llm
Workspace-->>MemoryReflectionController: llm_id
MemoryReflectionController->>ModelConfigService: get_model_by_id_async(db, model_id=llm_id, tenant_id)
ModelConfigService-->>MemoryReflectionController: model details
MemoryReflectionController-->>User: reflection result (using workspace.llm)
文件级变更(File-Level Changes)
提示与命令(Tips and commands)与 Sourcery 交互(Interacting with Sourcery)
自定义你的体验(Customizing Your Experience)访问你的 dashboard 来:
获取帮助(Getting Help)Original review guide in EnglishReviewer's GuideRefactors memory and related configs to rely on workspace-level model assignments instead of per-config model IDs, improves Redis cache behavior and invalidation, and removes explicit reflection/emotion model configuration from APIs and storage in favor of workspace models. Sequence diagram for reflection_run using workspace LLM modelsequenceDiagram
actor User
participant MemoryReflectionController
participant MemoryConfigRepository
participant Workspace
participant ModelConfigService
User->>MemoryReflectionController: reflection_run(config_id)
MemoryReflectionController->>MemoryConfigRepository: get_config_with_workspace_async(config_id)
MemoryConfigRepository-->>MemoryReflectionController: (MemoryConfig, Workspace)
MemoryReflectionController->>Workspace: read llm
Workspace-->>MemoryReflectionController: llm_id
MemoryReflectionController->>ModelConfigService: get_model_by_id_async(db, model_id=llm_id, tenant_id)
ModelConfigService-->>MemoryReflectionController: model details
MemoryReflectionController-->>User: reflection result (using workspace.llm)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
API Breaking Change ReportComparing against Breaking change approval label:
oasdiffOutputopenapi-diffOutputGate decisionNo breaking changes detected. The check passed without approval override. |
There was a problem hiding this comment.
Hey - 我在这里给出了一些总体反馈:
- 现在在创建反射配置时,会忽略
config_data中存在的任何reflection_model_id,而是始终从 workspace 的 models 中推导得到;如果这是有意为之,建议从仍然保留该字段的请求/响应负载或代码路径中将其移除,以避免让人误以为用户仍可配置它,从而造成困惑。 - 在
workspace_service.update_workspace中,内存配置缓存的失效前缀为memory_config:{db_workspace.memory_config};如果memory_config是 UUID 或其他非字符串类型,显式地转换为str可能更加安全,以避免出现不易察觉的 key 格式不一致问题。
给 AI Agents 的提示
请根据这次代码审查中的评论进行修改:
## 整体评论
- 现在在创建反射配置时,会忽略 `config_data` 中存在的任何 `reflection_model_id`,而是始终从 workspace 的 models 中推导得到;如果这是有意为之,建议从仍然保留该字段的请求/响应负载或代码路径中将其移除,以避免让人误以为用户仍可配置它,从而造成困惑。
- 在 `workspace_service.update_workspace` 中,内存配置缓存的失效前缀为 `memory_config:{db_workspace.memory_config}`;如果 `memory_config` 是 UUID 或其他非字符串类型,显式地转换为 `str` 可能更加安全,以避免出现不易察觉的 key 格式不一致问题。帮我变得更有用吧!请在每条评论下点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- Reflection config creation now ignores any
reflection_model_idpresent inconfig_dataand always derives it from workspace models; if this is intentional, consider removing the field from any remaining request/response payloads or code paths that still suggest it can be user-configured to avoid confusion. - In
workspace_service.update_workspace, the invalidation prefix for memory config cache ismemory_config:{db_workspace.memory_config}; ifmemory_configis a UUID or other non-string type, it may be safer to explicitly cast tostrto avoid subtle key format inconsistencies.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Reflection config creation now ignores any `reflection_model_id` present in `config_data` and always derives it from workspace models; if this is intentional, consider removing the field from any remaining request/response payloads or code paths that still suggest it can be user-configured to avoid confusion.
- In `workspace_service.update_workspace`, the invalidation prefix for memory config cache is `memory_config:{db_workspace.memory_config}`; if `memory_config` is a UUID or other non-string type, it may be safer to explicitly cast to `str` to avoid subtle key format inconsistencies.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
remove model config from v1/memory_config/update_config_extracted v1/memory_config/update_config_emotion v1/memory_config/update_config_reflection |
Summary by Sourcery
对内存相关配置与工作区级模型设置进行对齐,简化反射/情绪/抽取配置,并改进 Redis 缓存及缓存失效工具。
New Features:
Bug Fixes:
Enhancements:
Documentation:
Chores:
Original summary in English
Summary by Sourcery
Align memory-related configuration with workspace-level model settings, simplify reflection/emotion/extraction configs, and improve Redis caching and cache invalidation utilities.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Chores: