Skip to content

build_context text output shows incoming relations without their source #1717

Closed

Description

@phernandez

Found during the v0.24.0 acceptance test.

build_context(..., output_format="text") lists every relation under the primary note's "### Relations" heading as - relation_type [[target]] without the source. An incoming relation such as Café note -relates_to-> Coffee Bean Origins shows under Coffee Bean Origins as - relates_to [[Coffee Bean Origins]], which reads as a self-link. Relations that belong to a depth-2 neighbor appear there too.

The JSON output has from_entity and to_entity and is correct. The text formatter is in src/basic_memory/mcp/tools/build_context.py. It should show the source for relations that don't originate from the primary note, or split them into outgoing and incoming.

Activity

  1. added this to the v0.24.x milestone on Oct 10, 2026
  2. claude commented on Oct 10, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 14s —— View job


    Triage

    • Type: bug (labeled bug)
    • Component: MCP tools (build_context text formatter). Not Cloud.
    • Priority: Medium. The output misleads, but there's no data loss, and the JSON output is correct.
    • Complexity: Simple.
    • Duplicates: A search of existing issues found none.

    Confirmed in code: src/basic_memory/mcp/tools/build_context.py:94-98 renders every RelationSummary as - {relation_type} [[{to_entity or to_name}]]. It never reads from_entity. An incoming relation therefore shows the primary note as its own target, and relations belonging to depth-2 neighbors are listed under the primary note as well.

    Suggested direction (not implemented): Either of the two options in the issue would work.

    • Split the list into outgoing and incoming, based on whether from_entity is the primary note.
    • Render the source for non-outgoing relations, e.g. - Café note relates_to [[Coffee Bean Origins]].

    The fix should come with a regression test covering an incoming relation and a depth-2 neighbor relation.

  3. added
    bug
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions