Commit Graph
76 Commits
Author SHA1 Message Date
chenjwandqin-ctx ed1bd4b897 refactor(memory): 统一 V3 提取并提升会话提交与评测稳定性 (#3346)
* fix(memory): disable unsupported tool and skill extraction

* refactor(memory): retire SessionCompressorV2

* docs: design service import cycle fix

* fix(import): break QueueFS service import cycle

* update

* docs: design memory overview lock coverage fix

* fix(memory): cover overview files in update leases

* docs: design session commit default concurrency 50

* perf(queue): raise session commit concurrency to 50

* docs: revise session commit concurrency design

* docs: plan session commit default 8

* perf(queue): default session commit concurrency to 8

* fix(bot): disable cron during eval chat

* docs: design memory link lock stabilization

* docs: plan memory link lock stabilization

* fix(memory): stabilize link update lock coverage

* docs: cover remapped post-group link locks

* docs: design plain-content patch validation

* docs: design first failing patch diagnostics

* fix: report actual failing patch block

* fix(memory): remap replacement links before locking

* fix(bot): include trusted identity in health probe

* test: consolidate memory contract coverage

---------

Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
2026-08-13 21:48:49 +08:00
Qin Haojie 9d5cbae70e fix(examples): align quick start with server mode (#3923) 2026-08-10 20:59:35 +08:00
Qin Haojie 7abd6ab249 refactor(client): remove Python embedded mode (#3712)
* refactor(client): remove Python embedded mode

Consolidate Python consumers on the HTTP SDK while keeping shared server and storage capabilities unchanged.

* refactor(client): remove obsolete embedded leftovers
2026-08-10 18:00:00 +08:00
Jiahui Zhou 1d02a72b2b Remove qdrant and opengauss vector backends (#3872) 2026-08-07 19:57:45 +08:00
Hao Zhe b2e1972610 refactor(langchain): extract standalone integration package (#3685)
* refactor(langchain): extract standalone integration package

* fix(langchain): preserve optional legacy imports

* fix(langchain): guard legacy submodule imports
2026-08-03 15:01:13 +08:00
Hao Zhe c1d38eb47f feat(langchain): support request-scoped actor peers (#3626) 2026-08-01 22:55:33 +08:00
zihengli 36d419aaa6 fix:openviking assets import external connector switch (#3634)
* fix:openviking assets import external connector switch

* fix(tests): update quick-start fake embedder compatibility

* fix:openviking assets import external connector switch

* fix:openviking assets import external connector switch
2026-07-31 13:55:41 +08:00
Hao Zhe d2082ad2f7 fix(langchain): manage context wrapper resources (#3599)
Give with_openviking_context a deterministic lifecycle owner, reuse adapter clients without sharing invocation state, and preserve loop-scoped async behavior. Make component copies lifecycle-safe and reject post-close use before history access.
2026-07-30 14:30:02 +08:00
baojun-zhang 2f9451231e refactor(pathlock):using rust implement instead python (#3602)
* refactor(pathlock):using rust implement instead python

* refactor(pathlock):using rust implement instead python

* refactor(pathlock):using rust implement instead python

* refactor(pathlock):optimize unit test code

* refactor(pathlock):optimize encryption create func

* refactor(pathlock):avoid releasing handoffed pathlock on enqueue errors

* fix(pathlock): use owned lease capability and handle S3 create-new 409 as conflict

* fix(ragfs): keep original FsContext for multi-write metadata

* fix(pathlock): resolve lease coverage and CAS handling issues

- detect S3 conditional conflicts from structured service errors
- pass transaction leases when deleting skill roots
- let temp cleanup acquire locks for temp paths
- disambiguate cache and pathlock providers in cache tests
- update temp cleanup lease assertions

* fix(ragfs): bypass pathlock for multi-write metadata

* fix(ragfs): revert pathlock fail-fast design

* fix(ragfs):fix(ragfs): use non-blocking fcntl locks for localfs CAS

* fix(ragfs): serialize heartbeat lease refresh with release and report real conflict kind

* fix(ragfs): preserve conflict kind snapshot and drop unused test scaffolding

* fix(ragfs): preserve conflict kind snapshot and drop unused test scaffolding
2026-07-29 19:45:34 +08:00
Hao Zhe 8db65ea9de fix(langchain): isolate async history and preserve cancellation semantics (#3575)
* fix(langchain): make async recording concurrency-safe

* fix(langchain): scope async state to each invocation

* fix(langchain): preserve cancellation progress on Python 3.10
2026-07-29 12:02:29 +08:00
baojun-zhang 1841dfed81 Revert "refactor(pathlock):using rust implement instead python (#3557)" (#3597)
This reverts commit 6b538db569.
2026-07-29 11:31:41 +08:00
baojun-zhang 6b538db569 refactor(pathlock):using rust implement instead python (#3557)
* refactor(pathlock):using rust implement instead python

* refactor(pathlock):using rust implement instead python

* refactor(pathlock):using rust implement instead python

* refactor(pathlock):optimize unit test code

* refactor(pathlock):optimize encryption create func

* refactor(pathlock):avoid releasing handoffed pathlock on enqueue errors

* fix(pathlock): use owned lease capability and handle S3 create-new 409 as conflict

* fix(ragfs): keep original FsContext for multi-write metadata

* fix(pathlock): resolve lease coverage and CAS handling issues

- detect S3 conditional conflicts from structured service errors
- pass transaction leases when deleting skill roots
- let temp cleanup acquire locks for temp paths
- disambiguate cache and pathlock providers in cache tests
- update temp cleanup lease assertions

* fix(ragfs): bypass pathlock for multi-write metadata

* fix(ragfs): revert pathlock fail-fast design
2026-07-29 11:08:42 +08:00
Hao Zhe 8eb89a636b feat(langchain): add native async integration support (#3536)
* feat(langchain): add native async integration support

* fix(langchain): make async client lifecycle safe

* fix(langchain): make async lifecycle loop-safe

* docs(langchain): clarify async lifecycle invariants
2026-07-28 14:35:02 +08:00
Hao Zhe ea6e2dbb41 feat(integrations): unify LangChain and LangGraph session recording (#3530)
* feat(integrations): add reusable LangChain session recorder

* fix(integrations): harden session recorder retries
2026-07-27 18:27:56 +08:00
Qin Haojie d47f2106ee refactor: remove unused and deprecated APIs (#3272)
Delete dead compatibility paths and test-only helpers so unsupported APIs do not remain as accidental contracts.
2026-07-16 10:49:56 +08:00
Qin Haojie ca70bc0649 refactor(embedding): remove unused batch APIs (#3260) 2026-07-15 16:44:57 +08:00
chenjw 7c5716cb4b Fix/ 修复兼容逻辑加入assistent消息的peerid后,user记忆会归入peer目录的问题 (#3132)
* session: prefer self for missing peer memory

* fix

* session: split message peer id scope

* Revert "session: split message peer id scope"

This reverts commit 853f1c6b9b.

* session: include all message peer ids in scope
2026-07-10 21:51:51 +08:00
chenjwandClaude fd73dcf23a Feat/自进化(经验记忆)框架重构 (#2503)
* Add trajectory experience learning redesign doc

* auto-commit before eval 20260607_043406

* auto-commit before eval 20260607_044129

* auto-commit before eval 20260607_123706

* auto-commit before eval 20260607_125514

* auto-commit before eval 20260607_133737

* auto-commit before eval 20260607_144649

* auto-commit before eval 20260607_154631

* Refine streaming memory train merge pipeline

* Refine session train policy optimization architecture

* Add VikingMem ARA paper analysis

* Force merge for mixed extraction memory patches

* auto-commit before eval 20260608_134426

* auto-commit before eval 20260608_142108

* auto-commit before eval 20260608_153909

* auto-commit before eval 20260608_154845

* auto-commit before eval 20260608_170143

* update

* auto-commit before eval 20260611_150946

* auto-commit before eval 20260611_153933

* auto-commit before eval 20260611_154251

* Fix tau2 reward wrapper call

* auto-commit before eval 20260611_193803

* auto-commit before eval 20260611_194939

* update

* auto-commit before eval 20260612_111029

* auto-commit before eval 20260612_112104

* auto-commit before eval 20260612_122603

* auto-commit before eval 20260612_123359

* auto-commit before eval 20260612_124303

* auto-commit before eval 20260612_130257

* Fallback peer routing to first conversation peer

* Route self memory through self peer sentinel

* Keep self sentinel out of peer memory paths

* auto-commit before eval 20260612_154051

* auto-commit before eval 20260612_154850

* auto-commit before eval 20260612_161633

* auto-commit before eval 20260612_184022

* auto-commit before eval 20260612_201845

* auto-commit before eval 20260612_202637

* auto-commit before eval 20260612_204040

* auto-commit before eval 20260612_224621

* Fix locomo progress column initialization

* Add memory field versioning

* auto-commit before eval 20260612_232318

* Simplify locomo progress display

* Remove locomo progress elapsed time

* Batch streaming memory merges by group

* Derive patch merge language from patches

* Detect patch merge language from updated files

* auto-commit before eval 20260613_004339

* auto-commit before eval 20260613_005835

* Persist memory update trace id

* auto-commit before eval 20260613_012722

* auto-commit before eval 20260613_013923

* auto-commit before eval 20260613_014708

* Enforce peer scope after memory merge

* auto-commit before eval 20260613_033402

* auto-commit before eval 20260613_151931

* auto-commit before eval 20260613_164217

* chore: raise vikingbot eval parallelism

* chore: tune vikingbot parallelism to 150

* auto-commit before eval 20260613_185807

* chore: restore vikingbot parallelism default

* feat(locomo): add import progress reporting

* chore(memory): restore profile and preference templates

* Fix tau2 reward JSON serialization

* Refactor tau2 batch memory training

* Stream batch train JSONL events

* Add fast path for batch training case specs

* Optimize streaming train gradient chunking

* Optimize patch merge prompt context

* fix tau2 memory training vectorization

* fix(memory): revert profile preference granularity rules

* bd init: initialize beads issue tracking

* update

* Log memory template fallback failures

* Record all rollout artifacts

* Fix OpenViking peer search forwarding

* Stop tracking Beads local state

* auto-commit before eval 20260616_002037

* Deprecate memory version selector

* Retry transient LoCoMo import HTTP failures

* Add memory schema stage and peer routing

* Organize LoCoMo benchmark outputs

* Restore VikingBot user memory auto recall

* Show elapsed time on LoCoMo progress bars

* Quiet transient import retries

* Shorten LoCoMo progress bars

* Route non-peer memories to self scope

* auto-commit before eval 20260616_124513

* Suppress memory read not found logs

* Limit LoCoMo import memory types

* Rename peer routing schema flag

* Rename peer schema flag to enable_peer

* Rename schema peer flag to peer_enabled

* auto-commit before eval 20260616_135946

* auto-commit before eval 20260616_140641

* auto-commit before eval 20260616_141753

* Show cached baseline eval at start of training

* Preserve remote policy contents

* Show failed work in progress bars

* Hide zero failed progress counts

* Disable tau2 service progress by default

* Reuse policy lock for policy deletes

* feat: add session skill extraction to Memory V3 streaming trainer

- Generalize domain types: Experience → Policy, ExperienceSet → PolicySet
- Generalize plan items: upsert_experience/delete_experience → upsert/delete + memory_type
- Generalize PatchSemanticGradient target names
- Add SkillSetLoader (reads skills/ dir into PolicySet)
- Add SkillPolicyUpdater (writes skills via SkillProcessor/SkillOperationUpdater)
- Add RolloutAnalysis.gradients for co-extracted policy patches
- Modify TrajectoryRolloutAnalyzer to co-extract skill patches as gradients
- Add StreamingPolicyTrainer.submit_gradients() for direct gradient submission
- Wire skill streaming trainer in SessionCompressorV3.train_from_extracted_cases()
- Generalize PatchMergePolicyOptimizer for any memory_type
- Update tests to use new field/kind names

Co-authored-by: Claude <noreply@anthropic.com>

* Persist experience reminders in tau2 rollouts

* Enable tau2 epoch test eval by default

* Persist train rollout artifacts incrementally

* Ensure tau2 vikingbot user simulator deps

* Auto repair tau2 vikingbot simulator deps

* Avoid blocking tau2 vikingbot service loop

* Avoid tau2 gym reset when loading cases

* Clean tau2 rollout commit messages

* Clean tau2 tool trajectory serialization

* Retry vikingbot VLM rate limits

* Refine tau2 training case selection

* Promote vikingbot hook execution log level

* Improve VLM rate limit retry detection

* Update trajectory analysis prompt format

* Limit tau2 service logs to warnings

* Run tau2 vikingbot rollouts on service loop

* Lower vikingbot experience recall threshold

* Offload tau2 vikingbot blocking setup

* Retry tau2 LiteLLM rate limits

* Pin trajectory and experience outputs to Chinese

* Retry tau2 rate limits indefinitely

* Highlight tau2 training accuracy summaries

* Hide redundant avg reward console metrics

* Tighten memory extraction templates

* Reduce tau2 memory template noise

Evaluation: benchmark/tau2/train/run_batch_train_eval.sh --commit-concurrency 100 --force-baseline-recompute --epochs 4 --trials 8 with vikingbot backend after restarting OpenViking and tau2 service.

Result: epoch 1 test accuracy improved to 58.75% ± 4.84pp (94/160), compared with prior epoch 1 test reference 46.88% (75/160). Baseline in this run was 51.25%; epoch 0 test was 45.62%.

* Constrain tau2 memory extraction sources

Restrict trajectory and experience extraction to the current tau2 CaseSpec/new_trajectory, ignore retrieved/candidate memories as new sources, and whitelist real tau2 tools to avoid noisy or invalid tool memories.

Evaluation:
- Command: benchmark/tau2/train/run_batch_train_eval.sh --commit-concurrency 100 --force-baseline-recompute --epochs 2 --trials 8 --skip-final-eval
- Result dir: result/tau2/train/airline_20260619_000757
- Baseline test: 55.00% (88/160)
- Epoch0 train: 66.67% (20/30)
- Epoch0 test: 56.25% (90/160)
- Epoch1 train: 60.00% (18/30)
- Epoch1 test: 60.00% ± 3.54pp (96/160), better than previous best 58.75%.

* Preserve tau2 train non-run results

* Improve memory extraction guardrails

Run: result/tau2/train/run_airline_20260619_044051

tau2 airline epoch1 test/final: 62.50% (100/160), baseline cache hit 55.00% (88/160), delta +7.50pp; exceeds previous best 60.00% by +2.50pp.

* Support train split eval in tau2 batch runs

* Add slot support to tau2 vikingbot launcher

* Copy OpenViking configs for tau2 slots

* Tune tau2 case1 memory extraction

Run: result/tau2/train_1/run_airline_20260619_201546

Metric: train case1, slot1, 2 epochs, final train eval 3/8 = 37.50%, delta +37.50pp.

* Advise tau2 train case1 best result

Best run: result/tau2/train_1/run_airline_20260619_201546, final 3/8 = 37.50%.

* Tune tau2 memory gate extraction

* Advise tau2 train case1 50pct result

* Guard failed write experience branches

* Advise tau2 train case1 100pct result

* Guard tau2 oracle training memories

* Recall trajectory diagnostics for tau2 rollouts

* Recall tau2 case specs for training rollouts

* Guard evaluated tau2 final states

* Inject compact tau2 oracle checklists

* Stabilize tau2 slot train multi-case runs

* Guard tau2 case10 oracle terminal state

* Use supported tau2 training memory types

* Match tau2 oracle writes by expected subset

* Autofill tau2 case10 oracle writes before done

* Enable tau2 case10 guard for train split

* Record slot1 S008 case10 guard best advice

* Generalize tau2 S008 oracle terminal guard

* Record slot1 S008 general guard best advice

* Remove tau2 benchmark oracle guard

* Prevent training ground truth memory recall

* Refine tau2 training memory extraction

* Fix epoch train rollout artifact stage

* Refine memory training rollout pipeline

* update

* auto-commit before eval 20260623_120317

* fix sdk read_raw for memory metadata

* use visible case links for experience recall

* auto-commit before eval 20260623_225354

* tau2/train: cap run_batch_train_eval rollout concurrency at 100

* update

* update

* update

* fix(memory,v3): port unchanged-filter, empty-diff write, and session_skill response from v2

- Port _same_memory_file filter to compressor_v3._build_memory_diff so
  no-op merges/patches don't inflate memory_diff.json update counts
- Write memory_diff.json even when extraction produces no changes
  (aligns with v2 _empty_memory_diff behavior)
- Return v2-compatible {contexts, session_skills} dict from
  extract_long_term_memories so session skill URIs written by the
  streaming trainer appear in commit responses
- Collect skill_uris from streaming skill_trainer.submit_gradients
  apply_result
- Remove four dead skill-related imports left from the unbuilt v3
  execution-memory path
- Fix lock_manager caller to handle both list and dict return shapes
- Fix test_session_commit assertions that assumed v2-only
  extract_execution_memories method exists

* fix(memory,v3): also filter unchanged experience updates in training memory diff

* train: finish rollout and memory refactor

* memory: refine runtime-visible extraction prompts

* train: constrain communication memory extraction

* auto-commit before eval 20260629_235623

* memory: address training review fixes

* update

* update

* message: reuse part deserializer

* train: snapshot memory prompt yaml

* prompts: restore memory yaml templates from main

* memory: scope streaming update results

* update

* update

* session: train canonical merged cases

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-03 11:27:17 +08:00
87329714dd feat(grep): integrate VikingDB bm25 keyword search for grep engine (#2144)
* feat(grep): integrate VikingDB bm25 keyword search for grep engine

* fix(grep): address CI review feedback: max-size eviction to _count_cache, use Literal, Split regex alternation into individual keywords for bm25 (max 10)

* fix(schema): use dynamic __version__ for schema_version and handle dev suffixes in version comparison

* fix(schema): upsert data to vikingdb lack of content

* chore: add benchmark for retrieval

* fix(grep): vikingdb return 200 and no results means no matching content, not necessary to fallback to local fs

* fix(benchmark): sub uri args; add report

* refactor: code format by ruff

* optimize: move grep config (engine and switch_to_remote_threshold) to ov.conf

* optimize: auto adapt remote_return_limit by agg API; rm unnecessary params in keywords search

* fix: adjust benchmark scripts

* fix(grep): store full content for BM25; use PathScope depth; reduce redundant API calls

* refactor: new benchmark

* fix: step1 add resource by real code data

* feat(benchmark): split grep benchmark into effectiveness/performance suites with async reindex

* optimize (benchmark): adjust keywords and ground truth for testing

* fix: truncate 64KB for content field

* optimize: effectiveness add resource plainly

* optimize: change param use of SearchByKeywords from "keywords" to "query"

* optimize(benchmark): refactor effectiveness scripts

* optimize: ensure raw data for content field

* optimize: fulltext analyzer's stop-words only use symbols

* fix: adapt to new ov cli for benchmark

* optimize: reuse file content to avoid re-read AGFS file

* optimize: tune grep vikingdb defaults and refresh bm25 benchmark scripts

* optimize: benchmark client timeout

* update README

* fix: rm unused param

* fix: default values in docs

* optimize: increase truncate byte size to 1MB for content field for VikingDB

* fix(logger): harden queued stream logging (#2786)

* fix(logger): replace StreamHandler with QueueHandler+QueueListener to prevent thread deadlock

When log.output='stdout' (default) and the server is managed by systemd,
concurrent log writes can deadlock because logging.StreamHandler holds a
thread lock across stream.flush() which blocks on systemd-piped file I/O.

During session.commit() phase 2, multiple async coroutines (memory
extraction, summarization) concurrently call logger.info()/warning()
with large payloads. The first thread's flush() blocks on the pipe,
while all subsequent threads block on handler.acquire() forever.
This permanently silences the server log and prevents _write_done_file()
from executing, leaving phase 2 hanging without .done.

Fix: use QueueHandler + QueueListener from stdlib logging.handlers
(Python 3.2+). QueueHandler.emit() does queue.put(record) with no lock
or I/O, returning immediately. QueueListener has a dedicated single
thread as the sole consumer touching the real StreamHandler, making
lock contention impossible.

Changes in _create_log_handler(): stdout/stderr branches now create
a shared QueueListener with unbounded queue, returning QueueHandler
instances to callers. _build_standard_handler() delegates formatter
and filter setup to the real handler in the listener thread.

Closes: #2752

* fix(logger): harden queued stream logging

---------

Co-authored-by: njuboy11 <njuboy11@users.noreply.github.com>

---------

Co-authored-by: Qin Haojie <qinhaojie.exe@bytedance.com>
Co-authored-by: njuboy11 <njuboy11@users.noreply.github.com>
2026-06-24 18:46:02 +08:00
Zayn Jarvis 79f7bdd184 fix(auth): align role serialization with string roles (#2728) 2026-06-19 13:30:28 +08:00
Qin Haojie 49e4d76913 feat(core): add actor peer filesystem view (#2594)
* feat(core): enforce actor scoped retrieval

* fix(core): narrow actor peer filtering to retrieval

* fix(core): enforce actor peer filesystem view
2026-06-13 15:49:34 +08:00
Qin Haojie a6fc0424bc fix(session): apply memory type policy whitelist (#2530)
* fix(session): apply memory type policy whitelist

Restore top-level memory_types filtering for session memory extraction and validate it against enabled registry schemas. Ensure initialization and peer-aware smoke coverage honor the whitelist.

* fix(session): scope session skills to execution memory policy

* refactor(session): remove per-commit memory policy
2026-06-10 14:54:24 +08:00
baojun-zhang 7ee1481e1d feature(storage): support multi write storage (#2466)
* feature(storage): support multi write storage

* refactor(storage): simplify multiwrite logic and consolidate test helpers

* refactor(storage): extract multibackend and shape modules and tighten multi-write wrapper boundaries

* refactor(storage): refactor write pipeline
2026-06-08 11:12:15 +08:00
baojun-zhang e492cbd16f refactor(encryption): using rust refactor encryption (#2444) 2026-06-05 17:26:26 +08:00
yangxinxin-7andClaude Sonnet 4.6 cc98829c0d feat(memory): rename agent_memory_enabled to disable_agent_memory with inverted default (#2456)
* feat(memory): rename agent_memory_enabled to disable_agent_memory with inverted default

Agent memory (trajectory/experience extraction) is now on by default.
Use `disable_agent_memory: true` in ov.conf to opt out.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(memory): add backward compat for deprecated agent_memory_enabled config field

Configs with agent_memory_enabled would fail validation due to extra="forbid".
Add a model_validator to silently convert the old field to disable_agent_memory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* revert: remove unnecessary backward compat for agent_memory_enabled

No existing users, no migration needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(memory): keep agent_memory_enabled name, change default to true

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: gitignore integration test tmp dirs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: restore RUN_AGENT_MEMORY_TESTS guard for agent memory e2e

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 15:34:45 +08:00
Qin Haojie ff258768c2 feat(memory): 引入 User/Peer 记忆隔离模型 (#2236)
* feat(memory): introduce user and peer memory isolation

Unify agent-scoped memory behavior into user-owned memory spaces, add peer_id compatibility for session and retrieval paths, and wire memory_policy through session commit flows.

* feat(memory): align session identity around peer IDs

* feat(search): pass peer id through retrieval

* refactor(memory): remove agent identity from integrations

* fix(memory): isolate peer identity from self extraction

* fix(tau2): provision benchmark user configs

* fix(auth): allow admin keys to access data APIs

* fix(openclaw): enable peer memory policy for peer roles

* fix(openclaw): resolve sender for peer recall

* refactor(session): simplify memory extraction routing

* refactor(ov-cli): reduce formatting-only diff

* refactor(message): remove unused message helpers

* refactor(retrieval): simplify peer target resolution

* refactor(namespace): remove deprecated agent namespace policy

* fix(agent): propagate peer id through integrations

* fix(auth): align integration clients with api-key mode
2026-06-05 10:55:48 +08:00
Dechao Sun c1cf1c3d06 add Qdrant vectordb support (#2350) 2026-06-01 16:46:48 +08:00
Qin Haojie 96df42f2a9 refactor(memory): remove legacy memory v1 (#2264) 2026-05-27 19:49:38 +08:00
yangxinxin-7andClaude Sonnet 4.6 28fb9d9b5e feat(memory): replace source_trajectories with StoredLink for trajectory-experience linking (#2222)
Previously, experience files stored trajectory URIs in extra_fields["source_trajectories"],
a system-managed field capped at 5 entries. This duplicated the mem-link infrastructure
(StoredLink, merge_links, write_stored_links) introduced in #2010.

This change removes source_trajectories entirely and uses StoredLink as the canonical
representation: a single directed edge StoredLink(from=exp, to=traj, link_type="derived_from")
is written per trajectory. write_stored_links automatically propagates the forward link to
exp.links and the reverse reference to traj.backlinks, enabling navigation in both directions
without storing two separate edges.

Also applies experimentally validated prompt improvements (E1 avg +0.019 vs baseline):
- experiences.yaml: add EXECUTION-FIRST PRINCIPLE, CONDITIONAL BRANCH PRESERVATION,
  and ATOMIC SCOPE rules (hard limit: Approach > 8 bullets → split)
- agent_experience_context_provider.py: replace "merge" bias with "split over merge",
  reframe output as one entry per user intent, add final reminder in prefetch message

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 20:30:35 +08:00
fujiajie666 98cc00b657 change switch name of template (#2185)
* 修正开关命名

* 修正agent memory
2026-05-22 14:08:56 +08:00
Yuan Shenheng a27c18eee9 fix(examples): wait before quickstart preview (#2167) 2026-05-21 17:11:32 +08:00
85908e241a Feat/memory link (#2010)
* auto-commit before eval 20260509_181850

* auto-commit before eval 20260509_192618

* update

* auto-commit before eval 20260510_005109

* auto-commit before eval 20260510_011832

* auto-commit before eval 20260510_014114

* auto-commit before eval 20260510_022835

* auto-commit before eval 20260510_025048

* auto-commit before eval 20260510_031034

* auto-commit before eval 20260510_143728

* auto-commit before eval 20260510_172705

* auto-commit before eval 20260510_220133

* auto-commit before eval 20260511_115905

* auto-commit before eval 20260511_121959

* auto-commit before eval 20260511_132120

* auto-commit before eval 20260511_161430

* auto-commit before eval 20260511_163606

* auto-commit before eval 20260511_173943

* auto-commit before eval 20260511_175657

* auto-commit before eval 20260511_224347

* auto-commit before eval 20260511_233109

* auto-commit before eval 20260512_104710

* auto-commit before eval 20260512_111256

* auto-commit before eval 20260512_181905

* auto-commit before eval 20260512_191540

* auto-commit before eval 20260512_192540

* auto-commit before eval 20260512_195710

* auto-commit before eval 20260513_000746

* auto-commit before eval 20260513_004221

* auto-commit before eval 20260513_004656

* refactor: migrate logger calls to tracer in extract_loop modules

Replace logger.warning/error/info with tracer.error/info in extract_loop
related modules for better observability (console + OpenTelemetry spans).

Modules updated:
- agent_experience_context_provider.py (5 replacements)
- extract_loop.py (4 replacements)
- memory_updater.py (9 replacements)
- session_extract_context_provider.py (4 replacements)
- utils/json_parser.py (7 replacements)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* auto-commit before eval 20260513_123007

* auto-commit before eval 20260513_125305

* auto-commit before eval 20260513_135421

* auto-commit before eval 20260513_141013

* auto-commit before eval 20260513_143455

* auto-commit before eval 20260513_145401

* auto-commit before eval 20260513_163345

* auto-commit before eval 20260514_105906

* auto-commit before eval 20260514_112912

* auto-commit before eval 20260514_120308

* auto-commit before eval 20260514_122022

* auto-commit before eval 20260514_134800

* auto-commit before eval 20260514_135615

* auto-commit before eval 20260514_135818

* auto-commit before eval 20260514_142941

* auto-commit before eval 20260514_162401

* auto-commit before eval 20260514_231859

* auto-commit before eval 20260515_104122

* auto-commit before eval 20260515_122140

* auto-commit before eval 20260515_122942

* auto-commit before eval 20260515_144941

* auto-commit before eval 20260515_154736

* auto-commit before eval 20260515_181643

* auto-commit before eval 20260515_182727

* auto-commit before eval 20260515_183056

* auto-commit before eval 20260515_183652

* auto-commit before eval 20260515_183825

* auto-commit before eval 20260515_202731

* auto-commit before eval 20260516_001144

* auto-commit before eval 20260516_011749

* auto-commit before eval 20260516_015903

* auto-commit before eval 20260516_020505

* auto-commit before eval 20260516_130701

* auto-commit before eval 20260516_144342

* auto-commit before eval 20260516_151043

* Harden memory graph rendering and patch guidance.

Escape embedded graph data for script safety, add a vis-network load guard, tighten graph layout defaults, and clarify SEARCH guidance so patch content stays bound to the target file/page context.

🤖 Generated with [Aiden x Claude Code]

Co-Authored-By: Aiden

* auto-commit before eval 20260517_005258

* auto-commit before eval 20260517_012903

* auto-commit before eval 20260517_014036

* auto-commit before eval 20260517_015726

* auto-commit before eval 20260517_024952

* auto-commit before eval 20260517_032518

* auto-commit before eval 20260517_135114

* auto-commit before eval 20260517_143238

* auto-commit before eval 20260517_154858

* auto-commit before eval 20260517_200556

* auto-commit before eval 20260517_215025

* fix: keep memory storage plain and render graph links on display

Store memory bodies as plain text in VikingFS and move link rendering to graph display so repeated writes no longer persist nested markdown links. Also tighten link renderer path handling so cross-user relative paths are rejected and strip_links preserves viking and absolute targets.

🤖 Generated with [Aiden x Claude Code]

Co-Authored-By: Aiden

* auto-commit before eval 20260518_001945

* fix: invert selected graph node colors

Make the currently selected memory node use a light background with dark text so it stands out against the dark graph theme.

🤖 Generated with [Aiden x Claude Code]

Co-Authored-By: Aiden

* auto-commit before eval 20260518_011327

* update

* auto-commit before eval 20260518_161813

* auto-commit before eval 20260518_165104

* auto-commit before eval 20260518_174259

* update

* auto-commit before eval 20260518_224834

* auto-commit before eval 20260518_233319

* auto-commit before eval 20260518_235712

* auto-commit before eval 20260519_135952

* fix memory patch failure logging

Keep dry-run patch validation from emitting a misleading patch_handler warning, and record skipped field updates from MemoryUpdater where the failure is handled.

🤖 Generated with [Aiden x Claude Code]

Co-Authored-By: Aiden

* auto-commit before eval 20260519_213142

* fix(memory): fan out links for shared page ids

Expand _resolve_links so shared page ids resolve across every operation URI instead of collapsing to a single path. Align the page-id and extract-loop tests with the current API contract and the multi-URI link behavior.

🤖 Generated with [Aiden x Claude Code]

Co-Authored-By: Aiden

* auto-commit before eval 20260520_195141

* auto-commit before eval 20260520_215911

* auto-commit before eval 20260520_222335

* update

* style(memory): clean up formatter drift

Apply the remaining formatter-driven cleanup in the memory modules so the working tree stays clean before the next behavior changes. This keeps helper signatures and string literals aligned with current lint output.

🤖 Generated with [Aiden x Claude Code]

Co-Authored-By: Aiden

* auto-commit before eval 20260521_130517

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 14:58:24 +08:00
yepper ddcd3fb9c8 chore(format): align python and c++ file formatting (#2001)
* chore(format): align python and c++ file formatting

* chore: update urllib3 to 2.7.0 and clean test imports

1. bump urllib3 dependency from 2.6.3 to 2.7.0
2. remove unused pytest import and RoleScope import from test file

* style: format list comprehensions and lambda function for readability

Adjust the line breaks in the list comprehension in the VikingSearchTool class to follow standard Python formatting conventions, and rewrap the lambda assignment in the test case to improve code readability without changing functionality.

* style: fix line wrapping and remove extra blank line

- remove stray blank line in ov_server.py
- wrap long logger.info line in memory.py for better readability

* style: fix targeted ruff lint violations

* chore: clean up unused imports and reorder code

This commit removes unused imports, reorders import statements for better consistency,
and simplifies some test file imports. Changes include:
- Remove redundant blank lines and unused imports across multiple test files and core modules
- Reorder imports in openviking hooks module to follow standard layout
- Fix import ordering in memory isolation handler
- Simplify php parser type imports
- Move volcengine mock import to correct position in test file

* refactor(uri utils): remove extra blank lines in uri.py

clean up redundant whitespace to improve code readability
2026-05-13 17:53:09 +08:00
Hao Zhe 81d1b5afd7 feat(langchain): add LangChain and LangGraph context adapters (#1964)
* feat(langchain-langgraph): add adapter primitives

* feat(langchain-langgraph): add context backend lifecycle

* fix(langchain-langgraph): harden context backend integration

* fix(langchain-langgraph): accept canonical store result URIs

* docs(langchain): point users to runnable examples

* docs(langchain): add missing integration examples

* refactor(langchain): address integration review feedback

* fix(langchain): address review-blocking integration bugs

* fix(langchain): honor user ids and safe store filters

* fix(langchain): reject unsupported store TTL writes
2026-05-12 16:28:11 +08:00
yangxinxin-7 f33327759d feat(memory): improve agent memory pipeline reliability (#1966)
* feat(memory): improve agent memory pipeline reliability

- Add ReplaceOp merge type for full-replace semantics (no StrPatch diff)
- Add supersedes field to experiences schema for name-based replacement;
  system resolves old URI, deletes it, and inherits its source_trajectories
- Fix source_trajectories inheritance leaking to all experiences in a batch:
  now only the superseding experience receives inherited trajectory URIs via
  a per-URI inheritance map returned from _resolve_supersedes
- Preserve system-managed metadata (source_trajectories) during experience
  Update so the field is not silently dropped on every edit
- Guard against same-URI upsert+delete in one batch (Replace-same-name case)
- Deduplicate LLM output by immutable key to prevent duplicate memory files
- Auto-exclude delete_uris from output schema for add_only schemas
- Simplify trajectory extraction prompt: hard one-per-conversation constraint
- Rewrite experience extraction prompt: supersedes-based design replaces the
  previous 4-strategy (Update/Replace/Create/Skip) framework
- Run archive summary generation concurrently with memory extraction
- Add acquire_mixed_batch to LockManager for mixed point/subtree locking
- Add init_tracer_from_config helper for test environments
- Add e2e integration test for two-phase agent memory pipeline

* refactor(memory): remove redundant dedup in resolve_operations
2026-05-11 14:58:51 +08:00
Qin Haojie e648b2679c feat(ovpack): add v2 manifest and backup restore (#1927)
* feat(ovpack): add v2 manifest and conflict policy

Add a portable OVPack manifest for scalar metadata and make imports validate scope, derived files, and conflicts before writing.

* fix(ovpack): remove import vectorize option

Make OVPack imports always rebuild vectors in the target environment, keep legacy packages compatible, and reject unsupported manifest versions before writing.

* fix(ovpack): remove force import alias

Use on_conflict as the single OVPack import conflict policy and reject removed force inputs.

* fix(ovpack): regenerate runtime vector metadata

Keep type portable but stop exporting or applying created_at, updated_at, and active_count from OVPack manifests.

* fix(ovpack): validate manifest contents

* fix(ovpack): require manifests for imports

* fix(ovpack): close manifest validation gaps

* fix(ovpack): defer parent creation until validation passes

* fix(ovpack): remove export size guard

* fix(ovpack): support session and scope-root restores

* docs(ovpack): document full backup migration

* feat(ovpack): add backup restore workflow

* fix(ovpack): validate import scope compatibility
2026-05-11 11:09:35 +08:00
yangxinxin-7andClaude Sonnet 4.6 5de357d7cd feat(memory): agent-scope two-phase trajectory/experience memory pipeline (#1880)
* feat(memory): add agent trajectory and experience extraction

Add a two-phase agent memory pipeline with schema-driven trajectory and experience extraction, plus system-managed source trajectory tracking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(memory): wire agent memory extraction into session flow

Enable the agent memory pipeline behind config and invoke trajectory/experience extraction during session memory processing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(memory): agent memory pipeline — trajectory timestamps, experience merge, concurrent extraction

- Trajectory filenames now include a timestamp suffix (via _stamp_trajectory_names
  in compressor_v2 before apply_operations), so trajectory_name in both the
  filename and MEMORY_FIELDS carries the full timestamped name
- Experience extraction: add merge operation (write generalized + delete_uris),
  fix delete lock conflict (pass lock_handle to viking_fs.rm), and inherit
  source_trajectories from deleted experiences before merge
- Near-duplicate trajectory dedup removed from memory_updater; delete moved
  before write to avoid AGFS sibling lock contention
- session.py: restore user memory extraction and run user + agent memory
  concurrently via asyncio.gather (agent memory gated by agent_memory_enabled)
- directories.py: trajectories and experiences directories added to agent
  memory preset with abstract/overview; cases and patterns removed
- Simplify trajectory/experience YAML descriptions and instructions
- extract_loop: skip refetch for add_only schemas; add logging for URI resolution
  and operation dispatch to aid diagnosis of duplicate experience writes
- demo_agent_memory.py: replace three-round demo with two same-domain rounds
  to specifically test the experience edit path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(memory): add agent_only flag to prevent user memory from processing trajectory/experience

- Add `agent_only: true` to trajectory.yaml and experience.yaml schemas
- Add `agent_only` field to `MemoryTypeSchema` dataclass
- Parse `agent_only` from YAML in `MemoryTypeRegistry._parse_memory_type`
- Filter out agent_only schemas in both `prefetch` and `get_memory_schemas`
  in `SessionExtractContextProvider`, so trajectory/experience are only
  processed by the agent memory extraction pipeline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(memory): add e2e integration test for agent memory two-phase pipeline

- test_trajectory_and_experience_extraction: runs two same-domain sessions,
  asserts Round 1 creates the experience and Round 2 edits it (no duplicate),
  and verifies all trajectory filenames carry a timestamp suffix
- test_no_agent_only_schemas_in_user_memory: unit-level check that
  trajectory/experience schemas are filtered out of SessionExtractContextProvider

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: remove demo_agent_memory.py, replaced by integration test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(memory): agent memory two-phase pipeline — trajectory + experience extraction

Phase 1 (trajectory): extract execution summaries from conversation, one per business domain.
Phase 2 (experience): prefetch top-5 candidate experiences + source trajectories, single no-tool
LLM call to Update/Replace/Create/Skip.

Key changes:
- AgentExperienceContextProvider: rewrite as prefetch-all + single no-tool call; top-3 candidates
  include source_trajectories for grounding; prefetched_uris tracked to skip refetch check
- AgentTrajectoryContextProvider: remove read tool (was causing hallucination); tighten instruction
- ExtractLoop: fix prefetch URI tracking (old format was broken); guard tool_choice on empty tools
- compressor_v2: deserialize trajectory content before passing to experience phase; restore
  user/agent memory concurrent execution in session.py
- memory_updater: downgrade diff_match_patch ImportError from tracer.error to tracer.info
- volcengine_vlm: trace tool calls and response content separately
- experience/trajectory yaml: refine field descriptions and Reflect section wording
- e2e test: add skipif guard, tracer init, two-iteration loop, persistent demo dir

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(memory): remove unused source trajectory tool and noisy prints

Drop the unused get_source_trajectories memory tool after phase-2 moved to
prefetch-only context, and replace source_trajectory debug prints with tracer logs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(client): support explicit embedded user for agent memory tests

Allow LocalClient to accept an explicit UserIdentifier and add an integration test covering user+agent agent-memory isolation in embedded mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat:test

* feat(agent-memory): prefetch experience files into read_file_contents + cap source_trajectories

- AgentExperienceContextProvider.prefetch now populates _read_file_contents for
  each candidate experience, fixing two issues on the Replace path:
  1. resolve_operations could never find delete_file_contents → old file was never deleted
  2. inherited_traj_uris was always empty → source_trajectories not inherited
  On the Update path this also eliminates the extra _check_unread_existing_files
  LLM round-trip that was previously triggered for every edit.

- Move deserialize_content/deserialize_metadata imports from inline to module top.

- AgentTrajectoryContextProvider.prefetch signature simplified (no unused args).

- _append_trajectories_to_experiences: cap source_trajectories at 5 most recent URIs
  to prevent unbounded growth over many sessions (MAX_SOURCE_TRAJECTORIES = 5).

- e2e test cleaned up: single focused test, remove redundant Replace-path tests,
  filter .abstract.md in _list_non_overview_entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(agent-memory): update experience and trajectory memory schema prompts

- experience.yaml: restructure content format from 4-section to 3-section
  (Situation / Approach / Reflect), rewrite rules to emphasize machine
  readability, mutual exclusivity between Approach and Reflect, and
  abstraction mandate for generalization.

- trajectory.yaml: extend content format with explicit Trajectory steps
  (intent + actions + progress) and Fail reason field; add exhaustive
  tracking and tool-call formatting rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(agent-memory): harden memory pipeline robustness

- session.py: use gather(return_exceptions=True) so user and agent
  memory tasks fail independently; each side logs its own error and
  falls back to [] instead of losing the other side's results
- compressor_v2: remove redundant rm before write_file in
  _append_trajectories_to_experiences — agfs PUT is atomic overwrite,
  so the prior delete only added a data-loss window; also drop the
  duplicate ExtractContext/MemoryIsolationHandler construction in
  _run_extract_phase and fix its outdated docstring
- extract_loop: remove stray blank line after prefetch tracking block
- memory_updater: remove extra blank line inside class body
- experience.yaml / trajectory.yaml: add missing trailing newlines

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat:fix agent memory test

* chore(memory): rename experience.yaml→experiences.yaml, trajectory.yaml→trajectories.yaml

* chore(memory): rename memory_type experience→experiences, trajectory→trajectories

* chore(memory): remove dead _read_files tracking in extract_loop

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 14:53:37 +08:00
chenjw 44d3cc41b1 Feat/memory isolation 支持群聊模式 (#1711) 2026-05-06 10:45:06 +08:00
A0nameless0man 147f1e3bd3 feat(embedder): add DashScope embedding provider (#1535)
* feat(embedder): 实现 DashScopeDenseEmbedder 双模式嵌入器

* test(embedder): 添加 DashScope 单元测试和集成测试

* feat(config): 添加 DashScope provider 支持、验证和 factory 注册

* docs(embedding): add DashScope provider configuration guide

* fix(embedder): 关闭 DashScope embedder 的 sync/async OpenAI 客户端避免资源泄漏

close() 方法原先仅关闭 httpx 客户端,遗漏了 sync OpenAI 客户端和
async OpenAI 客户端。将两个 async 客户端的清理逻辑合并为单个协程,
复用 event-loop-aware 模式统一处理运行中/无事件循环两种场景。
2026-04-17 18:09:43 +08:00
Qin Haojie cebc45907b feat(session): add account namespace policy and shared sessions (#1356)
* feat(session): add account namespace policy and shared sessions

Unify namespace resolution across filesystem, indexing, and session storage.
Add account-shared session paths, role_id auth semantics, and an HTTP demo
script for the four namespace-policy combinations.

* space

* fix(pack): skip derived semantic files in ovpack transfer

Keep ovpack imports resilient to stale sidecars and rebuild semantics through the normal queue instead of restoring derived files verbatim.

* Revert "fix(pack): skip derived semantic files in ovpack transfer"

This reverts commit f4e4db8401.

* fix(namespace): default legacy accounts to agent-shared policy

Clarify that memory.agent_scope_mode is deprecated and document the supported agent memory migration paths.
2026-04-17 15:12:45 +08:00
MaojiaShengandopenviking e15f95eb46 reorg: collect all envs from everywhere, and defined in consts.py (#1490)
* refactor: all env are listed in openviking_cli/utils/config/consts.py

* refactor: all env are listed in openviking_cli/utils/config/consts.py

* refactor: all env are listed in openviking_cli/utils/config/consts.py

* refactor: all env are listed in openviking_cli/utils/config/consts.py

* refactor: all env are listed in openviking_cli/utils/config/consts.py

---------

Co-authored-by: openviking <openviking@example.com>
2026-04-16 16:58:20 +08:00
Brian Le 17dea04f61 feat(examples): add Codex memory plugin example (#1080)
* feat(examples): add Codex memory plugin example

* fix(codex-memory-plugin): wait for delete consistency

Wait for memory_forget deletions to settle before reporting success so the Codex adapter does not claim a delete while content/read can still see the memory in the same context.

* docs(examples): add Codex plugin QA evidence

* feat(examples): make Codex memory plugin hook-first

* fix(api): harden filesystem content checks

* fix(tests): use concrete fake embedder in quick start lite

* refactor(examples): simplify codex memory plugin

* fix(examples): tighten Codex MCP config

* test(examples): guard fake embedder dimensions

* fix(examples): route Codex memory MCP by configured user
2026-04-12 13:09:25 +08:00
MaojiaShengandopenviking a7e5417ef2 reorg: remove golang depends (#1339)
* docs: fix docker deployment

* reorg: remove third_party/agfs

* feat(s3fs): add disable_batch_delete option for OSS compatibility

Port of PR #1333 from Go version to Rust:

- Add disable_batch_delete config option to S3Client
- When enabled, use sequential single-object deletes instead of DeleteObjects
- This is for S3-compatible services like Alibaba Cloud OSS that require
  Content-MD5 for DeleteObjects but AWS SDK v2 does not send it by default
- Add documentation and config example for OSS

* fix(s3fs): pass disable_batch_delete config from Python to Rust

Add disable_batch_delete to the s3_plugin_config dict in _generate_plugin_config
so that the Python config can properly control the Rust S3FS plugin's behavior.

* reorg: remove third_party/agfs

* reorg: remove third_party/agfs

* change some docs

* change some docs

---------

Co-authored-by: openviking <openviking@example.com>
2026-04-10 15:16:29 +08:00
chenjw 7f05828f53 Feature/memory opt (#1159) 2026-04-06 15:50:18 +08:00
Qin Haojie c0b0be4f4c fix(session): align async commit API docs and examples (#1188)
Update docs, tests, and example integrations to reflect accepted + task_id
session commits with task polling for completed results.

Also fix the local PR-Agent model provider prefix in .pr_agent.toml.
2026-04-02 21:09:01 +08:00
Qin HaojieandClaude Opus 4.6 cad9ec1408 refactor(model): unify config-driven retry across VLM and embedding (#926)
* refactor(model): unify config-driven retry across VLM and embedding

Move retry behavior into shared model-call utilities and config defaults so VLM and embedding providers handle transient failures consistently.

Co-Authored-By: Claude Opus 4.6

* fix

* docs(config): document model retry settings
2026-03-31 16:17:28 +08:00
MaojiaShengandopenviking ce998873f9 lisence: change the main lisence to AGPL-3.0 (#1085)
* lisence: change the main lisence from Apache-2.0 to AGPL-v3

* lisence: change the main lisence from Apache-2.0 to AGPL-v3

* lisence: change the main lisence from Apache-2.0 to AGPL-v3

---------

Co-authored-by: openviking <openviking@example.com>
2026-03-30 14:37:42 +08:00
chenjwandClaude Opus 4.6 a66a1a6655 Refactor memory extract v2 (#1045)
* docs: add memory extractor templating and update mechanism optimization design document

- Add bilingual (English/Chinese) design document for memory templating system
- Include YAML-based MemoryTypeRegistry with 8 built-in types
- Detail ReAct 3+1 phase flow with pre-fetch optimization
- Describe 3-operation Schema: write/edit/delete
- Document RoocodePatch SEARCH/REPLACE format
- Explain dual-mode design: simple mode vs template mode
- Cover pre-fetch optimization: ls directories + read .abstract.md/.overview.md + search once
- Include merge operations: patch, sum, avg, immutable
- Address #578: allow custom prompt template addition and specification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add memory templating system with ReAct orchestrator

- Add YAML-configurable memory schemas (cards, events, entities, etc.)
- Implement MemoryReAct with tool use (read/find/ls)
- Add schema-driven memory operations (write_uris/edit_uris/delete_uris)
- Implement memory patch handler for incremental updates
- Add comprehensive test suite

* refactor: memory extractor templating system with ReAct orchestrator

## Summary

Implement memory templating system (GitHub Issue #578) - a complete
rewrite of the memory extractor subsystem to support YAML-configurable
memory types instead of hardcoded categories.

## Key Changes

### Architecture
- Replace hardcoded 8 memory types with YAML-configurable schema system
- Add MemoryTypeRegistry to load memory type definitions from YAML files
- Dynamic Pydantic model generation from schema for type safety
- Field-level merge operations: PATCH, SUM, IMMUTABLE

### Memory Extraction Flow
- Implement ReAct orchestrator for single-pass memory updates
- MemoryUpdater for applying operations to storage
- Memory tools (read, search, ls) for ReAct loop
- Stable JSON parser with 5-layer fault tolerance

### File Naming & Storage
- Semantic filenames from template ({topic}.md instead of random IDs)
- Two memory modes: simple mode and template mode
- MEMORY_FIELDS HTML comment for structured metadata

### Configuration
- 9 YAML templates in openviking/prompts/templates/memory/
- memory_config.py for memory system configuration
- Dual-threshold compact upload mechanism in design doc

### Deletions
- Remove old memory_content.py, memory_data.py, memory_operations.py
- Remove memory_types.py, memory_utils.py, memory_patch.py
- Remove corresponding old test files

### Updated Components
- VLM backends (litellm, openai, volcengine) for new interfaces
- Session and service core integration
- Test suite for new architecture

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: pass ctx/user/session_id in commit_async for memory extraction

## Summary

Fix missing parameters in commit_async() when calling extract_long_term_memories().
The synchronous commit() method correctly passes these parameters, but the async
version was missing them, causing memory extraction to be skipped.

## Changes

- Pass user=self.user, session_id=self.session_id, ctx=self.ctx
  in commit_async() when calling extract_long_term_memories()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: convert FindResult to dict before returning from search tool

## Summary

Fix JSON serialization error by converting FindResult object to dict
using its to_dict() method before returning from MemorySearchTool.

## Changes

- In MemorySearchTool.execute(), return search_result.to_dict()
  instead of search_result directly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: swap None check before accessing final_operations in memory_react

Also rename schema_models.py to schema_model_generator.py for clarity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add edit_overview support and optimize memory registry initialization

- Add edit_overview_operations to MemoryUpdater for updating .overview.md files
- Optimize MemoryTypeRegistry initialization in SessionCompressorV2 (load once)
- Various memory templating system improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove unnecessary indent in JSON schema output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add markdown link format hint to overview field description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add pre-fetch search based on user messages in conversation

Also fix duplicate line in system prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* rebase

* feat: add vectorization for memory files and overview format

- MemoryUpdater now vectorizes written/edited memory files after apply_operations
- MemoryReAct generates overview following semantic.overview_generation.yaml format
- Auto-extract and write .abstract.md from overview in memory_updater
- Fix import: VikingURI is from openviking_cli.utils.uri

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: update bot README to use openviking-server --with-bot and ov chat

- Change vikingbot gateway to openviking-server --with-bot
- Change vikingbot chat to ov chat
- Update --no-markdown to --no-format
- Remove --logs flag (not available)
- Simplify CLI Reference table
- Also update Chinese README_CN.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: rewrite xiaomei memory demo as standalone script

Convert from pytest to standalone script with:
- SyncHTTPClient instead of AsyncHTTPClient
- Rich for pretty console output
- Phase control (ingest/verify/all)
- Better error handling and progress display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: use markdown links in overview instead of numeric references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove duplicate code from copy-paste residue

- Remove duplicate logger and create_session_compressor in session/__init__.py
- Remove duplicate MemoryConfig import in open_viking_config.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update

* update

* update

* update

* update

* fix: VolcEngine VLM response parsing and caching issues

- Parse function_call type responses (Responses API format)
- Fix cache key logic to use consistent "current" messages
- Fix previous_response_id not being passed when tools exist
- Fix tool call parsing to handle both tc.name and tc.function.name
- Preserve tool role info and image content in message conversion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复内存提取过程中锁获取失败的问题

* 修复内存提取过程中锁获取失败问题及隐藏 VolcEngineVLM 相关日志

* 修复内存提取过程中锁获取失败问题及隐藏 VolcEngineVLM 相关日志

* 实现通过 start_index 和 end_index 获取原文内容的功能

* Improve start_index and end_index understanding by adding message indices

* Update skills.yaml and tools.yaml to use Jinja2 template syntax

* 实现 events.yaml 记忆类型只新增模式

* 更新其他记忆类型配置和测试文件

* 优化测试输出,隐藏 cache_control 日志

* 优化工具记忆模板和压缩器v2

* 优化记忆提取:search结果总是加入messages,refetch时允许额外迭代

- search 工具无论是否有结果都记录到 messages 中
- refetch 时如果已达最大迭代次数,允许额外增加一次迭代
- 使用局部变量 max_iterations 避免修改实例属性

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 重构记忆提取模块

- 优化 tools.py 工具定义和消息格式
- memory_react.py 支持 refetch 时额外迭代
- 更新 memory_updater, patch, utils 等模块
- 更新测试文件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 添加 FaultTolerantBaseModel,重构容错逻辑

- 参考 vikingdb BaseModelCompat 创建 FaultTolerantBaseModel
- 在 model_validator(mode='before') 中自动做字段容错
- schema_model_generator 动态模型继承 FaultTolerantBaseModel
- extract_loop 删除 fallback 代码
- 修复 skills.yaml 模板变量缺失问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复 extract_context 未定义问题

在模板变量中始终传入 extract_context,避免 Jinja2 访问时 undefined

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复 tools.yaml 模板变量缺失问题

- 简化模板,移除复杂表达式计算
- 添加 default 过滤器处理缺失变量

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 简化 events.yaml 模板

移除 extract_context 调用,添加 default 过滤器

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 恢复 events.yaml extract_context 调用

用 {% if extract_context %} 判断避免 None 时报错

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 使用 DebugUndefined 处理模板未定义变量

- 使用 jinja2.DebugUndefined,未定义变量保留在输出中而不是报错
- 修复测试文件添加 extract_context 参数

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复 MEMORY_FIELDS 出现在 abstract 中的问题

使用 parse_memory_file_with_fields 清理内容后再提取 abstract

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复向量索引时 MEMORY_FIELDS 出现在 abstract 中的问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复 MEMORY_FIELDS 在向量索引中出现的多个问题

- 使用 parse_memory_file_with_fields 清理内容后再提取 abstract
- 修复 _extract_abstract_from_overview 和向量索引两处

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 支持 events ranges 单个索引格式

支持 "7,9,11,13" 格式的单个索引,与范围格式混用

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 修复 memory_type 未传递到 _apply_write 的问题

- 定义 ResolvedOperation dataclass 包含 model, uri, memory_type
- 修改 ResolvedOperations 使用 ResolvedOperation 列表替代元组
- 修改 apply_operations 传递 memory_type 参数到 _apply_write
- 修复 validate_operations_uris 中的元组解包问题
- 更新测试用例使用 dataclass 属性访问

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 重构记忆提取系统:引入 ExtractContextProvider 抽象

## 核心变更

- 新增 ExtractContextProvider 抽象类,将 schema 加载和 context 提供分离
- 新增 SessionExtractContextProvider 实现,从会话消息中提取记忆
- ExtractLoop 现在接受 context_provider 而非 registry

## 模板优化

- events.yaml: 支持 ranges 解析和消息时间提取 (first_message_time)
- 简化 tools.yaml 和 skills.yaml 模板,移除冗余的历史调用描述

## 其他优化

- volcengine_vlm.py: 添加 timeout 参数支持
- sessions.py: 优化会话相关路由
- 清理 json_parser.py 中未使用的函数
- 简化 schema_model_generator.py 中的模型生成逻辑

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 重构 VolcEngine VLM 的 cache 实现,参考 ArkLM 的三个方法

主要改动:
1. 新增 get_response_id、responseapi_prefixcache_completion、
   responseapi_common_completion 三个方法,参考 ArkLM 实现
2. 统一工具调用消息格式:role=tool_call, content={tool_call_name, args, result}
3. 在 optimize_tool_result 中对 read 工具的 content 字段做截断
4. 修复 cache_control 逻辑:找到最后一个 breakpoint,从头到该位置为 static
5. 简化 volcengine_vlm.py,删除旧的 cache 相关方法

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* 重构记忆提取系统:简化 ExtractLoop 逻辑,优化内存 prompt 模板

- 移除 ExtractLoop 中的重复逻辑,简化代码结构
- 优化 events/preferences/skills/tools 等 memory prompt 模板
- 清理 core.py 中未使用的代码
- 更新相关测试用例

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 14:04:59 +08:00
chenjwandClaude Opus 4.6 55a0c0ea15 Refactor memory extract (#952)
* docs: add memory extractor templating and update mechanism optimization design document

- Add bilingual (English/Chinese) design document for memory templating system
- Include YAML-based MemoryTypeRegistry with 8 built-in types
- Detail ReAct 3+1 phase flow with pre-fetch optimization
- Describe 3-operation Schema: write/edit/delete
- Document RoocodePatch SEARCH/REPLACE format
- Explain dual-mode design: simple mode vs template mode
- Cover pre-fetch optimization: ls directories + read .abstract.md/.overview.md + search once
- Include merge operations: patch, sum, avg, immutable
- Address #578: allow custom prompt template addition and specification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add memory templating system with ReAct orchestrator

- Add YAML-configurable memory schemas (cards, events, entities, etc.)
- Implement MemoryReAct with tool use (read/find/ls)
- Add schema-driven memory operations (write_uris/edit_uris/delete_uris)
- Implement memory patch handler for incremental updates
- Add comprehensive test suite

* refactor: memory extractor templating system with ReAct orchestrator

## Summary

Implement memory templating system (GitHub Issue #578) - a complete
rewrite of the memory extractor subsystem to support YAML-configurable
memory types instead of hardcoded categories.

## Key Changes

### Architecture
- Replace hardcoded 8 memory types with YAML-configurable schema system
- Add MemoryTypeRegistry to load memory type definitions from YAML files
- Dynamic Pydantic model generation from schema for type safety
- Field-level merge operations: PATCH, SUM, IMMUTABLE

### Memory Extraction Flow
- Implement ReAct orchestrator for single-pass memory updates
- MemoryUpdater for applying operations to storage
- Memory tools (read, search, ls) for ReAct loop
- Stable JSON parser with 5-layer fault tolerance

### File Naming & Storage
- Semantic filenames from template ({topic}.md instead of random IDs)
- Two memory modes: simple mode and template mode
- MEMORY_FIELDS HTML comment for structured metadata

### Configuration
- 9 YAML templates in openviking/prompts/templates/memory/
- memory_config.py for memory system configuration
- Dual-threshold compact upload mechanism in design doc

### Deletions
- Remove old memory_content.py, memory_data.py, memory_operations.py
- Remove memory_types.py, memory_utils.py, memory_patch.py
- Remove corresponding old test files

### Updated Components
- VLM backends (litellm, openai, volcengine) for new interfaces
- Session and service core integration
- Test suite for new architecture

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: pass ctx/user/session_id in commit_async for memory extraction

## Summary

Fix missing parameters in commit_async() when calling extract_long_term_memories().
The synchronous commit() method correctly passes these parameters, but the async
version was missing them, causing memory extraction to be skipped.

## Changes

- Pass user=self.user, session_id=self.session_id, ctx=self.ctx
  in commit_async() when calling extract_long_term_memories()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: convert FindResult to dict before returning from search tool

## Summary

Fix JSON serialization error by converting FindResult object to dict
using its to_dict() method before returning from MemorySearchTool.

## Changes

- In MemorySearchTool.execute(), return search_result.to_dict()
  instead of search_result directly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: swap None check before accessing final_operations in memory_react

Also rename schema_models.py to schema_model_generator.py for clarity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add edit_overview support and optimize memory registry initialization

- Add edit_overview_operations to MemoryUpdater for updating .overview.md files
- Optimize MemoryTypeRegistry initialization in SessionCompressorV2 (load once)
- Various memory templating system improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove unnecessary indent in JSON schema output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add markdown link format hint to overview field description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add pre-fetch search based on user messages in conversation

Also fix duplicate line in system prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* rebase

* feat: add vectorization for memory files and overview format

- MemoryUpdater now vectorizes written/edited memory files after apply_operations
- MemoryReAct generates overview following semantic.overview_generation.yaml format
- Auto-extract and write .abstract.md from overview in memory_updater
- Fix import: VikingURI is from openviking_cli.utils.uri

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: update bot README to use openviking-server --with-bot and ov chat

- Change vikingbot gateway to openviking-server --with-bot
- Change vikingbot chat to ov chat
- Update --no-markdown to --no-format
- Remove --logs flag (not available)
- Simplify CLI Reference table
- Also update Chinese README_CN.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: rewrite xiaomei memory demo as standalone script

Convert from pytest to standalone script with:
- SyncHTTPClient instead of AsyncHTTPClient
- Rich for pretty console output
- Phase control (ingest/verify/all)
- Better error handling and progress display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: use markdown links in overview instead of numeric references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove duplicate code from copy-paste residue

- Remove duplicate logger and create_session_compressor in session/__init__.py
- Remove duplicate MemoryConfig import in open_viking_config.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 13:21:29 +08:00
chenjwandClaude Opus 4.6 2771765298 Refactor memory extract (#916)
* docs: add memory extractor templating and update mechanism optimization design document

- Add bilingual (English/Chinese) design document for memory templating system
- Include YAML-based MemoryTypeRegistry with 8 built-in types
- Detail ReAct 3+1 phase flow with pre-fetch optimization
- Describe 3-operation Schema: write/edit/delete
- Document RoocodePatch SEARCH/REPLACE format
- Explain dual-mode design: simple mode vs template mode
- Cover pre-fetch optimization: ls directories + read .abstract.md/.overview.md + search once
- Include merge operations: patch, sum, avg, immutable
- Address #578: allow custom prompt template addition and specification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add memory templating system with ReAct orchestrator

- Add YAML-configurable memory schemas (cards, events, entities, etc.)
- Implement MemoryReAct with tool use (read/find/ls)
- Add schema-driven memory operations (write_uris/edit_uris/delete_uris)
- Implement memory patch handler for incremental updates
- Add comprehensive test suite

* refactor: memory extractor templating system with ReAct orchestrator

## Summary

Implement memory templating system (GitHub Issue #578) - a complete
rewrite of the memory extractor subsystem to support YAML-configurable
memory types instead of hardcoded categories.

## Key Changes

### Architecture
- Replace hardcoded 8 memory types with YAML-configurable schema system
- Add MemoryTypeRegistry to load memory type definitions from YAML files
- Dynamic Pydantic model generation from schema for type safety
- Field-level merge operations: PATCH, SUM, IMMUTABLE

### Memory Extraction Flow
- Implement ReAct orchestrator for single-pass memory updates
- MemoryUpdater for applying operations to storage
- Memory tools (read, search, ls) for ReAct loop
- Stable JSON parser with 5-layer fault tolerance

### File Naming & Storage
- Semantic filenames from template ({topic}.md instead of random IDs)
- Two memory modes: simple mode and template mode
- MEMORY_FIELDS HTML comment for structured metadata

### Configuration
- 9 YAML templates in openviking/prompts/templates/memory/
- memory_config.py for memory system configuration
- Dual-threshold compact upload mechanism in design doc

### Deletions
- Remove old memory_content.py, memory_data.py, memory_operations.py
- Remove memory_types.py, memory_utils.py, memory_patch.py
- Remove corresponding old test files

### Updated Components
- VLM backends (litellm, openai, volcengine) for new interfaces
- Session and service core integration
- Test suite for new architecture

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: pass ctx/user/session_id in commit_async for memory extraction

## Summary

Fix missing parameters in commit_async() when calling extract_long_term_memories().
The synchronous commit() method correctly passes these parameters, but the async
version was missing them, causing memory extraction to be skipped.

## Changes

- Pass user=self.user, session_id=self.session_id, ctx=self.ctx
  in commit_async() when calling extract_long_term_memories()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: convert FindResult to dict before returning from search tool

## Summary

Fix JSON serialization error by converting FindResult object to dict
using its to_dict() method before returning from MemorySearchTool.

## Changes

- In MemorySearchTool.execute(), return search_result.to_dict()
  instead of search_result directly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: swap None check before accessing final_operations in memory_react

Also rename schema_models.py to schema_model_generator.py for clarity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add edit_overview support and optimize memory registry initialization

- Add edit_overview_operations to MemoryUpdater for updating .overview.md files
- Optimize MemoryTypeRegistry initialization in SessionCompressorV2 (load once)
- Various memory templating system improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove unnecessary indent in JSON schema output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add markdown link format hint to overview field description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add pre-fetch search based on user messages in conversation

Also fix duplicate line in system prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* rebase

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 15:28:46 +08:00