feat(ai): harden agent tool schemas + error feedback + maxSteps (AGENT-4)#144
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 — nopackages/mcpor request-shape (providers.ts) changes.Changes
Tool schema/description audit (~30 tools reviewed):
set_db_cell's "no such property" error pointed atlist_db_views/get_db_row(neither surfaces column ids) → now points atdescribe_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.append_to_page(plain paragraphs only) vsadd_blocks(headings/lists/interactive/charts/layout) to remove the two-"append"-tools ambiguity.search_notes/list_pages/read_page/describe_databaseso the model knows results may be partial + which follow-up tool to use.ask_usersteps array getsminItems:1, maxItems:8matching 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 atool_resultand 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)
set_db_cellstill 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_cellpointer; maxSteps values.pnpm verifyexit 0: sdk 188 / ui 981 / server 666, server e2e 251, mcp e2e 40.