mem_get_observation
Signature
mem.mem_get_observation(user_id: str, observation_id: int) -> Observation | None
Fetches an observation by its integer primary key, scoped to user_id. Cross-user access returns None (never raises, never leaks). Use this to hydrate the full content of an observation surfaced by mem_search or mem_timeline.
Parameters
| Parámetro | Tipo | Requerido | Descripción |
|---|---|---|---|
user_id | str | sí | Owner scope. If the observation belongs to a different user, the result is None. |
observation_id | int | sí | Positive integer primary key (obtained from mem_search or mem_timeline results). |
Returns
Observation | None (Pydantic model | None):
The full observation if found and owned by user_id, else None. Fields:
id(int)session_id(str)user_id(str)type(str)title(str)content(str) — full text, with<private>blocks already replaced by[REDACTED].topic_key(str | None)revision_count(int)created_at(str, ISO-8601 UTC)updated_at(str, ISO-8601 UTC)
Raises
ValueError—observation_id <= 0.
Examples
- Hydrate after search
- Cross-user attempt returns None
- After save
hits = mem.mem_search(user_id="alice", query="auth")
if hits:
full = mem.mem_get_observation(user_id="alice", observation_id=hits[0].id)
print(full.content)
# observation 42 belongs to alice
result = mem.mem_get_observation(user_id="bob", observation_id=42)
assert result is None # never raises, never leaks
saved = mem.mem_save(user_id="alice", content="...", type="decision", title="...")
obs = mem.mem_get_observation(user_id="alice", observation_id=saved.id)
print(obs.revision_count) # 1