Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions engine/antigravity_engine/tools/memory_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def search_memory_md(
return completed.stdout.strip()
if completed.returncode in (0, 1):
return "No matching memory lines found."
except FileNotFoundError:
# Fallback for environments without ripgrep installed.
except OSError:
# Fallback for environments where ripgrep is missing or cannot run.
pass

matches = []
Expand Down
24 changes: 24 additions & 0 deletions engine/tests/test_memory_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ def test_search_memory_md(tmp_path):
assert "microsandbox" in result.lower()


def test_search_memory_md_falls_back_when_rg_cannot_run(tmp_path, monkeypatch):
memory_file = tmp_path / "agent_memory.md"
memory_file.write_text(
"# Agent Memory Log\n\nMicrosandbox enabled.\nDocker removed.\n",
encoding="utf-8",
)

def raise_permission_error(*args, **kwargs):
raise PermissionError("rg is not executable")

monkeypatch.setattr(
"antigravity_engine.tools.memory_tools.subprocess.run",
raise_permission_error,
)

result = search_memory_md(
query="docker",
max_results=5,
memory_file=str(memory_file),
)

assert "Docker removed." in result


def test_search_memory_md_empty_query(tmp_path):
memory_file = tmp_path / "agent_memory.md"
memory_file.write_text("any", encoding="utf-8")
Expand Down