-
Notifications
You must be signed in to change notification settings - Fork 0
MCP Bug Fixes #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ap_mcp_neptune_support
Are you sure you want to change the base?
Changes from 22 commits
4a97758
01d2116
6f17ed5
587027e
7a99052
d085e31
77a3ff9
e8ee4e7
786e015
8378cb9
b46554f
49a292f
037da15
8d94113
15cbe70
640bc3b
aa5e95c
b444eb2
92ab096
2b26e7e
4515979
d7acac3
465fc30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,10 @@ def get_episode_node_save_bulk_query(provider: GraphProvider) -> str: | |
| e.group_id AS group_id, | ||
| e.source_description AS source_description, | ||
| e.source AS source, | ||
| split(e.entity_edges, "|") AS entity_edges | ||
| CASE WHEN e.entity_edges IS NULL OR e.entity_edges = '' | ||
| THEN [] | ||
| ELSE split(e.entity_edges, "|") | ||
| END AS entity_edges | ||
| """ | ||
|
|
||
|
|
||
|
|
@@ -157,8 +160,11 @@ def get_entity_node_save_query(provider: GraphProvider, labels: str, has_aoss: b | |
| return f""" | ||
| MERGE (n:Entity {{uuid: $entity_data.uuid}}) | ||
| {label_subquery} | ||
| SET n = removeKeyFromMap(removeKeyFromMap($entity_data, "labels"), "name_embedding") | ||
| SET n.name_embedding = join([x IN coalesce($entity_data.name_embedding, []) | toString(x) ], ",") | ||
| SET n.name = $entity_data.name, | ||
| n.group_id = $entity_data.group_id, | ||
| n.created_at = $entity_data.created_at, | ||
| n.summary = $entity_data.summary, | ||
| n.name_embedding = join([x IN coalesce($entity_data.name_embedding, []) | toString(x) ], ",") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neptune entity nodes lose custom attributes on saveHigh Severity The Neptune query now explicitly sets only Additional Locations (1)There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neptune save queries silently drop entity/edge attributesHigh Severity The Neptune save queries were changed from Additional Locations (2) |
||
| RETURN n.uuid AS uuid | ||
| """ | ||
| case _: | ||
|
|
@@ -214,8 +220,11 @@ def get_entity_node_save_bulk_query( | |
| UNWIND $nodes AS node | ||
| MERGE (n:Entity {{uuid: node.uuid}}) | ||
| {labels} | ||
| SET n = removeKeyFromMap(removeKeyFromMap(node, "labels"), "name_embedding") | ||
| SET n.name_embedding = join([x IN coalesce(node.name_embedding, []) | toString(x) ], ",") | ||
| SET n.name = node.name, | ||
| n.group_id = node.group_id, | ||
| n.created_at = node.created_at, | ||
| n.summary = node.summary, | ||
| n.name_embedding = join([x IN coalesce(node.name_embedding, []) | toString(x) ], ",") | ||
| RETURN n.uuid AS uuid | ||
| """ | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,12 @@ class Versions(TypedDict): | |
|
|
||
|
|
||
| def resolve_edge(context: dict[str, Any]) -> list[Message]: | ||
| existing_facts_count = len(context.get('existing_edges', [])) | ||
| invalidation_candidates_count = len(context.get('edge_invalidation_candidates', [])) | ||
|
|
||
| existing_range = f'0 to {existing_facts_count - 1}' if existing_facts_count > 0 else 'none (empty list)' | ||
| invalidation_range = f'0 to {invalidation_candidates_count - 1}' if invalidation_candidates_count > 0 else 'none (empty list)' | ||
|
|
||
| return [ | ||
| Message( | ||
| role='system', | ||
|
|
@@ -50,16 +56,28 @@ def resolve_edge(context: dict[str, Any]) -> list[Message]: | |
| Message( | ||
| role='user', | ||
| content=f""" | ||
| You will analyze a NEW FACT against two separate lists of existing facts. | ||
|
|
||
| Task: | ||
| You will receive TWO lists of facts with CONTINUOUS idx numbering across both lists. | ||
| EXISTING FACTS are indexed first, followed by FACT INVALIDATION CANDIDATES. | ||
|
|
||
|
|
||
| ═══════════════════════════════════════════════════════════════ | ||
| LIST A: EXISTING FACTS (for duplicate detection) | ||
| ═══════════════════════════════════════════════════════════════ | ||
| Count: {existing_facts_count} facts | ||
| Valid idx range: {existing_range} | ||
|
|
||
| 1. DUPLICATE DETECTION: | ||
| - If the NEW FACT represents identical factual information as any fact in EXISTING FACTS, return those idx values in duplicate_facts. | ||
| - Facts with similar information that contain key differences should NOT be marked as duplicates. | ||
| - If no duplicates, return an empty list for duplicate_facts. | ||
|
|
||
| 2. CONTRADICTION DETECTION: | ||
| 2. FACT TYPE CLASSIFICATION: | ||
| - Given the predefined FACT TYPES, determine if the NEW FACT should be classified as one of these types. | ||
| - Return the fact type as fact_type or DEFAULT if NEW FACT is not one of the FACT TYPES. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Response model missing required
|
||
|
|
||
| 3. CONTRADICTION DETECTION: | ||
| - Determine which facts the NEW FACT contradicts from either list. | ||
| - A fact from EXISTING FACTS can be both a duplicate AND contradicted (e.g., semantically the same but the new fact updates/supersedes it). | ||
| - Return all contradicted idx values in contradicted_facts. | ||
|
|
@@ -74,17 +92,63 @@ def resolve_edge(context: dict[str, Any]) -> list[Message]: | |
| 1. Some facts may be very similar but will have key differences, particularly around numeric values. | ||
| Do not mark these as duplicates. | ||
|
|
||
| <FACT TYPES> | ||
| {context['edge_types']} | ||
| </FACT TYPES> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
|
||
|
|
||
| <EXISTING FACTS> | ||
| {context['existing_edges']} | ||
| </EXISTING FACTS> | ||
|
|
||
| <FACT INVALIDATION CANDIDATES> | ||
| ═══════════════════════════════════════════════════════════════ | ||
| LIST B: FACT INVALIDATION CANDIDATES (for contradiction detection) | ||
| ═══════════════════════════════════════════════════════════════ | ||
| Count: {invalidation_candidates_count} facts | ||
| Valid idx range: {invalidation_range} | ||
|
|
||
| {context['edge_invalidation_candidates']} | ||
| </FACT INVALIDATION CANDIDATES> | ||
|
|
||
| <NEW FACT> | ||
| ═══════════════════════════════════════════════════════════════ | ||
| NEW FACT TO ANALYZE | ||
| ═══════════════════════════════════════════════════════════════ | ||
| {context['new_edge']} | ||
| </NEW FACT> | ||
|
|
||
| ═══════════════════════════════════════════════════════════════ | ||
| FACT TYPES FOR CLASSIFICATION | ||
| ═══════════════════════════════════════════════════════════════ | ||
| {context['edge_types']} | ||
|
|
||
| ═══════════════════════════════════════════════════════════════ | ||
| YOUR RESPONSE MUST INCLUDE THREE FIELDS | ||
| ═══════════════════════════════════════════════════════════════ | ||
|
|
||
| 1. duplicate_facts (list of integers) | ||
| SOURCE: Use idx values ONLY from LIST A (EXISTING FACTS) | ||
| VALID RANGE: {existing_range} | ||
| PURPOSE: Identify which facts in LIST A are duplicates of the NEW FACT | ||
| CRITERIA: Facts must represent identical factual information (minor wording differences OK) | ||
| NOTE: Facts with key differences (especially numeric values) are NOT duplicates | ||
| IF NO DUPLICATES: Return empty list [] | ||
|
|
||
| 2. contradicted_facts (list of integers) | ||
| SOURCE: Use idx values ONLY from LIST B (FACT INVALIDATION CANDIDATES) | ||
| VALID RANGE: {invalidation_range} | ||
| PURPOSE: Identify which facts in LIST B are contradicted by the NEW FACT | ||
| CRITERIA: Facts that are logically incompatible with the NEW FACT | ||
| IF NO CONTRADICTIONS: Return empty list [] | ||
|
|
||
| 3. fact_type (string) | ||
| SOURCE: Choose from FACT TYPES listed above | ||
| PURPOSE: Classify the NEW FACT's type | ||
| DEFAULT: Return 'DEFAULT' if NEW FACT doesn't match any predefined FACT TYPES | ||
|
|
||
| ═══════════════════════════════════════════════════════════════ | ||
| CRITICAL WARNINGS | ||
| ═══════════════════════════════════════════════════════════════ | ||
| - LIST A and LIST B are COMPLETELY SEPARATE with INDEPENDENT indexing | ||
| - Do NOT use idx values from LIST B in duplicate_facts field | ||
| - Do NOT use idx values from LIST A in contradicted_facts field | ||
| - Each list starts indexing from 0 independently | ||
| - Verify your idx values are within the valid ranges specified above | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prompt contradicts data indexing and consuming codeHigh Severity The new prompt has contradictory indexing instructions. The data passed uses continuous idx numbering (invalidation candidates start where existing facts end), and the consuming code in |
||
| """, | ||
| ), | ||
| ] | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neptune queries silently drop custom attributes during save
High Severity
The new Neptune queries use explicit property lists instead of the previous
SET e = removeKeyFromMap(...)pattern, but this omits custom attributes. BothEntityEdgeandEntityNodehave anattributes: dict[str, Any]field. Thesave()methods spread these attributes into the data dictionary viaedge_data.update(self.attributes or {}). The old approach copied all properties including these spread attributes. The new explicit lists only include built-in fields, causing any custom attributes to be silently dropped on save. The same issue affects both edge queries and node queries for Neptune.Additional Locations (1)
graphiti_core/models/nodes/node_db_queries.py#L162-L167