Skip to content
Merged
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
17 changes: 13 additions & 4 deletions bench/agents/code_graph_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,24 @@ def find_symbol(self, repo: str, name: str) -> list[dict[str, Any]]:

auto_complete returns prefix matches; the agent often wants exact
matches. Doing this client-side keeps the FastAPI surface untouched.

The auto_complete payload nests the symbol name under
`item["properties"]["name"]` (FalkorDB node properties), so we look
there first and only fall back to a top-level `name` for older /
flatter shapes the tests may pass in.
"""
payload = self.auto_complete(repo, name)
results = payload.get("completions") or payload.get("results") or payload
if isinstance(results, dict):
results = results.get("items", [])
return [
item for item in (results or [])
if isinstance(item, dict) and item.get("name") == name
]
out: list[dict[str, Any]] = []
for item in (results or []):
if not isinstance(item, dict):
continue
props = item.get("properties") if isinstance(item.get("properties"), dict) else {}
if props.get("name") == name or item.get("name") == name:
out.append(item)
return out

def note_edit(self, repo: str, path: str) -> dict[str, Any]:
"""Tell code-graph the agent just edited `path`; trigger an
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ bench = [
markers = [
"slow: marks tests that spawn external subprocesses (LSP servers, FalkorDB, etc.); skip with -m 'not slow'",
]
# Keep pytest from walking into per-instance bench worktrees that contain
# their own copies of pytest source — collecting from those breaks the
# host pytest's AST rewriter.
norecursedirs = ["bench/cache", ".venv", "node_modules", "build", "dist", "*.egg-info"]

[tool.setuptools.packages.find]
where = ["."]
20 changes: 20 additions & 0 deletions tests/test_bench_code_graph_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ def test_find_symbol_filters_for_exact_match():
assert all(item["name"] == "Foo" for item in out)


def test_find_symbol_reads_nested_properties_name():
# Regression: the real /api/auto_complete payload nests `name` under
# `properties` (FalkorDB node properties). Before this fix every
# exact-name lookup returned [], so the agent fell back to bash grep.
resp = httpx.Response(
200,
json={"completions": [
{"id": 1, "labels": ["Function"],
"properties": {"name": "FooBar", "path": "/a.py"}},
{"id": 2, "labels": ["Function"],
"properties": {"name": "Foo", "path": "/b.py"}},
{"id": 3, "labels": ["Function"],
"properties": {"name": "Foo", "path": "/c.py"}},
]},
)
with _client_with({"POST /api/auto_complete": resp}) as c:
out = c.find_symbol("r", "Foo")
assert [item["id"] for item in out] == [2, 3]


def test_note_edit_calls_analyze_folder_and_reports_path():
resp = httpx.Response(200, json={"status": "ok"})
with _client_with({"POST /api/analyze_folder": resp}) as c:
Expand Down