Skip to content

fix(knowledge): validate UUIDs in parse_causal_links (fixes #474)#478

Open
mickume wants to merge 1 commit intodevelopfrom
fix/issue-474-causal-link-malformed-uuids
Open

fix(knowledge): validate UUIDs in parse_causal_links (fixes #474)#478
mickume wants to merge 1 commit intodevelopfrom
fix/issue-474-causal-link-malformed-uuids

Conversation

@mickume
Copy link
Copy Markdown
Contributor

@mickume mickume commented Apr 17, 2026

Summary

  • Added _is_valid_uuid() helper and UUID format validation in parse_causal_links() to filter out malformed IDs (truncated UUIDs, git SHAs, arbitrary strings) before they reach the DuckDB layer
  • Updated all existing causal link tests to use valid UUID strings; added 6 regression tests for malformed UUID filtering

Closes #474

Changes

File Change
agent_fox/knowledge/extraction.py Added _is_valid_uuid() helper; added UUID validation with warning log in parse_causal_links()
tests/unit/knowledge/test_extraction_causal.py Updated test IDs to valid UUIDs; added TestParseCausalLinksUUIDValidation class with 6 tests

Tests

  • TestParseCausalLinksUUIDValidation: covers truncated UUIDs, git SHAs, valid UUIDs, mixed batches, plain strings, empty strings

Verification

  • All existing tests pass: ✅ (4991 passed)
  • New tests pass: ✅
  • Linter / formatter: ✅
  • No regressions: ✅

Auto-generated by af-fix.

The LLM sometimes returns truncated UUIDs or git SHAs instead of valid
fact UUIDs. These malformed IDs caused DuckDB ConversionException when
cast to UUID in store_causal_links, silently dropping all causal links
for the session. Add uuid.UUID() validation in parse_causal_links to
filter out invalid IDs at the parser layer with a warning log.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant