graphiti/graphiti_core/utils/maintenance
Daniel Chalef 4a307dbf10
Optimize edge deduplication prompt for caching and clarity (#970)
* Optimize edge deduplication prompt for caching and clarity

- Restructure prompt to place invariant instructions at top and dynamic context at bottom for better LLM caching
- Change 'id' to 'idx' in edge context lists to avoid confusion with other identifiers
- Remove 'fact_type_id' from edge types context as LLM only needs fact_type_name
- Remove dynamic range values from prompt instructions (e.g., "range 0-N")
- Add debug logging before LLM call to track input sizes
- Add validation logging after LLM response to catch invalid idx values
- Clarify that duplicate_facts uses EXISTING FACTS idx and contradicted_facts uses INVALIDATION CANDIDATES idx

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Address terminology consistency and edge case logging

- Update Pydantic field descriptions to use 'idx' instead of 'ids' for consistency
- Fix debug logging to handle empty list edge case (avoid 'idx 0--1' display)

Note on review feedback:
- Validation is intentionally non-redundant: warnings provide visibility, list comprehensions ensure robustness
- WARNING level is appropriate for LLM output issues (not system errors)
- Existing test coverage is sufficient for this defensive logging addition

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-02 17:07:43 -07:00
..
__init__.py Gemini support (#324) 2025-04-06 09:27:04 -07:00
community_operations.py Remove ensure_ascii configuration parameter (#969) 2025-10-02 15:10:57 -07:00
dedup_helpers.py Refactor batch deduplication logic to enhance node resolution and track duplicate pairs (#929) (#936) 2025-09-26 08:40:18 -07:00
edge_operations.py Optimize edge deduplication prompt for caching and clarity (#970) 2025-10-02 17:07:43 -07:00
graph_data_operations.py OpenSearch updates (#906) 2025-09-14 01:43:37 -04:00
node_operations.py Remove ensure_ascii configuration parameter (#969) 2025-10-02 15:10:57 -07:00
temporal_operations.py Remove ensure_ascii configuration parameter (#969) 2025-10-02 15:10:57 -07:00
utils.py chore: Fix packaging (#38) 2024-08-25 10:07:50 -07:00