> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Who your agent keeps meeting

> Extraction names the people, companies and systems in every memory. Read the graph it has been building.

[← All use cases](/use-cases/overview)

<div className="uc-examples"><a href="https://github.com/anonalabs/Anona-Memory-SDK/blob/main/examples/knowledge_graph.py">knowledge\_graph.py</a></div>

## The scenario

You have been recording facts for months. Nobody built an ontology, nobody
tagged anything — and there is already a graph of who and what keeps appearing
together, because extraction names entities as it stores each memory.

## Step 1 — Read the graph

```python theme={null}
graph = client.get_graph(space_id=space)
for edge in graph["edges"]:
    print(edge["source_label"], "—", edge["target_label"], f"(x{edge['weight']})")
```

Nodes are entities; edges are **co-occurrence** — two entities appearing in the
same memory, weighted by how often.

## Step 2 — Address one entity

```python theme={null}
entities = client.list_entities(space_id=space)
first = client.get_entity(space_id=space, entity_id=entities[0]["id"])
print(first["name"], "mentioned", first["mention_count"], "times")
for obs in first["observations"]:
    print(obs)
```

`observations` fills as the space consolidates what it has stored about that
entity — which is how you get a dossier nobody wrote.

## Step 3 — Cut the noise

```python theme={null}
client.get_graph(space_id=space, min_count=3)
```

On a real space most entities are mentioned once. `min_count` is what turns a
hairball into something readable.

## Evals

1. Record four facts that connect three entities. Check the expected edges exist
   with the expected weights.
2. Raise `min_count` and confirm the long tail drops out.
3. Fetch an entity and check `observations` is populated — if it is empty on a
   busy space, consolidation has not run yet rather than failed.

## Guardrails

<Warning>
  **Edges are co-occurrence, not typed relationships.** The graph says two
  entities keep showing up together. It does not say one *owns*, *acquired* or
  *reports to* the other. Do not build a UI, or a sales claim, that implies
  typed predicates.
</Warning>

* **Entity names come from extraction**, so the same person can appear under two
  spellings if your source text does.
* **Read it as a map, not a database.** It is excellent for "what is this space
  mostly about" and wrong for anything needing exactness.

## The script

Complete and runnable:
[`knowledge_graph.py`](https://github.com/anonalabs/Anona-Memory-SDK/blob/main/examples/knowledge_graph.py).
