mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 06:32:24 +00:00
* feat: implement user working memory extraction from skill sync payloads - Added functionality to enable the extraction of user working memory from successful skill syncs, allowing for persistent storage of user preferences, goals, constraints, and entities. - Introduced a new configuration option in to toggle working memory extraction. - Created comprehensive documentation on the working memory extraction process, detailing its implementation and privacy considerations. - Updated memory loading logic to include working memory entries in the context provided to agents, enhancing personalization capabilities. - Enhanced logging for memory extraction processes to improve observability and debugging. This feature enhances the user experience by allowing skills to maintain context across interactions, improving the overall effectiveness of the OpenHuman platform. * docs: update architecture documentation to include user working memory integration * refactor: centralize working memory constants and enhance extraction logic - Moved `WORKING_MEMORY_KEY_PREFIX` and `WORKING_MEMORY_LIMIT` constants to `memory_context.rs` for better organization and accessibility. - Updated `MemoryLoader` to utilize these constants, improving code clarity. - Enhanced working memory extraction logic in `MemoryWriteJob` to conditionally persist user working-memory documents based on the job type. - Improved logging for memory extraction processes to provide clearer insights during execution. - Adjusted tests to ensure consistent behavior with the new working memory extraction logic. * chore: update OpenHuman version to 0.51.8 and refactor JSON-RPC test for clarity - Bumped the OpenHuman version in Cargo.lock from 0.51.6 to 0.51.8. - Refactored the JSON-RPC end-to-end test to improve readability by encapsulating the result assertion logic within a block, enhancing clarity in the flow of data handling.
61 lines
2.8 KiB
Markdown
61 lines
2.8 KiB
Markdown
# Skill Sync Working Memory
|
|
|
|
This document describes how OpenHuman turns successful skill sync payloads into durable user working memory for agent personalization.
|
|
|
|
## Definition
|
|
|
|
- **User working memory**: persisted, user-scoped facts that remain useful across turns (preferences, goals, constraints, recurring entities).
|
|
- **Ephemeral chat context**: transient per-turn conversation state and prompt history; not persisted by this flow.
|
|
- **TTL policy**: no TTL by default (`ttl = "none"`), but growth is bounded with deterministic upsert keys.
|
|
|
|
## Hook location
|
|
|
|
- Sync entrypoint: `src/openhuman/skills/qjs_skill_instance/event_loop/rpc_handlers.rs` (`handle_sync`).
|
|
- Sync persistence worker: `src/openhuman/skills/qjs_skill_instance/event_loop/mod.rs` (`spawn_memory_write_worker`).
|
|
- Working-memory extraction: `src/openhuman/skills/working_memory.rs`.
|
|
- Agent recall/injection: `src/openhuman/agent/loop_/memory_context.rs` and `src/openhuman/agent/memory_loader.rs`.
|
|
|
|
Flow:
|
|
1. `skills.sync` triggers `skill/sync`.
|
|
2. On success, the event loop enqueues a memory write job.
|
|
3. The memory worker stores raw sync history and runs working-memory extraction.
|
|
4. Extracted working-memory documents are upserted into `global` with fixed keys:
|
|
- `working.user.<skill>.preferences`
|
|
- `working.user.<skill>.goals`
|
|
- `working.user.<skill>.constraints`
|
|
- `working.user.<skill>.entities`
|
|
- `working.user.<skill>.summary`
|
|
|
|
Control switch:
|
|
- `OPENHUMAN_SKILLS_WORKING_MEMORY_ENABLED=false` disables this extraction/persistence path.
|
|
|
|
## Privacy and safety
|
|
|
|
- Sensitive keys (`token`, `secret`, `password`, `credential`, OAuth/auth fields, API keys, JWT/cookies) are skipped.
|
|
- Sensitive value heuristics are applied to avoid persisting secret-like blobs.
|
|
- Common PII patterns (email, phone) are redacted before persistence.
|
|
|
|
## Logging and observability
|
|
|
|
Per sync batch, the worker logs:
|
|
- scalar fields scanned
|
|
- sensitive fields skipped
|
|
- extracted preferences/goals/constraints/entities
|
|
- generated/persisted/failed working-memory docs
|
|
|
|
Log prefix: `[skills-working-memory]`.
|
|
|
|
## Agent usage (controlled)
|
|
|
|
- Agent context assembly now appends a bounded `[User working memory]` section.
|
|
- Only `working.user.*` keys are included, with relevance threshold + small caps.
|
|
- This keeps personalization available while preventing unbounded prompt growth.
|
|
|
|
## Extending for new skills
|
|
|
|
When a new integration needs better extraction quality:
|
|
1. Add or tune classification heuristics in `classify_into_buckets` and `looks_like_*` helpers in `src/openhuman/skills/working_memory.rs`.
|
|
2. Keep persistence bounded by reusing deterministic keys (do not introduce unbounded per-item keys by default).
|
|
3. Add/update tests with mocked sync payloads in `src/openhuman/skills/working_memory.rs`.
|
|
4. Verify degraded behavior remains non-fatal (sync success should not fail due to memory extraction issues).
|