Skip to content

pa-format-memories

by rob

Text

Format retrieved memories into a text block suitable for LLM prompt injection. Parses JSON memory array and sorts by similarity distance.

# pa-format-memories

Format retrieved memories into a text block suitable for LLM prompt injection. Parses JSON memory array, sorts by similarity distance, and formats with context prefixes.

## Installation

This is a CmdForge tool. It should be installed and managed via CmdForge.

## Usage

This tool accepts JSON input via stdin (typically piped from another command):

```bash
# Format memories with default settings (max 5, block format)
echo '[{"content": "User prefers Python", "distance": 0.2}, {"content": "Lives in NYC", "distance": 0.3}]' | pa-format-memories

# Limit to 3 memories
echo '[...]' | pa-format-memories --max-memories 3

# Use simple list format instead of block
echo '[...]' | pa-format-memories --format list

# Chain with memory retrieval
pa-retrieve-memories "What languages does the user like?" | pa-format-memories --max-memories 10
```

## Arguments

| Flag | Default | Description |
|------|---------|-------------|
| `--max-memories` | `5` | Maximum number of memories to include in output |
| `--format` | `block` | Output format: 'block' (delimited section) or 'list' (simple list) |

## How It Works

1. **format_memories**: Accepts JSON array of memory objects via stdin, sorts by similarity distance (ascending), limits to max count, and formats into either a delimited text block or simple list suitable for injection into LLM prompts.

## Dependencies

None

No reviews yet.

Issues

No issues reported for this tool.