feat(ai-chat): raise step limit to 20 and force a final answer #4
Closed
Ghost
wants to merge 1 commits from
feat/ai-chat-step-limit-and-forced-final-answer into develop
pull from: feat/ai-chat-step-limit-and-forced-final-answer
merge into: vvzvlad:develop
vvzvlad:main
vvzvlad:fix/embeddings-reindex-progress
vvzvlad:feat/git-sync
vvzvlad:feature/offline-sync
vvzvlad:feat/184-autonomous-agent-runs
vvzvlad:refactor/193-tool-spec-registry
vvzvlad:test/244-part-b
vvzvlad:fix/255-ws-redis-adapter-leak
vvzvlad:feat/251-intentional-clear
vvzvlad:fix/252-e2e-open-handles
vvzvlad:feat/221-image-captions
vvzvlad:fix/244-dataloss-bugs
vvzvlad:develop
vvzvlad:feat/229-catalog-yaml
vvzvlad:feat/243-blob-sandbox
vvzvlad:feat/228-inline-footnotes
vvzvlad:fix/qa-ui-bugs-216-218
vvzvlad:feature/agent-roles-catalog
vvzvlad:fix/share-alias-rename
vvzvlad:fix/ai-chat-empty-render
vvzvlad:feat/191-chat-doc-binding
vvzvlad:feat/201-temporary-notes
vvzvlad:feat/198-interrupt-agent
vvzvlad:feat/ai-chat-full-history
vvzvlad:feat/199-ai-generate-title
vvzvlad:feat/205-share-aliases
vvzvlad:batch/issues-189-187-170
vvzvlad:feat/170-mcp-test-button
vvzvlad:feat/189-context-badge
vvzvlad:feat/198-interrupt-agent-send-now
vvzvlad:fix/issues-190-159
vvzvlad:fix/ai-chat-new-chat-during-stream
vvzvlad:fix/ai-chat-stream-perf
vvzvlad:batch/issues-2026-06-25
vvzvlad:feat/ai-chat-persistent-history
vvzvlad:fix/ai-chat-copy-chat-wysiwyg
vvzvlad:fix/ai-stream-reset-resilience
vvzvlad:fix/ai-stream-undici-timeout
vvzvlad:fix/footnote-review-1227-followup
vvzvlad:fix/ai-chat-token-counter-realtime
vvzvlad:docs/manual-qa-test-plan
1 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3ca4bcf80b |
feat(ai-chat): raise step limit to 20 and force a final answer
The agent's per-turn step ceiling was 8. On research-heavy questions the model spent all 8 steps on tool calls and the turn ended with empty text - the user saw no answer and had to nudge with '?'. Two fixes: - Raise stopWhen from stepCountIs(8) to stepCountIs(MAX_AGENT_STEPS = 20). - On the LAST allowed step (stepNumber 19), forbid further tool calls (toolChoice: 'none') and append a synthesis instruction to the system prompt, so the model is forced to write the best answer it can from what it already gathered. prepareStep returns undefined for every earlier step, so natural early termination and the maxOutputTokens comment are untouched. The base system prompt is CONCATENATED with the instruction (a bare override would lose the persona/context). Logic extracted into a pure, exported prepareAgentStep(stepNumber, system) helper for unit testing. NOTE for future bumps: at AI SDK v7 the per-step 'system' field is renamed to 'instructions'; on v6 (`^6.0.134`) 'system' is correct. |