Overview
TheMubitMemoryEngine writes captured events to Mubit for semantic search, cross-contributor context sharing, and collaborative Q&A.
Class: MubitMemoryEngine
Constructor
Mubit API key (defaults to
MUBIT_API_KEY environment variable)Mubit endpoint URL
HTTP-specific endpoint
gRPC-specific endpoint
Transport protocol:
"auto" | "http" | "grpc"Agent identifier for Mubit runs
Prefix for Mubit run IDs
Shared project ID (overrides per-repo IDs)
Default actor ID for events
Run scope strategy:
"session": Separate run per session (codaph:{projectId}:{sessionId})"project": Shared run across all sessions (codaph:{projectId})
Enable/disable memory writes
Custom Mubit client instance
Methods
writeEvent
Writes a single event to Mubit.Event to write
Whether Mubit accepted the event
True if event was deduplicated by Mubit
Mubit job ID for async processing
Raw Mubit response
writeEventsBatch
Writes multiple events in a single batch request.Events to write
writeRunState
Updates run state variables in Mubit.Mubit run ID
State variables to set
querySemanticContext
Performs semantic search over Mubit run history.Run ID to query
Natural language query
Maximum results to return
Include linked runs in search
Query lane for direct bypass mode
Query routing mode
fetchContextSnapshot
Retrieves a context snapshot from Mubit.Run ID
Maximum timeline events to include
Force snapshot refresh
isEnabled
Checks if memory engine is enabled and configured.true if API key is configured and enabled
runIdForSession
Generates Mubit run ID for a session.promptRunIdForRepo
Generates Mubit run ID for prompt-specific tracking.Run Scope Strategies
Session Scope (Default)
Each captured session gets its own Mubit run:- Isolated session context
- Clear session boundaries
- No cross-session context sharing
Project Scope
All sessions for a project share a single Mubit run:- Shared context across all contributors and sessions
- Better for collaborative teams
- Larger run history
Helper Functions
mubitRunIdForSession
mubitRunIdForProject
createMubitMemoryFromEnv
Creates a Mubit engine from environment variables.null if MUBIT_API_KEY not set
Usage Example
Semantic Search Example
Activity Streams
The engine writes activity streams to Mubit for timeline visualization:- Main activity stream: Compacted event envelopes
- Prompt stream: Separate stream for prompt-specific tracking
- Session summaries: Aggregated session metadata
- Diff parts: File change diffs for code review context
Circuit Breaker
When used withIngestPipeline, Mubit writes automatically open a circuit after consecutive failures (default: 3). This prevents cascading failures while allowing local mirror writes to continue.