tinyhumansai/openhuman · error · anyhow::Error

memory_chunk_context: target chunk not found in source (sour

Error message

memory_chunk_context: target chunk not found in source (source may have >500 chunks)

What it means

The source listing succeeded (capped at 500 chunks) but the target chunk's seq_in_source was not found among the returned rows — the source has more than 500 chunks and the target falls outside the fetched window. A documented limitation of the neighbour-window algorithm.

Source

Thrown at src/openhuman/memory/tools/search/chunk_context.rs:128

        let source_query = ChunkQuery {
            source_kind: Some(source_kind),
            source_id: Some(source_id.clone()),
            limit: Some(500),
            ..Default::default()
        };
        let mut source_chunks = chunk_reader
            .list_chunks(&source_query, None)
            .await
            .map_err(|e| anyhow::anyhow!("memory_chunk_context: source query failed: {e}"))?;

        // Sort by seq_in_source (ascending) for natural reading order
        source_chunks.sort_by_key(|c| c.seq_in_source);

        // Find the target's position
        let target_pos = source_chunks
            .iter()
            .position(|c| c.id == parsed.chunk_id)
            .ok_or_else(|| anyhow::anyhow!(
                "memory_chunk_context: target chunk not found in source (source may have >500 chunks)"
            ))?;

        // Compute window bounds
        let start = target_pos.saturating_sub(window);
        let end = (target_pos + window + 1).min(source_chunks.len());
        let window_chunks = &source_chunks[start..end];

        let mut output = format!(
            "Source: {}:{} ({} total chunks)\n\
             Showing chunks {}-{} (target at position {}):\n\n",
            source_kind.as_str(),
            source_id,
            source_chunks.len(),
            start,
            end - 1,
            target_pos,
        );

View on GitHub (pinned to 7491200858)

Solutions

  1. Narrow the context request to a more recent chunk within the first 500 of the source
  2. Use a time-scoped search (cover_window) to re-locate the chunk
  3. Report the source as too large for chunk_context
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/openhuman/memory/tools/search/chunk_context.rs:128 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/d1b86412571c0298. Report an issue: GitHub.