Skip to content

fix(chat): store knowledge as fact triples, not free text (+ add pyoxigraph) - #178

Draft
sofiiako wants to merge 1 commit into
anthillnet:mainfrom
sofiiako:fix/chat-kb-store-format
Draft

fix(chat): store knowledge as fact triples, not free text (+ add pyoxigraph)#178
sofiiako wants to merge 1 commit into
anthillnet:mainfrom
sofiiako:fix/chat-kb-store-format

Conversation

@sofiiako

Copy link
Copy Markdown

Problem

Asking the resident chat agent to remember something always failed with a format
error — the agent surfaced something like:

the storage mechanism expects a specific JSON structure ({"facts": [...]}) that
I'm not able to construct

Two bugs on the knowledge-write path:

  1. Wrong payload shape. sinain_memory_store in sinain-chat-agent/tools.py
    takes a free-text text and POSTs {"content": text} to /knowledge/import.
    But that endpoint requires entity/attribute/value triples — {"facts":[...]}
    the same shape the MCP server's sinain_memory_store already sends. So the core
    rejected every save with No 'facts' array found. ... Got keys: content.

  2. Missing dependency. Even with the right shape, persistence fails: the core
    shells out to python3 -c "... from triplestore import TripleStore ...", and
    triplestore.pyrdf_store.py does import pyoxigraph unconditionally.
    pyoxigraph isn't in sinain-memory/requirements.txt, so /knowledge/import
    errors with ModuleNotFoundError: No module named 'pyoxigraph'.

Fix

  • sinain-chat-agent/tools.pysinain_memory_store now accepts a structured
    facts list (new StoreFact model: entity/attribute/value + optional
    confidence/domain, matching the MCP tool), drops empty/None fields, skips facts
    missing a required key, and POSTs {"facts": [...]}. Tool description updated to
    describe the triple shape.
  • sinain-hud-plugin/sinain-memory/requirements.txt — add pyoxigraph>=0.4

The chat sidecar's sinain_memory_store sent {"content": text} to
/knowledge/import, but that endpoint requires entity/attribute/value triples
({"facts":[...]}) — the same shape the MCP server already uses. Every save was
rejected with "No 'facts' array found". Change the tool to accept a structured
facts list (StoreFact) and POST {"facts": [...]}.

Also add pyoxigraph to sinain-memory/requirements.txt: triplestore.py ->
rdf_store.py imports it unconditionally, so /knowledge/import fails to persist
without it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants