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

# mem_capture_passive

> Extract and save structured learnings from text output

Extract and save structured learnings from text output. This tool automatically detects and saves learning sections from your output.

## Overview

`mem_capture_passive` looks for sections like `## Key Learnings:` or `## Aprendizajes Clave:` in text output and extracts numbered or bulleted items. Each item is saved as a separate observation with type `passive`.

This is useful for:

* Automatically capturing knowledge at the end of tasks
* Extracting learnings from agent responses
* Building a knowledge base from subagent completions
* Saving discoveries without manual `mem_save` calls

## Parameters

<ParamField path="content" type="string" required>
  The text output containing a learnings section. Must include a heading like `## Key Learnings:` followed by numbered or bulleted items.
</ParamField>

<ParamField path="session_id" type="string">
  Session ID to associate the learnings with. Defaults to `manual-save-{project}`.
</ParamField>

<ParamField path="project" type="string">
  Project name to scope the learnings. Defaults to the current directory name.
</ParamField>

<ParamField path="source" type="string">
  Source identifier for tracking where learnings came from (e.g., `subagent-stop`, `session-end`, `manual`).
</ParamField>

## Response

<ResponseField name="saved" type="number">
  Number of new learnings saved
</ResponseField>

<ResponseField name="skipped" type="number">
  Number of duplicate learnings skipped (already exist in memory)
</ResponseField>

<ResponseField name="total" type="number">
  Total number of learnings found in the input
</ResponseField>

## Expected Format

The tool recognizes two heading formats:

**English:**

```markdown theme={null}
## Key Learnings:

1. First learning item
2. Second learning item
```

**Spanish:**

```markdown theme={null}
## Aprendizajes Clave:

1. Primer aprendizaje
2. Segundo aprendizaje
```

You can also use bulleted lists:

```markdown theme={null}
## Key Learnings:

- Learning with bullet points
- Another learning
```

## Example Usage

### Basic Usage

```json theme={null}
{
  "content": "## Key Learnings:\n\n1. bcrypt cost=12 is the right balance for our server performance\n2. JWT refresh tokens need atomic rotation to prevent race conditions",
  "session_id": "session-abc123",
  "project": "auth-service"
}
```

**Response:**

```json theme={null}
{
  "saved": 2,
  "skipped": 0,
  "total": 2
}
```

Each learning is saved as a separate observation:

* Title: First 50 characters of the learning
* Type: `passive`
* Content: Full learning text
* Project: `auth-service`
* Session: `session-abc123`

### With Duplicates

```json theme={null}
{
  "content": "## Key Learnings:\n\n1. bcrypt cost=12 is the right balance\n2. New learning about rate limiting",
  "session_id": "session-xyz789",
  "project": "auth-service"
}
```

**Response:**

```json theme={null}
{
  "saved": 1,
  "skipped": 1,
  "total": 2
}
```

The first learning was already saved in a previous call, so it's skipped. Only the new learning about rate limiting is saved.

## Deduplication

The tool uses content-based deduplication:

* Each learning is hashed based on normalized content (lowercase, whitespace trimmed)
* If the hash matches an existing observation in the same project within a 15-minute window, it's skipped
* This prevents duplicate saves when the same learnings appear in multiple outputs

## Use Cases

### End-of-Task Knowledge Capture

When completing a task, include a Key Learnings section:

```markdown theme={null}
I've successfully implemented user authentication.

## Key Learnings:

1. Passport.js local strategy requires bcrypt version 5+ for async hash
2. JWT expiry should be configurable per environment (15m dev, 1h prod)
3. Refresh token rotation prevents token replay attacks
```

Call `mem_capture_passive` with this output to automatically save all three learnings.

### Subagent Completion Hooks

When a subagent finishes work, extract learnings automatically:

```json theme={null}
{
  "content": "<subagent output with learnings section>",
  "source": "subagent-stop",
  "project": "current-project"
}
```

### Session End Summary

Capture learnings from end-of-session summaries:

```json theme={null}
{
  "content": "<session summary with discoveries>",
  "source": "session-end",
  "session_id": "session-final"
}
```

## Comparison with mem\_save

| Feature           | mem\_capture\_passive             | mem\_save                         |
| ----------------- | --------------------------------- | --------------------------------- |
| **Format**        | Extracts from markdown headings   | Structured What/Why/Where/Learned |
| **Granularity**   | One observation per learning item | One observation per save call     |
| **Use Case**      | Automatic extraction from output  | Explicit, proactive saves         |
| **Control**       | Less control (auto-parsed)        | Full control over structure       |
| **Deduplication** | Automatic within 15-min window    | Manual topic key upserts          |

Use `mem_save` for deliberate, structured memories. Use `mem_capture_passive` for automatic knowledge extraction from text.

## Profile

**Profile:** `agent` (deferred loading)

This tool is in the `agent` profile but has `DeferLoading` enabled, meaning it's available to agents but not loaded into context by default. Agents can discover it through tool search when needed.

**Why deferred?** Most agents use `mem_save` for explicit memory creation. Passive capture is specialized for automated workflows and may not be needed in every session.

## Related Tools

<CardGroup cols={2}>
  <Card title="mem_save" icon="floppy-disk" href="/mcp/mem-save">
    Save structured observations explicitly
  </Card>

  <Card title="mem_search" icon="magnifying-glass" href="/mcp/mem-search">
    Search saved learnings
  </Card>

  <Card title="mem_session_summary" icon="file-lines" href="/mcp/mem-session-summary">
    Save comprehensive session summaries
  </Card>

  <Card title="POST /observations/passive" icon="globe" href="/api/observations#passive-capture">
    HTTP API for passive capture
  </Card>
</CardGroup>
