fix(agent): unambiguous document listing format for LLM parsing
Build and Push Containers / build-and-push-app (push) Successful in 1m34s
Build and Push Containers / build-and-push-db (push) Successful in 10s

This commit is contained in:
2026-09-01 12:44:53 -04:00
parent c738105932
commit 15a16a8fe0
5 changed files with 81 additions and 40 deletions
+11 -7
View File
@@ -26,7 +26,8 @@ task 04):
path (the kill switch).
2. Each tool call the model emits is executed server-side against
Postgres only (no LLM, no network): ``list_documents`` returns the
indexed catalog — one ``source/path — title`` line per document,
indexed catalog — one ``source: X | path: Y | title: Z`` line per
document (phase 63: labeled fields — unambiguous for LLM parsing),
``GET /api/docs`` order (uncapped in v1; the UI never shows it, only
the model does) — and ``read_document`` returns the document's **full**
content (A7-revised contract: never truncated).
@@ -85,7 +86,7 @@ AGENT_TOOLS: list[dict[str, Any]] = [
"name": "list_documents",
"description": (
"List every document indexed in the knowledge base, one "
"`source/path — title` line each"
"`source: X | path: Y | title: Z` line each"
),
"parameters": {"type": "object", "properties": {}, "required": []},
},
@@ -104,15 +105,17 @@ AGENT_TOOLS: list[dict[str, Any]] = [
"source": {
"type": "string",
"description": (
"The document's source (a directory basename, "
"e.g. 'Homelab')."
"The document's source, as shown after 'source: ' in the "
"list_documents output (e.g. 'Homelab' from "
"'source: Homelab | path: homelab/aws-route53.md')."
),
},
"path": {
"type": "string",
"description": (
"The document's path relative to its source "
"directory."
"The document's path, as shown after 'path: ' in the "
"list_documents output (e.g. 'homelab/aws-route53.md' from "
"'source: Homelab | path: homelab/aws-route53.md')."
),
},
},
@@ -186,7 +189,8 @@ def _execute_tool(
if call.name == "list_documents":
rows = list_catalog(db)
listing = f"{len(rows)} documents:\n" + "\n".join(
f"{source}/{path} — {title}" for source, path, title in rows
f"source: {source} | path: {path} | title: {title}"
for source, path, title in rows
)
holder.tool_calls += 1
return listing