Skip to main content

remember_entry

Function remember_entry 

Source
pub async fn remember_entry(
    entry: MemoryEntry,
    dataset_name: &str,
    session_id: &str,
    owner_id: Uuid,
    _tenant_id: Option<Uuid>,
    db: Option<Arc<DatabaseConnection>>,
    _session_store: Option<Arc<dyn SessionStore>>,
    session_manager: Option<Arc<SessionManager>>,
    llm: Option<Arc<dyn Llm>>,
) -> Result<RememberResult, ApiError>
Expand description

Dispatch a typed MemoryEntry to the appropriate SessionManager method.

Mirrors Python’s _dispatch_session_entry at cognee/api/v1/remember/remember.py:190-313. The entry_type / entry_id fields on the returned RememberResult are populated for all three branches; the HTTP DTO at crates/http-server/src/dto/ (E-02) carries them through to the wire.

Behavior:

  • Empty session_id returns Err(ApiError::InvalidArgument) (Python parity: ValueError → HTTP 400 at the handler boundary).
  • Best-effort pre-upsert via SessionLifecycleDb::ensure_and_touch_session; any failure is logged at debug level and swallowed (Python parity: try/except around the pre-upsert at remember.py:232-253).
  • MemoryEntry::QaSessionManager::save_qa; if any of feedback_text / feedback_score / used_graph_element_ids is set, a follow-up SessionManager::update_qa applies the partial update. entry_type = "qa", entry_id = qa_id.
  • MemoryEntry::TraceSessionManager::add_agent_trace_step. method_params.unwrap_or(Value::Null) is passed because the Rust signature requires a non-Option value. Feedback generation happens inside SessionManager based on generate_feedback_with_llm and whether an LLM is wired. entry_type = "trace", entry_id = trace_id.
  • MemoryEntry::FeedbackSessionManager::add_feedback. On Ok(true) the result reports RememberStatus::SessionStored with entry_id = qa_id. On Ok(false) the result reports RememberStatus::Errored with error = Some("add_feedback: QA <id> not found in session <sid>"). entry_type = "feedback".

LLM feedback: When TraceEntry::generate_feedback_with_llm is true and llm is Some, the trace entry’s session_feedback is produced by calling the LLM with the agent_trace_feedback_summary_system prompt (Python parity); the call is bounded by an 8-second timeout. On timeout, LLM error, missing llm handle, or empty method_return_value, the implementation falls back to the deterministic Python-parity strings ("<origin> succeeded." / "<origin> failed. Reason: ..." / "<origin> failed."). When generate_feedback_with_llm is false, the deterministic fallback is recorded regardless — also Python parity (session_manager.py:289-294).