hy-memory 2.0.7__tar.gz → 2.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hy_memory-2.0.7/hy_memory.egg-info → hy_memory-2.0.9}/PKG-INFO +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/README.md +1 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/extractor.py +37 -3
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/llm_provider.py +1 -2
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/mem_agent.py +1 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/prompts_zh.py +31 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/reconciler.py +11 -9
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/tools/base.py +3 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/tools/basic_profile.py +77 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/client.py +19 -13
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/extractor.py +4 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/fact_reconciler.py +15 -6
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/judge.py +21 -10
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/reconciler.py +21 -10
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/store.py +7 -2
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/core/embed_service.py +15 -4
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/reconcile_retrieval.py +6 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/cross_domain_sweeper.py +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/reader_base.py +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/system2_agent.py +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/async_executor.py +4 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/pipeline_log_writer.py +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/pipeline_observability.py +71 -30
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/token_count.py +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9/hy_memory.egg-info}/PKG-INFO +2 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/pyproject.toml +1 -1
- {hy_memory-2.0.7 → hy_memory-2.0.9}/LICENSE +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/MANIFEST.in +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/abstractor.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/emotion_analyzer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/episode_summary.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/intention_detector.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/reflector.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/agent/tools/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/chain_store.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/lexical.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/preproc.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/prompts_zh.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/types.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/coding/writer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/config.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/core/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/core/merger.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/core/scorer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/core/workload.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/cache.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/cache_base.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/cache_mysql.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/cache_sqlite.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/graph_store.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/graph_store_base.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/graph_store_kuzu.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/graph_store_neo4j.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/history_store.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/kv_store.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/rdb.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/vector_store.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/vector_store_base.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/vector_store_chroma.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/vector_store_faiss.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/data/vector_store_qdrant.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/embedding.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/inspector.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/metrics.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/models/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/models/memory.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/models/requests.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_graph/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_graph/projector.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_graph/rerank.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_graph/topic_summary.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/__init__.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/bm25.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/bm25_fastembed.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/candidate_guards.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/config.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/date_view.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/dedup.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/diversity.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/entities.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/entity_store.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/evolution.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/hierarchy_bundle.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/intent.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/intention.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/lemmatize.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/local_rerank.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/memory_format.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/multi_seed_bundle.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/ner.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/profile_evidence.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/profile_owner_gate.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/query_expand.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/record_date_view.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/retrieval_clauses.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/rrf.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/scoring.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/series_tail_guard.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/session_episode.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/strength.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/supplemental_propositions.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/tag_index.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/temporal.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/topic_candidates.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/trace.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/underflow.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/_retrieval/user_level_l0.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/balanced_catalog.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/base.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/reader.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/reader_hybrid.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/reader_legacy.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/registry.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/specific_supplement.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/system2_tools.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/system2_writer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/user_profile_scope.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/pipelines/writer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/retrieval.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/runtime.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/server.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/snapshot.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/structure.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/clone_references.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/keyword_ties.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/lang_detect.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/log_setup.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/metrics.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/model_call_context.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/source_filter.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/time_window.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/trace_file_writer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory/utils/tracer.py +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory.egg-info/SOURCES.txt +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory.egg-info/dependency_links.txt +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory.egg-info/requires.txt +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/hy_memory.egg-info/top_level.txt +0 -0
- {hy_memory-2.0.7 → hy_memory-2.0.9}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hy-memory
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.9
|
|
4
4
|
Summary: HY Memory - Industrial-grade dual-system cognitive memory framework
|
|
5
5
|
Author: alvinfei
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -84,6 +84,7 @@ English | [中文](README.zh.md)
|
|
|
84
84
|
## Latest News
|
|
85
85
|
|
|
86
86
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 🚀 **Open-sourced** quantized **FP8** (**[Hy-Memory-30B-A3B-FP8](https://huggingface.co/tencent/Hy-Memory-30B-A3B-FP8)**) and **GGUF** (**[Hy-Memory-30B-A3B-GGUF](https://huggingface.co/tencent/Hy-Memory-30B-A3B-GGUF)**) versions of **Hy-Memory-30B-A3B** on Hugging Face!
|
|
87
|
+
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 📦 **Released [MemHub v1.0.5](https://github.com/Tencent-Hunyuan/Hy-Memory/releases/tag/v1.0.5)** with Chinese, English and Spanish interfaces, one-time pairing codes for more custom Harnesses, and smoother browsing, search, startup and recovery, on **`hy-memory==2.0.8`**. See the release notes for details.
|
|
87
88
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 📦 **Released [MemHub v1.0.4](https://github.com/Tencent-Hunyuan/Hy-Memory/releases/tag/v1.0.4)** and **[memhub-cli 1.0.5](https://www.npmjs.com/package/memhub-cli/v/1.0.5)**, with a signed macOS desktop app and verified macOS/Linux Runtimes!
|
|
88
89
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 🚀 **Released** **Hy Memory 2.0 (`hy-memory==2.0.4`)** on [PyPI](https://pypi.org/project/hy-memory/2.0.4/) and open-sourced the **Hy-Memory** monorepo together with **[MemHub](memhub/README.md)**!
|
|
89
90
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 🚀 **Open-sourced** **[Hy-Memory-30B-A3B](https://huggingface.co/tencent/Hy-Memory-30B-A3B)** on Hugging Face along with its [technical report](https://arxiv.org/abs/2610.22196) on attributed reinforcement learning for long-term memory writing!
|
|
@@ -33,6 +33,7 @@ English | [中文](README.zh.md)
|
|
|
33
33
|
## Latest News
|
|
34
34
|
|
|
35
35
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 🚀 **Open-sourced** quantized **FP8** (**[Hy-Memory-30B-A3B-FP8](https://huggingface.co/tencent/Hy-Memory-30B-A3B-FP8)**) and **GGUF** (**[Hy-Memory-30B-A3B-GGUF](https://huggingface.co/tencent/Hy-Memory-30B-A3B-GGUF)**) versions of **Hy-Memory-30B-A3B** on Hugging Face!
|
|
36
|
+
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 📦 **Released [MemHub v1.0.5](https://github.com/Tencent-Hunyuan/Hy-Memory/releases/tag/v1.0.5)** with Chinese, English and Spanish interfaces, one-time pairing codes for more custom Harnesses, and smoother browsing, search, startup and recovery, on **`hy-memory==2.0.8`**. See the release notes for details.
|
|
36
37
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 📦 **Released [MemHub v1.0.4](https://github.com/Tencent-Hunyuan/Hy-Memory/releases/tag/v1.0.4)** and **[memhub-cli 1.0.5](https://www.npmjs.com/package/memhub-cli/v/1.0.5)**, with a signed macOS desktop app and verified macOS/Linux Runtimes!
|
|
37
38
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 🚀 **Released** **Hy Memory 2.0 (`hy-memory==2.0.4`)** on [PyPI](https://pypi.org/project/hy-memory/2.0.4/) and open-sourced the **Hy-Memory** monorepo together with **[MemHub](memhub/README.md)**!
|
|
38
39
|
* *<mark>[new]</mark>* 🔥🔥🔥 **[2026-10]**: 🚀 **Open-sourced** **[Hy-Memory-30B-A3B](https://huggingface.co/tencent/Hy-Memory-30B-A3B)** on Hugging Face along with its [technical report](https://arxiv.org/abs/2610.22196) on attributed reinforcement learning for long-term memory writing!
|
|
@@ -682,6 +682,23 @@ Output:
|
|
|
682
682
|
```
|
|
683
683
|
John's occupation and location are HIS attributes, so they go into `memory` with "John" as the subject. They must NEVER land in `basic_info.occupation` / `basic_info.location` — `basic_info` is exclusively the user's own profile. Only `name` (Tim, from the user message's `name` field) belongs there.
|
|
684
684
|
|
|
685
|
+
## Example 11 — Counter-example: small talk has no basic_info
|
|
686
|
+
|
|
687
|
+
New Messages:
|
|
688
|
+
[{"role": "user", "content": "Hi"},
|
|
689
|
+
{"role": "assistant", "content": "Hello! The user's name is The user. How can I help?"}]
|
|
690
|
+
Memory Date: 2025-09-03
|
|
691
|
+
|
|
692
|
+
Output:
|
|
693
|
+
```json
|
|
694
|
+
{
|
|
695
|
+
"memory": [],
|
|
696
|
+
"intentions": [],
|
|
697
|
+
"basic_info": {}
|
|
698
|
+
}
|
|
699
|
+
```
|
|
700
|
+
The user stated nothing about themselves. The assistant's line is not a user turn, and "The user" is a placeholder, not a name. Output `{}` — never `{"name": "The user"}` or `{"name": "user"}`.
|
|
701
|
+
|
|
685
702
|
---
|
|
686
703
|
"""
|
|
687
704
|
|
|
@@ -749,6 +766,14 @@ Rules:
|
|
|
749
766
|
fields (e.g. name, age, location, occupation, employer) **explicitly stated**
|
|
750
767
|
in the NEW user messages. Never infer, never invent. If no field is explicitly
|
|
751
768
|
stated, output `{{}}`.
|
|
769
|
+
* HARD RULE: fill a field ONLY if the user stated it in a `user` turn.
|
|
770
|
+
Anything said only by the assistant (including the assistant quoting an
|
|
771
|
+
earlier memory such as "The user's name is X") does NOT count. If nothing
|
|
772
|
+
qualifies, output `"basic_info": {{}}`.
|
|
773
|
+
* NEVER write the field name itself or a placeholder as a value ("user",
|
|
774
|
+
"The user", "用户", "name", "N/A", "unknown", "none", "-"). Omit the field.
|
|
775
|
+
* Negative example: small talk such as `[user]: Hi` / `[assistant]: How can
|
|
776
|
+
I help?`, or `[user]: Reply with exactly: PONG` → `"basic_info": {{}}`.
|
|
752
777
|
* Exception for `name`: the `name` field on the user's own message, or a leading
|
|
753
778
|
line "The user's name is X" / "用户名叫X", is an authoritative source for
|
|
754
779
|
`name` — even though the user never said it out loud.
|
|
@@ -817,6 +842,14 @@ Rules:
|
|
|
817
842
|
fields (e.g. name, age, location, occupation, employer) **explicitly stated**
|
|
818
843
|
in the NEW user messages. Never infer, never invent. If no field is explicitly
|
|
819
844
|
stated, output `{{}}`.
|
|
845
|
+
* HARD RULE: fill a field ONLY if the user stated it in a `user` turn.
|
|
846
|
+
Anything said only by the assistant (including the assistant quoting an
|
|
847
|
+
earlier memory such as "The user's name is X") does NOT count. If nothing
|
|
848
|
+
qualifies, output `"basic_info": {{}}`.
|
|
849
|
+
* NEVER write the field name itself or a placeholder as a value ("user",
|
|
850
|
+
"The user", "用户", "name", "N/A", "unknown", "none", "-"). Omit the field.
|
|
851
|
+
* Negative example: small talk such as `[user]: Hi` / `[assistant]: How can
|
|
852
|
+
I help?`, or `[user]: Reply with exactly: PONG` → `"basic_info": {{}}`.
|
|
820
853
|
* Exception for `name`: the `name` field on the user's own message, or a leading
|
|
821
854
|
line "The user's name is X" / "用户名叫X", is an authoritative source for
|
|
822
855
|
`name` — even though the user never said it out loud.
|
|
@@ -1177,7 +1210,7 @@ class Extractor:
|
|
|
1177
1210
|
if not tc_id:
|
|
1178
1211
|
logger.error(
|
|
1179
1212
|
f"[extractor] tool_call_id is empty! "
|
|
1180
|
-
f"
|
|
1213
|
+
f"raw_keys={list(tc_raw.keys())}"
|
|
1181
1214
|
)
|
|
1182
1215
|
try:
|
|
1183
1216
|
t_res = await tool_registry.dispatch(
|
|
@@ -1311,11 +1344,12 @@ class Extractor:
|
|
|
1311
1344
|
if parsed is None:
|
|
1312
1345
|
if not all_tool_calls:
|
|
1313
1346
|
logger.warning(
|
|
1314
|
-
f"[extractor] JSON parse failed
|
|
1347
|
+
f"[extractor] JSON parse failed ({len(raw_text)} chars)"
|
|
1315
1348
|
)
|
|
1349
|
+
logger.debug(f"[extractor] unparsable output: {raw_text[:200]!r}")
|
|
1316
1350
|
return ExtractResult(
|
|
1317
1351
|
success=False,
|
|
1318
|
-
error=f"JSON parse failed
|
|
1352
|
+
error=f"JSON parse failed ({len(raw_text)} chars)",
|
|
1319
1353
|
error_code="JSON_PARSE_FAILED",
|
|
1320
1354
|
raw_response=raw_text,
|
|
1321
1355
|
tokens_used=total_tokens,
|
|
@@ -129,8 +129,7 @@ def _parse_tool_calls_list(raw_calls: list, _json) -> List[Dict[str, Any]]:
|
|
|
129
129
|
tc_id = tc.get("id") or ""
|
|
130
130
|
if not tc_id:
|
|
131
131
|
logger.error(
|
|
132
|
-
f"[llm] tool_call missing 'id'!
|
|
133
|
-
f"{_json.dumps(tc, ensure_ascii=False, default=str)[:500]}"
|
|
132
|
+
f"[llm] tool_call missing 'id'! keys={list(tc.keys())}"
|
|
134
133
|
)
|
|
135
134
|
|
|
136
135
|
# 保留原始 tc 完整结构,只规范化 arguments
|
|
@@ -234,7 +234,7 @@ class MemAgent:
|
|
|
234
234
|
f"identity={len(identity)} facts={len(facts)} "
|
|
235
235
|
f"basic_info={basic_field_count}fields"
|
|
236
236
|
)
|
|
237
|
-
logger.
|
|
237
|
+
logger.debug(f"MemAgent: extracted_info={extract_result.info}")
|
|
238
238
|
|
|
239
239
|
# 3. 冲突检测(如果有已有记忆)
|
|
240
240
|
if mode == ProcessMode.FULL and existing_memories:
|
|
@@ -365,6 +365,13 @@ EXTRACT_PROMPT_ZH = """## 最近 k 条消息
|
|
|
365
365
|
* basic_info:**只装用户本人的画像**。
|
|
366
366
|
仅当 NEW user messages 中**明确**陈述稳定画像字段(如 姓名、年龄、所在地、职业、雇主)时才填写。
|
|
367
367
|
绝不推断、绝不编造。没有任何字段被明确陈述时输出 `{{}}`。
|
|
368
|
+
* **硬性规则**:只有用户在 `user` 回合里**明确说出**的字段才能填写。只在
|
|
369
|
+
assistant 回合出现的内容(包括 assistant 引用旧记忆,如"The user's name is X"
|
|
370
|
+
/ "用户名是X")一律不算。没有符合条件的字段时,必须输出 `"basic_info": {{}}`。
|
|
371
|
+
* **绝不**把字段名本身或占位符当值写入("用户"、"The user"、"user"、"name"、
|
|
372
|
+
"姓名"、"N/A"、"unknown"、"未知"、"未提供"、"-"),宁可省略该字段。
|
|
373
|
+
* 负例:寒暄如 `[user]: 你好` / `[assistant]: 我可以帮你。`,或
|
|
374
|
+
`[user]: Reply with exactly: PONG` → `"basic_info": {{}}`。
|
|
368
375
|
* `name` 的例外:用户自己那条消息上的 `name` 字段,或文首形如
|
|
369
376
|
"用户名叫X" / "The user's name is X" 的那一行,都是 `name` 的权威来源
|
|
370
377
|
——即使用户本人从未开口自报姓名。
|
|
@@ -440,6 +447,13 @@ EXTRACT_PROMPT_ZH_NO_INTENTION = """## 最近 k 条消息
|
|
|
440
447
|
* basic_info:**只装用户本人的画像**。
|
|
441
448
|
仅当 NEW user messages 中**明确**陈述稳定画像字段(如 姓名、年龄、所在地、职业、雇主)时才填写。
|
|
442
449
|
绝不推断、绝不编造。没有任何字段被明确陈述时输出 `{{}}`。
|
|
450
|
+
* **硬性规则**:只有用户在 `user` 回合里**明确说出**的字段才能填写。只在
|
|
451
|
+
assistant 回合出现的内容(包括 assistant 引用旧记忆,如"The user's name is X"
|
|
452
|
+
/ "用户名是X")一律不算。没有符合条件的字段时,必须输出 `"basic_info": {{}}`。
|
|
453
|
+
* **绝不**把字段名本身或占位符当值写入("用户"、"The user"、"user"、"name"、
|
|
454
|
+
"姓名"、"N/A"、"unknown"、"未知"、"未提供"、"-"),宁可省略该字段。
|
|
455
|
+
* 负例:寒暄如 `[user]: 你好` / `[assistant]: 我可以帮你。`,或
|
|
456
|
+
`[user]: Reply with exactly: PONG` → `"basic_info": {{}}`。
|
|
443
457
|
* `name` 的例外:用户自己那条消息上的 `name` 字段,或文首形如
|
|
444
458
|
"用户名叫X" / "The user's name is X" 的那一行,都是 `name` 的权威来源
|
|
445
459
|
——即使用户本人从未开口自报姓名。
|
|
@@ -669,6 +683,23 @@ Memory Date:2025-09-02
|
|
|
669
683
|
```
|
|
670
684
|
职业和所在地是 **John 的**属性,所以进 `memory` 并以"John"作主体,**绝不能**落到 `basic_info` 的 `occupation` / `location` —— `basic_info` 专属于用户本人。只有 `name`(Tim,来自用户消息的 `name` 字段)才该放进去。注意输出语言随输入语言(此例为英文)。
|
|
671
685
|
|
|
686
|
+
## 示例 11 —— 反例:寒暄没有 basic_info
|
|
687
|
+
|
|
688
|
+
新消息:
|
|
689
|
+
[{"role": "user", "content": "你好"},
|
|
690
|
+
{"role": "assistant", "content": "你好!我可以帮你。之前记得 The user's name is 用户."}]
|
|
691
|
+
Memory Date:2025-09-03
|
|
692
|
+
|
|
693
|
+
输出:
|
|
694
|
+
```json
|
|
695
|
+
{
|
|
696
|
+
"memory": [],
|
|
697
|
+
"intentions": [],
|
|
698
|
+
"basic_info": {}
|
|
699
|
+
}
|
|
700
|
+
```
|
|
701
|
+
用户没有说任何关于自己的信息。assistant 那句不是 user 回合,"用户" 也是占位符而不是名字。必须输出 `{}`——**绝不能**输出 `{"name": "用户"}`。
|
|
702
|
+
|
|
672
703
|
---
|
|
673
704
|
"""
|
|
674
705
|
|
|
@@ -50,7 +50,7 @@ def is_canonical_state_node(node: Any) -> bool:
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def _log_ops_detail(ops: List["ReconcileOp"]) -> None:
|
|
53
|
-
"""以单条
|
|
53
|
+
"""以单条 DEBUG(JSON list)输出 reconcile 的逐条结果;含记忆正文,不进 INFO。"""
|
|
54
54
|
if not ops:
|
|
55
55
|
return
|
|
56
56
|
view = [
|
|
@@ -68,7 +68,7 @@ def _log_ops_detail(ops: List["ReconcileOp"]) -> None:
|
|
|
68
68
|
}
|
|
69
69
|
for o in ops
|
|
70
70
|
]
|
|
71
|
-
logger.
|
|
71
|
+
logger.debug(
|
|
72
72
|
f"[reconciler] ops detail: {json.dumps(view, ensure_ascii=False, default=str)}"
|
|
73
73
|
)
|
|
74
74
|
|
|
@@ -1514,9 +1514,10 @@ class MemoryReconciler:
|
|
|
1514
1514
|
logger.warning(
|
|
1515
1515
|
f"[reconciler] RECONCILE JSON parse failed "
|
|
1516
1516
|
f"(attempt {_attempt+1}/{_MAX_PARSE_ATTEMPTS}), "
|
|
1517
|
-
f"retrying: raw
|
|
1518
|
-
f"{raw_response[:200] if _log_llm_content_enabled() else '<redacted>'}"
|
|
1517
|
+
f"retrying: raw({len(raw_response or '')} chars)"
|
|
1519
1518
|
)
|
|
1519
|
+
if _log_llm_content_enabled():
|
|
1520
|
+
logger.debug(f"[reconciler] unparsable raw={raw_response[:200]!r}")
|
|
1520
1521
|
|
|
1521
1522
|
recon_elapsed = (_time.perf_counter() - t_recon) * 1000
|
|
1522
1523
|
|
|
@@ -1528,8 +1529,8 @@ class MemoryReconciler:
|
|
|
1528
1529
|
error_code = "LLM_UNAVAILABLE"
|
|
1529
1530
|
elif raw_response.strip():
|
|
1530
1531
|
error_msg = (
|
|
1531
|
-
f"RECONCILE JSON parse failed after {_n_attempts} attempts
|
|
1532
|
-
f"{raw_response
|
|
1532
|
+
f"RECONCILE JSON parse failed after {_n_attempts} attempts "
|
|
1533
|
+
f"({len(raw_response)} chars)"
|
|
1533
1534
|
)
|
|
1534
1535
|
error_code = "JSON_PARSE_FAILED"
|
|
1535
1536
|
else:
|
|
@@ -1806,7 +1807,8 @@ class MemoryReconciler:
|
|
|
1806
1807
|
except Exception as _re:
|
|
1807
1808
|
logger.debug(f"[reconciler] json_repair failed: {_re}")
|
|
1808
1809
|
if data is None:
|
|
1809
|
-
logger.warning(f"[reconciler] failed to parse ops JSON
|
|
1810
|
+
logger.warning(f"[reconciler] failed to parse ops JSON ({len(text)} chars)")
|
|
1811
|
+
logger.debug(f"[reconciler] unparsable ops output: {text[:200]!r}")
|
|
1810
1812
|
return []
|
|
1811
1813
|
|
|
1812
1814
|
if not isinstance(data, list):
|
|
@@ -2018,11 +2020,11 @@ class MemoryReconciler:
|
|
|
2018
2020
|
if clash is not None:
|
|
2019
2021
|
logger.warning(
|
|
2020
2022
|
f"[reconciler] memory_id {clash} already touched by '{touched[clash]}', "
|
|
2021
|
-
f"current op '{op.op}
|
|
2023
|
+
f"current op '{op.op}' dropped"
|
|
2022
2024
|
)
|
|
2023
2025
|
continue
|
|
2024
2026
|
for t in target_ids:
|
|
2025
|
-
touched[t] =
|
|
2027
|
+
touched[t] = op.op
|
|
2026
2028
|
validated.append(op)
|
|
2027
2029
|
|
|
2028
2030
|
return validated
|
|
@@ -211,7 +211,9 @@ def parse_tool_calls_from_json(raw: Any) -> List[ToolCall]:
|
|
|
211
211
|
try:
|
|
212
212
|
args = json.loads(args_raw) if args_raw.strip() else {}
|
|
213
213
|
except json.JSONDecodeError:
|
|
214
|
-
logger.warning(
|
|
214
|
+
logger.warning(
|
|
215
|
+
f"[tools] failed to parse arguments as JSON ({len(args_raw)} chars)"
|
|
216
|
+
)
|
|
215
217
|
args = {}
|
|
216
218
|
elif isinstance(args_raw, dict):
|
|
217
219
|
args = args_raw
|
|
@@ -26,6 +26,8 @@ from __future__ import annotations
|
|
|
26
26
|
|
|
27
27
|
import asyncio
|
|
28
28
|
import logging
|
|
29
|
+
import re
|
|
30
|
+
import unicodedata
|
|
29
31
|
import uuid
|
|
30
32
|
import weakref
|
|
31
33
|
from dataclasses import dataclass
|
|
@@ -208,6 +210,76 @@ def _sanitize_kv(
|
|
|
208
210
|
return result
|
|
209
211
|
|
|
210
212
|
|
|
213
|
+
# ================================================================
|
|
214
|
+
# 占位符守卫(P0-1)
|
|
215
|
+
# ================================================================
|
|
216
|
+
# 弱模型(如 qwen3.5-2b)在用户什么都没说时,会把 schema 字段说明里的词当值
|
|
217
|
+
# 填进 basic_info:{"name": "用户"} / "The user" / "N/A"。每个占位符都会
|
|
218
|
+
# supersede 掉真实值,演化链变成 费天翔 → Fei → 用户 → The user。
|
|
219
|
+
# 规则:占位符永远不入库;读侧组装 KV 时占位符也不覆盖已有真实值。
|
|
220
|
+
|
|
221
|
+
_PLACEHOLDER_VALUES = frozenset({
|
|
222
|
+
"用户", "该用户", "本用户", "用户本人",
|
|
223
|
+
"the user", "the user's", "user", "a user", "this user",
|
|
224
|
+
"n/a", "na", "none", "null", "nil", "unknown", "unspecified",
|
|
225
|
+
"not provided", "not specified", "not mentioned",
|
|
226
|
+
"未提供", "未知", "不详", "未说明", "未提及", "无",
|
|
227
|
+
"-", "?",
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
# 内置字段的中文标签:弱模型也会把字段说明的中文词当值。
|
|
231
|
+
_FIELD_LABELS: Dict[str, tuple] = {
|
|
232
|
+
"name": ("姓名", "名字", "用户名", "用户姓名", "用户名字"),
|
|
233
|
+
"age": ("年龄", "用户年龄"),
|
|
234
|
+
"location": ("所在地", "地点", "城市", "用户所在地"),
|
|
235
|
+
"occupation": ("职业", "工作", "用户职业"),
|
|
236
|
+
"employer": ("雇主", "公司", "用户雇主"),
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
# 去掉标点/符号后再比较,让 "The user." / "用户。" / "N/A" 都命中。
|
|
240
|
+
# "-" / "?" 本身就是纯标点,剥完为空串,同样判为占位符。
|
|
241
|
+
_PUNCT_RE = re.compile(r"[\s\.,;:!?'\"`~()\[\]{}<>/\\|_\-\u3000-\u303f\uff00-\uff0f\uff1a-\uff20]+")
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _placeholder_key(value: str) -> str:
|
|
245
|
+
s = unicodedata.normalize("NFKC", str(value or "")).strip().lower()
|
|
246
|
+
s = s.replace("\u2019", "'")
|
|
247
|
+
s = _PUNCT_RE.sub(" ", s)
|
|
248
|
+
return " ".join(s.split())
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
_PLACEHOLDER_KEYS = frozenset(_placeholder_key(v) for v in _PLACEHOLDER_VALUES)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def is_placeholder_value(field_name: str, value: Any) -> bool:
|
|
255
|
+
"""value 是否为占位符(空 / 用户 / The user / N/A / 字段名本身 等)。
|
|
256
|
+
|
|
257
|
+
大小写不敏感、首尾空白与标点不敏感。数字(如 age=30)永远不是占位符。
|
|
258
|
+
"""
|
|
259
|
+
if value is None:
|
|
260
|
+
return True
|
|
261
|
+
if isinstance(value, bool):
|
|
262
|
+
return False
|
|
263
|
+
if isinstance(value, (int, float)):
|
|
264
|
+
return False
|
|
265
|
+
key = _placeholder_key(value)
|
|
266
|
+
if not key:
|
|
267
|
+
return True
|
|
268
|
+
if key in _PLACEHOLDER_KEYS:
|
|
269
|
+
return True
|
|
270
|
+
field_key = _placeholder_key(field_name)
|
|
271
|
+
if field_key and key in (field_key, field_key.replace("_", " ")):
|
|
272
|
+
return True
|
|
273
|
+
for label in _FIELD_LABELS.get(field_name, ()):
|
|
274
|
+
if key == _placeholder_key(label):
|
|
275
|
+
return True
|
|
276
|
+
return False
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _drop_placeholders(kv: Dict[str, Any]) -> Dict[str, Any]:
|
|
280
|
+
return {k: v for k, v in kv.items() if not is_placeholder_value(k, v)}
|
|
281
|
+
|
|
282
|
+
|
|
211
283
|
# ================================================================
|
|
212
284
|
# 公共入口:upsert_basic_profile
|
|
213
285
|
# ================================================================
|
|
@@ -287,6 +359,8 @@ async def _upsert_basic_profile_unlocked(
|
|
|
287
359
|
# L0 Basic Info 从输入、唯一性到落盘都只属于 user_id。
|
|
288
360
|
|
|
289
361
|
new_kv = _sanitize_kv(kv or {}, allowed_fields=allowed_fields)
|
|
362
|
+
# 单调性守卫:占位符永远不覆盖已有值,过滤后为空就不写新版本、不产生新链头。
|
|
363
|
+
new_kv = _drop_placeholders(new_kv)
|
|
290
364
|
if not new_kv:
|
|
291
365
|
return BasicProfileUpsertResult(
|
|
292
366
|
success=True, changed=False, reason="no valid fields after sanitize"
|
|
@@ -513,5 +587,8 @@ def _assemble_full_kv_from_nodes(
|
|
|
513
587
|
for k, v in kv.items():
|
|
514
588
|
if allowed_set is not None and k not in allowed_set:
|
|
515
589
|
continue
|
|
590
|
+
# 历史上已落盘的占位符版本(如 name=用户)不覆盖更早的真实值。
|
|
591
|
+
if is_placeholder_value(k, v):
|
|
592
|
+
continue
|
|
516
593
|
full_kv[k] = v
|
|
517
594
|
return full_kv
|
|
@@ -744,7 +744,7 @@ class HyMemoryClient:
|
|
|
744
744
|
def _install_pipeline_observability_hooks(self) -> None:
|
|
745
745
|
"""
|
|
746
746
|
包装 cache.store_pipeline_log:
|
|
747
|
-
- Log:JSONL
|
|
747
|
+
- Log:JSONL 文件,由 MEMORY_PIPELINE_LOG_ENABLED 控制(默认开启)
|
|
748
748
|
- Trace:SQLite pipeline_logs,由 MEMORY_PIPELINE_TRACE_ENABLED 控制(Inspector)
|
|
749
749
|
- 落盘 fire-and-forget,不阻塞 search/write 热路径
|
|
750
750
|
"""
|
|
@@ -958,7 +958,7 @@ class HyMemoryClient:
|
|
|
958
958
|
parsed_tool_calls = json.loads(raw_tool_calls) if raw_tool_calls else []
|
|
959
959
|
except Exception:
|
|
960
960
|
logger.warning(
|
|
961
|
-
"tool_calls 是非法 JSON
|
|
961
|
+
"tool_calls 是非法 JSON 字符串,已忽略 (%d chars)", len(raw_tool_calls)
|
|
962
962
|
)
|
|
963
963
|
parsed_tool_calls = []
|
|
964
964
|
raw_tool_calls = parsed_tool_calls if isinstance(parsed_tool_calls, list) else []
|
|
@@ -3008,13 +3008,13 @@ class HyMemoryClient:
|
|
|
3008
3008
|
f"[add] writing {preview} user={uid} "
|
|
3009
3009
|
f"agent_id={agent_id} session_id={session_id} mode={self._mode}"
|
|
3010
3010
|
)
|
|
3011
|
-
logger.
|
|
3011
|
+
logger.debug(f"[add] messages detail: {[m.to_dict() for m in chat_messages]}")
|
|
3012
3012
|
else:
|
|
3013
3013
|
logger.info(
|
|
3014
3014
|
f"[add] writing text({len(content)} chars) user={uid} "
|
|
3015
|
-
f"agent_id={agent_id} session_id={session_id} mode={self._mode}
|
|
3016
|
-
f"content={content}"
|
|
3015
|
+
f"agent_id={agent_id} session_id={session_id} mode={self._mode}"
|
|
3017
3016
|
)
|
|
3017
|
+
logger.debug(f"[add] text content={content!r}")
|
|
3018
3018
|
|
|
3019
3019
|
# mode → agent_mode 映射
|
|
3020
3020
|
# lite: 不调 LLM agent
|
|
@@ -4034,14 +4034,14 @@ class HyMemoryClient:
|
|
|
4034
4034
|
decided_variant = HyMemoryClient._scene_variant(scene)
|
|
4035
4035
|
logger.info(
|
|
4036
4036
|
f"[search] scene explicit={decided_scene} (no LLM judge); "
|
|
4037
|
-
f"target
|
|
4037
|
+
f"target({len(effective_target_query or '')} chars)"
|
|
4038
4038
|
)
|
|
4039
4039
|
elif not agentic_enabled and not queries_supplied:
|
|
4040
4040
|
# 默认 light search 仅指 query="...":固定 normal,绝不调用 LLM。
|
|
4041
4041
|
decided_scene = "normal"
|
|
4042
4042
|
logger.info(
|
|
4043
4043
|
f"[search] search_mode=default single-query scene=normal (no LLM); "
|
|
4044
|
-
f"target
|
|
4044
|
+
f"target({len(target_query or '')} chars)"
|
|
4045
4045
|
)
|
|
4046
4046
|
elif agentic_enabled:
|
|
4047
4047
|
# agentic:单/多 query 都强制一次 LLM 完成三分类 + rewrite + 时间解析。
|
|
@@ -4076,14 +4076,18 @@ class HyMemoryClient:
|
|
|
4076
4076
|
rewrite_created_after = ar.get("created_after")
|
|
4077
4077
|
logger.info(
|
|
4078
4078
|
f"[search] agentic scene={decided_scene} via rewrite-LLM "
|
|
4079
|
-
f"(classify={want_classify});
|
|
4080
|
-
f"effective={effective_target_query!r} rewrite_used={rewrite_used} "
|
|
4079
|
+
f"(classify={want_classify}); rewrite_used={rewrite_used} "
|
|
4081
4080
|
f"created_after={rewrite_created_after}"
|
|
4082
4081
|
)
|
|
4082
|
+
logger.debug(
|
|
4083
|
+
f"[search] agentic rewrite: orig={target_query!r} "
|
|
4084
|
+
f"effective={effective_target_query!r}"
|
|
4085
|
+
)
|
|
4083
4086
|
else:
|
|
4084
4087
|
decided_scene = "normal"
|
|
4085
4088
|
logger.info(
|
|
4086
|
-
f"[search] agentic rewrite-LLM fallback=normal;
|
|
4089
|
+
f"[search] agentic rewrite-LLM fallback=normal; "
|
|
4090
|
+
f"target({len(target_query or '')} chars)"
|
|
4087
4091
|
)
|
|
4088
4092
|
elif rewrite_enabled and not _too_long:
|
|
4089
4093
|
# default + queries= 的原逻辑:配置开启时一次 LLM 做 rewrite/time,
|
|
@@ -4162,7 +4166,7 @@ class HyMemoryClient:
|
|
|
4162
4166
|
decided_scene = "normal"
|
|
4163
4167
|
logger.info(
|
|
4164
4168
|
f"[search] default multi-query features disabled; no LLM; "
|
|
4165
|
-
f"target
|
|
4169
|
+
f"target({len(target_query or '')} chars)"
|
|
4166
4170
|
)
|
|
4167
4171
|
|
|
4168
4172
|
# ────────────────────────────────────────────────────────────
|
|
@@ -4215,7 +4219,7 @@ class HyMemoryClient:
|
|
|
4215
4219
|
else:
|
|
4216
4220
|
logger.info(
|
|
4217
4221
|
f"[search] routing to PRODUCTIVITY path variant={decided_variant}: "
|
|
4218
|
-
f"target
|
|
4222
|
+
f"target({len(effective_target_query or '')} chars) "
|
|
4219
4223
|
f"workspace_id={workspace_id!r} branch={branch!r}"
|
|
4220
4224
|
)
|
|
4221
4225
|
return await self._search_coding(
|
|
@@ -4243,9 +4247,11 @@ class HyMemoryClient:
|
|
|
4243
4247
|
# Chat 召回链路(原有逻辑)
|
|
4244
4248
|
# ────────────────────────────────────────────────────────────
|
|
4245
4249
|
logger.info(
|
|
4246
|
-
f"[search] query
|
|
4250
|
+
f"[search] query({len(effective_target_query or '')} chars) "
|
|
4251
|
+
f"user_ids={effective_user_ids} "
|
|
4247
4252
|
f"agent_ids={effective_agent_ids} session_ids={effective_session_ids} limit={limit}"
|
|
4248
4253
|
)
|
|
4254
|
+
logger.debug(f"[search] query={effective_target_query!r}")
|
|
4249
4255
|
|
|
4250
4256
|
# rewrite 抽出的时间下界与用户显式 created_after 取更晚者(更严格)
|
|
4251
4257
|
effective_created_after = created_after
|
|
@@ -1166,7 +1166,10 @@ class CodingMemoryExtractor:
|
|
|
1166
1166
|
obj = None
|
|
1167
1167
|
|
|
1168
1168
|
if not isinstance(obj, dict):
|
|
1169
|
-
logger.warning(
|
|
1169
|
+
logger.warning(
|
|
1170
|
+
f"[coding-extract] failed to parse output ({len(text or '')} chars)"
|
|
1171
|
+
)
|
|
1172
|
+
logger.debug(f"[coding-extract] unparsable output: {text!r}")
|
|
1170
1173
|
return [], []
|
|
1171
1174
|
|
|
1172
1175
|
# "memories" 是双层化之前的 key,老 prompt 缓存 / 旧模型可能还这么回
|
|
@@ -570,9 +570,12 @@ class WorkingFactReconciler:
|
|
|
570
570
|
kept.append(fact)
|
|
571
571
|
if blocked:
|
|
572
572
|
logger.info(
|
|
573
|
-
f"[fact-reconcile] subject gate blocked {len(blocked)} candidate(s) "
|
|
574
|
-
|
|
575
|
-
|
|
573
|
+
f"[fact-reconcile] subject gate blocked {len(blocked)} candidate(s): "
|
|
574
|
+
+ ", ".join(f.fact_id for f in blocked)
|
|
575
|
+
)
|
|
576
|
+
logger.debug(
|
|
577
|
+
f"[fact-reconcile] subject gate: draft subject={draft.subject!r} "
|
|
578
|
+
f"blocked subjects={[f.subject for f in blocked]!r}"
|
|
576
579
|
)
|
|
577
580
|
result.append(kept)
|
|
578
581
|
return result
|
|
@@ -745,7 +748,10 @@ class WorkingFactReconciler:
|
|
|
745
748
|
obj = None
|
|
746
749
|
|
|
747
750
|
if not isinstance(obj, dict):
|
|
748
|
-
logger.warning(
|
|
751
|
+
logger.warning(
|
|
752
|
+
f"[fact-reconcile] failed to parse ops output ({len(text or '')} chars)"
|
|
753
|
+
)
|
|
754
|
+
logger.debug(f"[fact-reconcile] unparsable ops output: {text!r}")
|
|
749
755
|
return {}
|
|
750
756
|
ops_raw = obj.get("ops")
|
|
751
757
|
if not isinstance(ops_raw, list):
|
|
@@ -835,8 +841,11 @@ class WorkingFactReconciler:
|
|
|
835
841
|
# 别的主体的状态不是。闸门关掉时这道复查一并跳过,否则闸门就没关干净。
|
|
836
842
|
if self.subject_gate and _subject_conflict(draft.subject, old.subject):
|
|
837
843
|
logger.warning(
|
|
838
|
-
f"[fact-reconcile] refused cross-subject SUPERSEDE: "
|
|
839
|
-
|
|
844
|
+
f"[fact-reconcile] refused cross-subject SUPERSEDE: {old.fact_id}"
|
|
845
|
+
)
|
|
846
|
+
logger.debug(
|
|
847
|
+
f"[fact-reconcile] cross-subject: old subject={old.subject!r} "
|
|
848
|
+
f"draft subject={draft.subject!r}"
|
|
840
849
|
)
|
|
841
850
|
continue
|
|
842
851
|
try:
|
|
@@ -195,8 +195,10 @@ async def classify_messages_scene(
|
|
|
195
195
|
result = _parse_scene_json(resp.content)
|
|
196
196
|
if result is None:
|
|
197
197
|
logger.warning(
|
|
198
|
-
f"[coding-judge] failed to parse classify_messages output
|
|
198
|
+
f"[coding-judge] failed to parse classify_messages output "
|
|
199
|
+
f"({len(resp.content or '')} chars); defaulting to chat"
|
|
199
200
|
)
|
|
201
|
+
logger.debug(f"[coding-judge] unparsable classify_messages output: {resp.content!r}")
|
|
200
202
|
await _store_coding_log(
|
|
201
203
|
cache, request_id=request_id, user_id=user_id, agent_id=agent_id,
|
|
202
204
|
session_id=session_id, step="CODING_JUDGE", prompt=prompt,
|
|
@@ -207,9 +209,8 @@ async def classify_messages_scene(
|
|
|
207
209
|
return "chat"
|
|
208
210
|
scene = result["scene"]
|
|
209
211
|
parsed = {**result, "is_coding": scene != "chat"}
|
|
210
|
-
logger.info(
|
|
211
|
-
|
|
212
|
-
)
|
|
212
|
+
logger.info(f"[coding-judge] scene={scene}")
|
|
213
|
+
logger.debug(f"[coding-judge] scene={scene} reason={result.get('reason', '')!r}")
|
|
213
214
|
await _store_coding_log(
|
|
214
215
|
cache, request_id=request_id, user_id=user_id, agent_id=agent_id,
|
|
215
216
|
session_id=session_id, step="CODING_JUDGE", prompt=prompt,
|
|
@@ -295,8 +296,10 @@ async def classify_queries_scene(
|
|
|
295
296
|
result = _parse_scene_json(resp.content)
|
|
296
297
|
if result is None:
|
|
297
298
|
logger.warning(
|
|
298
|
-
f"[coding-judge] failed to parse classify_queries output
|
|
299
|
+
f"[coding-judge] failed to parse classify_queries output "
|
|
300
|
+
f"({len(resp.content or '')} chars); defaulting to chat"
|
|
299
301
|
)
|
|
302
|
+
logger.debug(f"[coding-judge] unparsable classify_queries output: {resp.content!r}")
|
|
300
303
|
return "chat"
|
|
301
304
|
scene = result["scene"]
|
|
302
305
|
logger.info(f"[coding-judge] queries scene={scene}")
|
|
@@ -422,15 +425,18 @@ async def classify_and_rewrite_queries(
|
|
|
422
425
|
scene = _parse_scene_label(head)
|
|
423
426
|
if scene is None:
|
|
424
427
|
logger.warning(
|
|
425
|
-
f"[coding-judge] classify_and_rewrite unrecognized head
|
|
428
|
+
f"[coding-judge] classify_and_rewrite unrecognized head "
|
|
429
|
+
f"({len(head)} chars); falling back to chat"
|
|
426
430
|
)
|
|
431
|
+
logger.debug(f"[coding-judge] classify_and_rewrite unrecognized head={head!r}")
|
|
427
432
|
return {"scene": "chat", "is_coding": False, "rewrite_query": rewrite, "ok": False}
|
|
428
433
|
is_coding = scene != "chat"
|
|
429
434
|
|
|
430
435
|
logger.info(
|
|
431
436
|
f"[coding-judge] classify_and_rewrite scene={scene} "
|
|
432
|
-
f"rewrite
|
|
437
|
+
f"rewrite({len(rewrite)} chars)"
|
|
433
438
|
)
|
|
439
|
+
logger.debug(f"[coding-judge] classify_and_rewrite rewrite={rewrite!r}")
|
|
434
440
|
return {"scene": scene, "is_coding": is_coding, "rewrite_query": rewrite, "ok": True}
|
|
435
441
|
|
|
436
442
|
|
|
@@ -569,8 +575,9 @@ async def analyze_queries(
|
|
|
569
575
|
parsed_scene = _parse_scene_label(head)
|
|
570
576
|
if parsed_scene is None:
|
|
571
577
|
logger.warning(
|
|
572
|
-
f"[coding-judge] analyze_queries unrecognized head
|
|
578
|
+
f"[coding-judge] analyze_queries unrecognized head ({len(head)} chars); ok=False"
|
|
573
579
|
)
|
|
580
|
+
logger.debug(f"[coding-judge] analyze_queries unrecognized head={head!r}")
|
|
574
581
|
return {**fallback, "since_raw": ""}
|
|
575
582
|
scene = parsed_scene
|
|
576
583
|
idx = 1
|
|
@@ -589,9 +596,10 @@ async def analyze_queries(
|
|
|
589
596
|
created_after = _since_to_created_after(since_raw, current_time)
|
|
590
597
|
|
|
591
598
|
logger.info(
|
|
592
|
-
f"[coding-judge] analyze scene={scene} rewrite
|
|
599
|
+
f"[coding-judge] analyze scene={scene} rewrite({len(rewrite)} chars) "
|
|
593
600
|
f"since={since_raw!r} created_after={created_after}"
|
|
594
601
|
)
|
|
602
|
+
logger.debug(f"[coding-judge] analyze rewrite={rewrite!r}")
|
|
595
603
|
return {
|
|
596
604
|
"scene": scene, "is_coding": scene != "chat", "rewrite_query": rewrite,
|
|
597
605
|
"created_after": created_after, "since_raw": since_raw, "ok": True,
|
|
@@ -614,7 +622,10 @@ def _since_to_created_after(since_raw: str, current_time: str) -> Optional[float
|
|
|
614
622
|
return dt.timestamp()
|
|
615
623
|
except (ValueError, TypeError):
|
|
616
624
|
continue
|
|
617
|
-
logger.warning(
|
|
625
|
+
logger.warning(
|
|
626
|
+
f"[coding-judge] analyze_queries unparsable SINCE ({len(since_raw)} chars)"
|
|
627
|
+
)
|
|
628
|
+
logger.debug(f"[coding-judge] analyze_queries unparsable SINCE={since_raw!r}")
|
|
618
629
|
return None
|
|
619
630
|
|
|
620
631
|
|