GoodMemGoodMem
ReferenceCLIMemory

Memory Retrieve

Memory Retrieve CLI command reference

goodmem memory retrieve

Retrieve memories using semantic search

Synopsis

Retrieve memories from specified spaces using semantic search.

By default, this command returns the direct search results. To refine or process these results further, you can specify a post-processor using the --post-processor, --post-processor-args, or --post-processor-interactive flags.

Results are streamed in real-time as they become available.

goodmem memory retrieve <query> [flags]

Examples

  # Basic search in a single space
  goodmem memory retrieve --space-id 123e4567-e89b-12d3-a456-426614174000 "machine learning best practices"

  # Search multiple spaces with additional context
  goodmem memory retrieve \
    --space-id space1 --space-id space2 \
    --context-text "for production systems" \
    --max-results 20 \
    "deployment strategies"

  # Include files as context
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --context-file config.yaml \
    --fetch-content \
    "configuration issues"

  # Control output format and generation
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --filter "CAST(val('$.effectiveDate') AS DATE) >= CAST('2024-10-01' AS DATE)" \
    --no-abstract \
    --format json \
    "debugging tips"

  # Set resource budgets
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --output-budget 1000 \
    --compute-budget 5000 \
    "optimization techniques"

  # Advanced: tune HNSW scan behavior for filtered ANN queries
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --hnsw-iterative-scan relaxed-order \
    --hnsw-max-scan-tuples 200000 \
    --hnsw-scan-mem-multiplier 8 \
    "high-cardinality query"

  # Use ChatPostProcessorFactory with custom arguments
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --post-processor-args '{"llm_id": "123e4567-e89b...", "reranker_id": "456e4567-e89b...", "relevance_threshold": 0.7}' \
    "search query"

  # Use ChatPostProcessorFactory with arguments from file
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --post-processor-args @processor-config.json \
    "search query"

  # Use custom post-processor
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --space-id 223e4567-e89b-12d3-a456-426614174111 \
    --filter @filter-prod.sql --filter @filter-staging.sql \
    --post-processor "com.example.SimplePostProcessor" \
    "search query"

  # Interactive configuration for ChatPostProcessorFactory
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --post-processor-interactive \
    "search query"

  # Give a task instruction for this search. Embedders whose stored query template reads
  # {{ instruction }} use it; the others ignore it.
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --query-instruction "Given a claim, retrieve passages that support or refute it" \
    "vitamin D prevents colds"

  # Replace one embedder's query template for this search only
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --embedder-query-format '{"embedderId":"550e8400-e29b-41d4-a716-446655440001","queryTemplate":"search_query: {{ content }}"}' \
    "deployment strategies"

  # Give the reranker a task instruction for this search (ChatPostProcessorFactory keys:
  # reranker_instruction, reranker_query_template, reranker_document_template)
  goodmem memory retrieve \
    --space-id 123e4567-e89b-12d3-a456-426614174000 \
    --post-processor-args '{"reranker_id":"650e8400-e29b-41d4-a716-446655440002","reranker_instruction":"Prefer recent documents"}' \
    "release notes"

Options

      --compute-budget uint32                     Token budget for compute operations
      --context-file strings                      Files to include as binary context (can be specified multiple times)
      --context-text strings                      Additional text context to clarify the query (can be specified multiple times)
      --debug[=true|false]                        Show result set boundaries, timing, and additional debugging information
      --embedder-query-format stringArray         Override one embedder's stored query format for this search: a JSON object with embedderId and at least one of instruction and queryTemplate, or @file.json (can be specified multiple times). An empty string means none for this search; \n in the JSON is a line break
      --fetch-content[=true|false]                Include original memory content in results
      --filter strings                            Metadata filter expression; repeat to target specific spaces or use @file.sql to load from a file
  -f, --format string                             Output format (stream, json, table) (default "stream")
  -h, --help[=true|false]                         help for retrieve
      --hnsw-ef-search uint32                     [advanced] Override HNSW ef_search for this request (1..1000)
      --hnsw-iterative-scan string                [advanced] Override HNSW iterative scan mode (off, relaxed-order, strict-order)
      --hnsw-max-scan-tuples uint32               [advanced] Override HNSW max_scan_tuples for this request (1..2147483647)
      --hnsw-scan-mem-multiplier float            [advanced] Override HNSW scan_mem_multiplier for this request (1..1000)
      --max-results int32                         Maximum number of results to retrieve (best effort with ANN + metadata filters; can return fewer if scan caps hit) (default 10)
      --no-abstract[=true|false]                  Skip generating abstractive replies
      --output-budget uint32                      Token budget for output generation
      --post-processor string                     Post-processor class name (Java FQN)
      --post-processor-args string                Post-processor arguments as JSON or @file.json
      --post-processor-interactive[=true|false]   Launch interactive TUI to configure ChatPostProcessorFactory
      --query-instruction string                  Task instruction for this search. Every embedder whose query template reads {{ instruction }} uses it in place of its stored instruction; other embedders ignore it. It does not reach a reranker
      --space-id strings                          Space IDs to search within (can be specified multiple times)

Options inherited from parent commands

      --api-key string   API key for authentication (can also be set via GOODMEM_API_KEY environment variable)
      --server string    GoodMem server URL (gRPC API; default ports: https=443, http=80)

SEE ALSO

On this page