Revert "fix(agents): reuse Tembo sessions for follow-up changes (#345)" - #356
Revert "fix(agents): reuse Tembo sessions for follow-up changes (#345)"#356ryw wants to merge 1 commit into
Conversation
This reverts commit 4b7c00b.
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { dispatchTemboTask, validateTemboApiKey } from "@/lib/cap-api"; | ||
| import { validateTemboApiKey } from "./cap-api"; |
There was a problem hiding this comment.
This drops the last test that proves createTemboTask posts to /public-api/session/create with the expected payload, but that helper is still the shared path for new-agent, chat-edit, run-improve, and API requests. Can we keep a small create-path test here so future endpoint/payload regressions are caught without reintroducing the deleted resume behavior?
There was a problem hiding this comment.
Pull request overview
This PR reverts the prior change that attempted to reuse Tembo CAP sessions for follow-up agent edits, restoring the earlier behavior of creating a fresh CAP session per change to avoid unauthorized requests against non-public endpoints.
Changes:
- Remove CAP “resume existing session” plumbing (DB lookup +
/session/:id/messagedispatch) and always create tasks via/public-api/session/create. - Update agent-change request flows (chat, run improvements, API v1) to call
createTemboTaskdirectly. - Revert documentation/changelog text that described session reuse, and update the generated in-app docs bundle accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/lib/improvements-api.ts | Removes DB helper used to find the latest CAP task for session reuse. |
| web/src/lib/cap-api.ts | Drops resume/dispatch logic and keeps a single “create task” CAP client path. |
| web/src/lib/api-v1/actions.ts | Removes session reuse lookup and switches task dispatch to createTemboTask. |
| web/src/app/[workspace]/agents/[agent]/chat/actions.ts | Removes reuse lookup and always creates a new CAP task for chat-to-edit. |
| web/src/app/[workspace]/agents/[agent]/runs/[runId]/actions.ts | Removes reuse lookup and always creates a new CAP task for run improvements. |
| web/src/lib/cap-api.test.ts | Removes dispatch/resume tests; retains validation coverage for API key checks. |
| docs/src/content/docs/agent-lifecycle.md | Removes documentation describing follow-up edits reusing Tembo sessions. |
| docs/src/content/docs/changelog.md | Removes changelog entry describing session reuse as a fixed behavior. |
| web/src/lib/docs-content.ts | Regenerates the in-app docs bundle to match the updated markdown docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Reverts #345. Fixes #351.
#345 sends follow-up agent changes to
POST /session/:id/messageon CAP. That endpoint is in the dashboard auth realm (user JWTs) and rejects API keys outright ("Unauthorized - Invalid token"), and no message endpoint exists under/public-apiat all — the public session router exposes onlycreate/list/search(verified against tembo/monorepoapps/api/src/server/routes/public-api/task.ts). So every follow-up change on an agent with an existing session 401s, for every user and every key.TAS maps CAP 401/403 to "Tembo rejected the API key (it may have been rotated or revoked)", which misdiagnosed the problem in #351 and sent the reporter rotating keys.
Reverting restores the pre-#345 behavior (a new CAP session per change), which works. Session reuse can come back once CAP exposes a public-API message endpoint — tracked as TEM-8013; re-land #345 on top of it then.
🤖 Generated with Claude Code