feat(memory): optional Dongtian memory retrieval for system prompt context#72
Open
siaochuan wants to merge 11 commits intoHKUDS:mainfrom
Open
feat(memory): optional Dongtian memory retrieval for system prompt context#72siaochuan wants to merge 11 commits intoHKUDS:mainfrom
siaochuan wants to merge 11 commits intoHKUDS:mainfrom
Conversation
(cherry picked from commit 7d2a010)
…DS#138) `asyncio.gather` was called without `return_exceptions=True`, so a single escaping exception from one parallel tool propagated out of the gather, abandoned its sibling coroutines, and left the assistant turn with one or more `tool_use` blocks that never received a matching `tool_result`. The Anthropic Messages API rejects the next request on the session with a 400 in that state, so any unhandled tool exception during a multi-tool turn effectively bricks the session. Pass `return_exceptions=True` and synthesize an `is_error=True` `ToolResultBlock` for each raised exception, matched to the originating `tool_use_id`. The exception is logged via `log.exception` so the failure is still observable. Co-authored-by: José Maia <glitch-ux@users.noreply.github.com> (cherry picked from commit a2dea03)
(cherry picked from commit 9f97283)
Files under ~/.openharness/ — credentials, settings, session snapshots, cron registry, memory index — were written with `Path.write_text()` in truncating mode. A crash, SIGKILL, power loss, or out-of-disk error during the write leaves a truncated file on disk; concurrent writers clobber each other's updates; and the credentials file spent a brief window at the default umask mode (commonly 0o644) before chmod-to-0600 ran. Introduce `openharness.utils.fs.atomic_write_text` / `atomic_write_bytes` which write to a same-directory temp file, fsync, apply the target mode while the file is still private, and `os.replace` into place. Thread them through all persistence writers. For read-modify-write on shared files (credentials, settings, cron, memory index), pair atomic writes with the existing `exclusive_file_lock` primitive so two `oh` processes no longer race. The generic lock helper moves from `openharness.swarm.lockfile` to `openharness.utils.file_lock`. `swarm.lockfile` is retained as a thin re-export so existing callers keep working. Co-authored-by: José Maia <glitch-ux@users.noreply.github.com> (cherry picked from commit 4857439)
…fresh line (HKUDS#133) * fix(tui): write newline on exit so shell prompt starts on fresh line Ink hides the cursor during rendering and restores it on exit, but does not emit a trailing newline. When the TUI process ends, the terminal cursor sits at the end of the last rendered line, causing the shell prompt to appear directly concatenated with the TUI output. Rename restoreCursor → restoreTerminal and append '\n' alongside the cursor-show escape sequence so the parent shell always receives the prompt on a clean new line. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test(tui): add regression guard for exit newline; update changelog - Add tests/test_ui/test_tui_exit_sequence.py with two tests: * test_tui_exit_handler_writes_newline: asserts the cleanup write includes the trailing \n alongside \x1B[?25h * test_tui_exit_handler_registered_for_all_signals: asserts cleanup is registered for 'exit', SIGINT, and SIGTERM - Add entry to CHANGELOG.md [Unreleased] Fixed section Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(tests): update ohmo cli test inputs for allow_remote_admin_commands prompt Commit dd1d235 added a new 'Allow explicitly listed administrative slash commands from remote channels?' confirmation step to the gateway config wizard, but the four interactive test cases in test_ohmo/test_cli.py were not updated to provide an answer for it. This caused stdin to be exhausted and click to emit Abort(), making all four tests fail with exit_code=1. Add 'n' as the answer for allow_remote_admin_commands in each affected test, and move the existing 'restart gateway' answer after it in test_ohmo_config_interactive_can_restart_gateway. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit ed0b5f0)
…tream events API" This reverts commit 5be05c7.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #67
Summary
Add an optional integration layer that retrieves relevant conversation snippets from a local Dongtian memory database and injects them into the system prompt. Default behavior is completely unchanged — the feature is off unless explicitly enabled.
How it works
Configuration
{ "memory": { "enabled": true, "dongtian_enabled": true, "dongtian_db_path": "~/.dongtian/palace.db", "dongtian_limit": 5, "dongtian_max_chars": 1200 } }All fields have safe defaults. Set `dongtian_enabled: true` to activate.
Design decisions
Relation to #67
This addresses the same need as #67 (external memory retrieval for system prompt) with a different backend:
Both approaches are valid for different use cases. A future `MemoryProvider` protocol could unify them — see discussion on #67.
Files
What is Dongtian?
Dongtian is a lightweight AI conversation memory system (~1200 lines, SQLite + FTS5 + optional embeddings). It ingests sessions from Claude Code, Codex, OpenCode/DeepSeek, ChatGPT, and Slack into a structured searchable database. It also runs as an MCP server with 15 tools for search, ingestion, knowledge graph, and SSH remote sync.