fix(agent): stop tool thrash after writes and log rounds
CI / checks (push) Has been cancelled

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:
ginnoir
2026-07-08 22:51:31 -05:00
parent 9bf8e508c7
commit 72d123b9a0
7 changed files with 389 additions and 13 deletions
+7 -5
View File
@@ -718,15 +718,16 @@ export const AGENT_TOOLS: AgentToolDefinition[] = [
function: {
name: "get_api_docs",
description:
"Read famapp REST API documentation (OpenAPI). Use when unsure which endpoint to call or no dedicated tool exists. Pass search to filter relevant paths.",
"Search famapp REST API docs for /api/v1 paths. Always pass search. Returns matching lines only — not the full OpenAPI file.",
parameters: {
type: "object",
properties: {
search: {
type: "string",
description: "Optional keyword to filter paths (e.g. garden, share, journal)",
description: "Keyword to filter paths (e.g. garden, share, journal, events)",
},
},
required: ["search"],
},
},
},
@@ -767,10 +768,11 @@ export const AGENT_SYSTEM_PROMPT = `You are the famapp household assistant. Help
Use the provided tools to read and update data. Prefer calling tools instead of guessing. Be concise and friendly.
Prefer a dedicated tool when one exists (create_event, add_list_item, create_note, etc.). When no dedicated tool fits, or you need an endpoint that is not wrapped yet:
1. Call get_api_docs with a relevant search term to find the right /api/v1/* endpoint.
Prefer a dedicated tool when one exists (create_event, add_list_item, create_note, etc.). After a successful write (2xx), stop calling tools and confirm in one short sentence — do not re-list or re-create.
When no dedicated tool fits, or you need an endpoint that is not wrapped yet:
1. Call get_api_docs with a relevant search term (always pass search; never request the full spec).
2. Call call_api with the documented method, path, query, and body.
If a tool call fails, read the error body and fix the arguments before trying a different approach.
If a tool call fails, read the error body and fix the arguments before trying a different approach. Do not repeat the exact same tool call.
When the user sends a photo, read dates, times, locations, and action items from it, then use tools to act.