ITADN

Agent-loop route + ls tool + wire panel to real backend

#1045Closedmattpocock 创建于 2026-06-18
M
mattpocockcommented
## Parent PRD #1041 ## What to build Deliver the first end-to-end slice: a working read-only agent in the course panel that can run `ls`. Add a streaming completions route under `/courses/:courseId/...` using the tool-loop agent with `@ai-sdk/anthropic`, returning a UI message stream. Implement the `ls(path)` tool over the VFS model: one entry per line, directories get a trailing `/`, ghost section/lesson dirs tagged with a trailing `[ghost]` (canonical path clean), bash-style errors returned (not thrown) so the model self-corrects in-loop. Wire the panel to the real backend: replace the mocked threads/messages with real `useChat`, drop the dev-only `?agentPanel` gate, pass the current `courseId` to the route and announce it as the anchor, bind each thread to its `{courseId → versionId}` pin, and surface the live "context window used" counter using the **last step's** `input_tokens` via `finish-step` message metadata (not the over-counting total). Thread switching/archiving and localStorage persistence from the prototype are retained. ## Acceptance criteria - [ ] A streaming agent route under `/courses/:courseId/...` runs the tool loop and streams UI messages - [ ] `ls(path)` lists VFS entries with trailing `/` for dirs and `[ghost]` tags; bad paths return bash-style errors - [ ] The panel uses real `useChat` (mock data removed) and the `?agentPanel` dev gate is gone - [ ] The route receives the current `courseId` as the anchor; threads carry and use a per-course version pin - [ ] The token counter reflects the last step's input_tokens via finish-step metadata and survives reload - [ ] Tests cover the `ls` tool behavior including ghost tags and error cases ## Depends on Sub-issue #1044 — VFS model: addressing + leaf generators + Zod schemas
关闭于 2026-06-18 1 条评论