Skip to content

Refactor site assistant around AI SDK agent loop - #72

Merged
naaiyy merged 2 commits into
mainfrom
agent/refactor-site-assistant-agent
Aug 15, 2026
Merged

Refactor site assistant around AI SDK agent loop#72
naaiyy merged 2 commits into
mainfrom
agent/refactor-site-assistant-agent

Conversation

@naaiyy

@naaiyy naaiyy commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • replace the hand-written generateText continuation loop with AI SDK 7 ToolLoopAgent
  • keep the complete tool loop inside one Convex action and return only terminal text to Workflow
  • serialize OpenEditor page documents at tool boundaries so Convex never journals deeply nested documents
  • serialize durable tool and generation checkpoints, and propagate persistence or cancellation failures before the next model request
  • remove the artificial completion tool and model-message continuation plumbing

Root cause

The previous workflow returned the AI SDK continuation, including nested page tool outputs, from every generation action. Convex Workflow attempted to persist that result and rejected it at nesting depth 18 because Convex values allow at most 16 levels. The action had already completed, so the workflow step remained in progress and the UI continued showing a running agent.

Impact

The assistant now uses the AI SDK's official bounded tool loop. Convex Workflow persists only { text }, while page documents remain JSON strings inside the action. Cancellation and observability writes are checked before each provider request.

Verification

  • bun run lint
  • bun run check-types
  • bun test — 246 passing
  • bun run build
  • strict-schema Convex development deployment
  • live workflow run with one manifest tool call and seven concurrent page reads; three model steps completed and the persisted action result contained only terminal text

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
base-blocks Ready Ready Preview Aug 15, 2026 12:27am

Request Review

@naaiyy
naaiyy merged commit 89cbe15 into main Aug 15, 2026
9 checks passed
@naaiyy
naaiyy deleted the agent/refactor-site-assistant-agent branch August 15, 2026 00:29
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