Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(memory): preserve short identifiers in semantic links

Lanre Shittuace50728106f
diff --git a/agent/src/memory/semantic_links.py b/agent/src/memory/semantic_links.py
index 128672897..f5b9066ac 100644
--- a/agent/src/memory/semantic_links.py
+++ b/agent/src/memory/semantic_links.py
@@ -49,7 +49,7 @@ _NON_LATIN_SCRIPT_RANGES = (
"א-ת" # Hebrew letters
"Ѐ-ӿ" # Cyrillic
)
-_TOKEN_RE = re.compile(rf"[a-zA-Z0-9]{{3,}}|[{_NON_LATIN_SCRIPT_RANGES}]")
+_TOKEN_RE = re.compile(rf"[a-zA-Z0-9]{{2,}}|[{_NON_LATIN_SCRIPT_RANGES}]")
# Relations file schema version
_RELATIONS_VERSION = 1
diff --git a/agent/tests/memory/test_semantic_links.py b/agent/tests/memory/test_semantic_links.py
index bfd6593b8..35b2b8c69 100644
--- a/agent/tests/memory/test_semantic_links.py
+++ b/agent/tests/memory/test_semantic_links.py
@@ -30,6 +30,20 @@ def _make_tokens(text: str) -> list[str]:
class TestDiscoverLinks:
+ def test_discover_links_keeps_short_financial_identifiers(self, tmp_path: Path) -> None:
+ """Two-character tickers and ratios can establish a memory link."""
+ linker = SemanticLinker(tmp_path)
+ source_tokens = _make_tokens("GE EV valuation notes")
+ all_entries = [
+ ("source.md", source_tokens),
+ ("related.md", _make_tokens("GE EV earnings analysis")),
+ ("unrelated.md", _make_tokens("weather forecast temperature rain")),
+ ]
+
+ links = linker.discover_links("source.md", source_tokens, all_entries)
+
+ assert "related.md" in [target for target, _score in links]
+
def test_discover_links_finds_similar(self, tmp_path: Path) -> None:
"""Entries with overlapping content get linked."""
linker = SemanticLinker(tmp_path)