oracle / oracle/ai-optimizer

Memory 6: Integrate Built-in Chat Deterministically

Open
#565 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
101
Forks
46
Avg merge
6h 19m
Merged PRs (30d)
23

Description

The current orchestrator owns an in-memory HistoryStore in src/server/app/runtime/common.py. It loads that history before execution and appends a successful user and assistant pair afterward in src/server/app/runtime/langgraph/chat.py.

Implement this integration in three increments.

Phase 1 Persistent Transcript
  • Introduce a conversation-store protocol.
  • Keep the current in-memory implementation as the disabled or fallback mode.
  • Add an Agent Memory implementation using get_messages_async() and add_messages_async().
  • Persist only after a completed response, preserving current failed-turn behavior.
  • Ensure the streaming path writes exactly once after the final completion event.
Phase 2 Long-Term Retrieval
  • Before each turn, search durable memory using exact user scope.
  • Inject returned content in a clearly delimited, untrusted context block.
  • Do not allow memory-derived text to authorize database writes, privilege changes, or other sensitive actions.
  • Return non-content metadata such as result count and record types in ChatResponse and the SSE completion event.
Phase 3 Context Compaction
  • Continue using raw messages for short conversations.
  • At a configured token threshold, replace the older prefix with get_context_card_async().content plus a small recent-message tail.
  • Do not pass both the complete transcript and a context card containing the same transcript.
  • Oracle specifically recommends context cards when compaction should retain summary, topics, relevant durable records, and recent turns.

Reference: Use Agent Memory short-term APIs with LangGraph.

Recommended failure behavior:

  • Explicit memory REST or MCP calls fail closed with a clear error.
  • Chat retrieval may fail open and continue without memory, while reporting memory_status="unavailable".
  • A failed post-response persistence call must not retract an answer already streamed to the client.
  • Background extraction should initially be opt-in. Explicit "remember this" writes offer more predictable behavior for the first release.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/server/app/runtime/common.py and src/server/app/runtime/langgraph/chat.py to trace HistoryStore loading, successful-turn persistence, and streaming completion handling. Review the linked Oracle Agent Memory LangGraph guide before defining the conversation-store boundary. Done means the three phases cover durable retrieval and persistence, safe metadata and failure behavior, and threshold-based context-card compaction with exactly-once streaming writes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, backend-api-design, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.