Skip to content

feat(ai): harden agent tool schemas + error feedback + maxSteps (AGENT-4)#144

Merged
eliotlim merged 1 commit into
mainfrom
feat/agent-4-tool-hardening
Jul 13, 2026
Merged

feat(ai): harden agent tool schemas + error feedback + maxSteps (AGENT-4)#144
eliotlim merged 1 commit into
mainfrom
feat/agent-4-tool-hardening

Conversation

@eliotlim

Copy link
Copy Markdown
Owner

What

Hardening pass on the in-app agent loop + tool set. Board: AGENT-4 (Epic: Agent-first-class). Scoped to packages/server/src/ai/{agent.ts,effort.ts} + a new test — no packages/mcp or request-shape (providers.ts) changes.

Changes

Tool schema/description audit (~30 tools reviewed):

  • Bug fix: set_db_cell's "no such property" error pointed at list_db_views/get_db_row (neither surfaces column ids) → now points at describe_database (the real source). Description also states expected value shape (option id for select/status, boolean for checkbox, number for number) since it stores raw without label→id coercion.
  • Clarified append_to_page (plain paragraphs only) vs add_blocks (headings/lists/interactive/charts/layout) to remove the two-"append"-tools ambiguity.
  • Result-cap disclosure on search_notes/list_pages/read_page/describe_database so the model knows results may be partial + which follow-up tool to use.
  • ask_user steps array gets minItems:1, maxItems:8 matching the documented contract.

Error feedback (run loop runTool): a throwing tool already didn't abort; strengthened so the error names the failing tool + signals recoverability, and an empty/blank result is normalized to an explicit "no output" note (no ambiguous blank frames). Loop feeds the error as a tool_result and continues.

maxSteps per effort: 4/8/16 → 6/12/24. Dependent chains (create_database → describe → create_property ×N → create_row ×M) exceeded 10 turns for even a few rows and truncated mid-task; one tool/turn under the JSON protocol, and Opus 4.8 + adaptive thinking plans further per turn. Ceiling bounded at 24.

Flags (behavior notes)

  • maxSteps bump is user-visible: hard tasks may take more model turns before "ran out of steps" → higher worst-case cost/latency. Explicitly requested; bounded.
  • set_db_cell still doesn't coerce select/status labels→option ids like create_row/update_row — improved the description to steer toward option ids rather than changing apply behavior. Possible follow-up.

Tests / verify

New agentLoop.test.ts (7 tests): throwing-tool → clean named error fed back + run completes + no run-ending error event; ordering; empty-result normalization; unknown-tool recovery; set_db_cell pointer; maxSteps values. pnpm verify exit 0: sdk 188 / ui 981 / server 666, server e2e 251, mcp e2e 40.

Tool schema/description audit (agent.ts):
- set_db_cell: fix stale error pointer (list_db_views/get_db_row →
  describe_database, the real source of column ids) + spell out the
  expected value shape (option id for select/status, etc.).
- append_to_page: clarify it takes PLAIN paragraphs only; point rich/
  interactive content at add_blocks (removes overlap ambiguity).
- search_notes/list_pages/read_page/describe_database: disclose result
  caps + shape (top-5, first-40, truncation) so the model knows results
  may be partial and which follow-up tool to use.
- ask_user: add minItems/maxItems (1–8) to match the documented contract
  and buildInterviewSteps' cap.

Error feedback (run loop):
- A throwing tool now feeds a named, recoverable error tool_result and the
  run CONTINUES (was already caught; message strengthened + tool named).
- An empty/blank tool result is normalised to an explicit "no output" note
  so the model never sees an ambiguous blank frame.

maxSteps per effort (effort.ts): 4/8/16 → 6/12/24. Dependent tool chains
(create_database → describe → create_property ×N → create_row ×M) routinely
exceeded the old caps and truncated mid-task; Opus 4.8 + adaptive thinking
plans further per turn. Ceiling kept bounded (a step is a paid model turn).

Tests (agentLoop.test.ts): throwing-tool → error fed back + run continues;
empty-result normalisation; unknown-tool recovery; set_db_cell pointer;
maxSteps values.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app.book.pub Ready Ready Preview, Comment Jul 13, 2026 3:23am

Request Review

@eliotlim eliotlim merged commit a1df88a into main Jul 13, 2026
10 checks passed
@eliotlim eliotlim deleted the feat/agent-4-tool-hardening branch July 13, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant