Cap get_api_docs, break duplicate tool rounds, force a reply after successful writes, and log each tool call so limit hits are diagnosable.
This commit is contained in:
@@ -451,13 +451,18 @@ async function getApiDocs(args: Record<string, unknown>): Promise<ApiCallResult>
|
||||
const specPath = path.join(process.cwd(), "docs", "api", "openapi.yaml");
|
||||
const spec = await readFile(specPath, "utf8");
|
||||
const search = typeof args.search === "string" ? args.search.trim().toLowerCase() : "";
|
||||
const pathLines = spec
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line.startsWith("/api/v1/"));
|
||||
|
||||
if (!search) {
|
||||
return {
|
||||
status: 200,
|
||||
body: {
|
||||
spec,
|
||||
hint: "Pass search to filter paths, or use call_api with a /api/v1/* path.",
|
||||
paths: pathLines.slice(0, 80),
|
||||
pathCount: pathLines.length,
|
||||
hint: "Pass search (e.g. calendar, events, lists) to get matching lines. Do not request the full OpenAPI dump.",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -469,8 +474,8 @@ async function getApiDocs(args: Record<string, unknown>): Promise<ApiCallResult>
|
||||
body: {
|
||||
search,
|
||||
matchCount: matches.length,
|
||||
matches: matches.slice(0, 100),
|
||||
hint: "Use call_api with method and path from the matches above.",
|
||||
matches: matches.slice(0, 40),
|
||||
hint: "Use a dedicated tool when one exists; otherwise call_api with method and path from the matches above.",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user