AI conversations should be stored in OSIS (per-context, per-user, persistent) #45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
AI conversations are stored in Shrimp's local SQLite (
data/shrimp.db), not in OSIS. This means:Expected
Conversations should be stored in OSIS, likely in the
aiorcommunicationdomain, scoped by context and user:ai.conversation— conversation metadata (title, created_at, context)ai.message— individual messages (role, content, timestamp, conversation_id)Impact
This ties into the broader question of whether Shrimp (Bun/TypeScript) should be rewritten as a native Rust agent that integrates directly with the Hero ecosystem:
Approach Options
hero_agent) that uses OSIS SDK natively, replaces Shrimp graduallyRelated
Decision: Enhance Shrimp, no Rust rewrite
Shrimp (Bun/TypeScript) stays as the AI agent. The approach for OSIS conversation storage:
ai.conversation/ai.messagedomainscontext_nameparam)Why not Rust: TypeScript is better for AI agent iteration speed — prompt engineering, tool development, LLM API integration. Shrimp works well, the gap is only storage integration.
Estimated effort: ~2-3 days
mik-tf referenced this issue2026-03-19 00:26:50 +00:00
mik-tf referenced this issue2026-03-19 02:54:39 +00:00
Implementation Plan — Full OSIS Migration (no SQLite)
Drop SQLite entirely. Conversations stored in OSIS with real user identity.
Phase 1: OSIS Schema (hero_osis)
Create
hero_osis/schemas/ai/conversation.oschema:Generates: types, CRUD, RPC methods, SDK client.
Phase 2: hero_agent Backend Migration
Remove: db.rs (SQLite), conversation.rs (SQLite wrapper), rusqlite dep
Add: OSIS client, conversation_osis.rs with list/get/create/save_message/load_history/delete/rename via OSIS RPC
Keep: All REST API endpoints unchanged — frontend doesn't know backend changed
Phase 3: User Identity
Replace hardcoded
anonymouswith real user from auth session token. All OSIS operations scoped to real user.Phase 4: Data Migration
One-time script: SQLite conversations → OSIS objects. Then remove SQLite file.
Phase 5: Frontend Cleanup
Remove localStorage conversation tracking. Sidebar already uses /api/conversations — no UI changes needed.
Testing (7 layers)
Files
Signed-off-by: mik-tf
Implementation Plan — Confirmed
Proceeding with the 5-phase plan. Key clarifications from code review:
Phase 1: OSIS Schema (hero_osis)
schemas/ai/conversation.oschemawith AI-specific typescommunication/chat.oschema— that's for general messaging (DMs, groups, reactions). AI conversations need different fields:role,tool_calls,context,tool_call_idPhase 2: Backend Migration (hero_agent)
conversation_osis.rs— wraps generated OSIS clientagent.rsto use OSIS instead of SQLiteConversationStoreroutes.rs— same REST API surface, backend swapdb.rspartially — audit_log, usage_log, memories stay in SQLite for now (tracked in #91)Phase 3: User Identity
anonymousPhase 4: Data Migration
Phase 5: Frontend Cleanup
/api/conversations— no UI changesFiles
hero_osis/schemas/ai/conversation.oschemahero_agent/crates/hero_agent/src/conversation_osis.rshero_agent/crates/hero_agent/src/conversation.rshero_agent/crates/hero_agent/src/db.rshero_agent/crates/hero_agent/src/agent.rshero_agent/crates/hero_agent_server/src/routes.rshero_agent/crates/hero_agent/Cargo.tomlWhat stays in SQLite (tracked separately)
audit_log— tool execution trackingusage_log— token usage per modelmemories— agent memory storageThese will be migrated in #91.
Signed-off-by: mik-tf
Implementation Complete — Full OSIS Migration
All 5 SQLite tables migrated to OSIS. SQLite and
rusqlitedependency removed entirely.Changes by repo
hero_osis
schemas/ai/agent_data.oschema— 5 rootobjects:AgentConversation,AgentMessage,AgentMemory,AgentAuditEntry,AgentUsageEntrycrates/hero_osis_server/src/ai/rpc.rs— added trigger stubs for all 5 new rootobjectshero_agent
crates/hero_agent/src/osis_store.rs— OSIS-backed store replacing SQLite, wraps AiClient CRUD operationscrates/hero_agent/src/db.rs(711 lines, SQLite)crates/hero_agent/src/conversation.rs(90 lines, SQLite wrapper)crates/hero_agent/src/agent.rs— usesOsisStoreinstead ofDatabase+ConversationStorecrates/hero_agent/src/memory.rs— async OSIS-backedMemoryStorecrates/hero_agent/src/auto_memory.rs— async memory savecrates/hero_agent/src/channels/cli.rs— usesstore.clear_conversation()crates/hero_agent/src/channels/telegram.rs— usesstore.clear_conversation()crates/hero_agent/src/lib.rs— replaceddb+conversationmodules withosis_storecrates/hero_agent/Cargo.toml—rusqliteremoved,hero_osis_sdkaddedcrates/hero_agent_server/src/main.rs—OsisStore::new()replacesDatabase::open()crates/hero_agent_server/src/routes.rs— all 12+ route handlers migrated to async OSIS callsCargo.toml(workspace) — removedrusqlite, addedhero_osis_sdkhero_services
docker/cargo-server-patches.toml— addedhero_osis_sdkpatch for Docker buildsAPI Surface
All REST endpoints unchanged — frontend needs zero changes:
GET/POST /api/conversationsGET/DELETE/PATCH /api/conversations/{id}GET /api/conversations/{id}/messagesGET /api/stats,/api/audit,/api/usage,/api/memoriesPOST /api/chat,/api/voice/chatConfiguration
New env vars for OSIS connection:
OSIS_URL(default:http://127.0.0.1:9999/hero_osis)OSIS_CONTEXT(default:default)What was removed
rusqlitecrate (no more SQLite dependency)hero_agent.dbfile (no more SQLite database)This also completes #91 — all 5 tables (conversations, messages, audit_log, usage_log, memories) are now in OSIS.
Signed-off-by: mik-tf
Testing Complete
Build
make dist-quick— 22/22 succeeded, 0 failedTAG=local make pack— image built successfullySmoke tests (layer 2)
Integration tests (layer 3)
OSIS migration verified
0006Repos ready for squash merge
Signed-off-by: mik-tf
Deferred: User Identity (Phase 3)
Phase 3 (replace hardcoded "anonymous" with real auth user) was deferred to #92 — requires auth middleware design work.
All other phases (1-2, 4-5) completed. v0.7.2-dev deployed and verified.
Signed-off-by: mik-tf