Description
Refactor the dashboard playground server to use the @composio/core 0.9.1 SDK's full multi-turn session pattern (composio.create() / composio.use() / session.update()) and add a preload picker with bulk-select controls in Advanced Settings.
Server (/api/playground/route.ts, _utils.ts)
- Bumped
@composio/core and @composio/vercel ^0.6.3 → ^0.9.1.
- Initialises
new Composio({ apiKey, baseURL }) with the per-project playground API key.
resolveSession() returns a mode discriminant — create / reuse / update. Same configHash → reuse (composio.use() only). Config drifted with a cached tool-router session → update (composio.use() + session.update() in place). No cache → create (composio.create()). .use() / .update() failures fall back to .create().
updatePlaygroundConfigHash() compare-and-set helper persists the new configHash only if the cached meta still belongs to our playground session, avoiding parallel-POST races.
- Raw tool list comes from
composio.tools.getRawToolRouterSessionTools(); execution flows through session.execute(slug, args).
Session storage
Tool-router sessionId lives in Upstash Redis under REDIS_KEYS.playgroundSession(userId, orgNanoId, projectNanoId) inside PlaygroundSessionMeta.toolRouterSessionId (24 h TTL, refreshed on every chat turn). A page refresh keeps the same Redis row, so the next message in the same session reuses the existing tool-router session via composio.use() — we never call composio.create() just because the user reloaded the tab. Explicit "Reset Chat" clicks (or a 24 h idle window) are the only paths that drop the row and start a fresh .create().
Preload UI
SessionConfig gains preload: { tools?: string[] | "all" }.
- New
config/preload-config.tsx: a Switch for "Preload every filtered tool" (tools: "all"), a ComboboxSelect over toolkit-filtered tools with removable chips, and two new buttons:
- Select all materialises every toolkit-filtered tool slug as chips, capped at
PRELOAD_HARD_CAP = 100 (soft reminder at 20, destructive note at 100).
- Clear all removes every chip in one click.
- The old "Start new session?"
ConfigChangeDialog was removed entirely. session.update() carries config drift across turns without losing history, so the warning was misleading.
- Generated TS/Python snippets in the right rail include the new
preload field.
How did I test this PR
pnpm typecheck clean (tsgo --noEmit).
pnpm exec oxlint --config .oxlintrc.json over changed paths — 0 findings; full-tree lint matches origin/main baseline (5 errors, all pre-existing on main).
- E2E walkthrough in agent-browser against local Apollo (
localhost:9900):
- Selected the HackerNews toolkit, opened Advanced Settings.
- Select all → 14 HackerNews tool slugs rendered as chips. Clear all → chips removed, button correctly disables.
- Toggled the "Preload every filtered tool" switch on — no dialog popped up (old
ConfigChangeDialog removed); the switch just took effect.
- Sent first message "what are the top 3 stories on HN right now? just titles" → agent called
HACKERNEWS_GET_TOP_STORIES + 3× HACKERNEWS_GET_ITEM_WITH_ID and returned 3 titles.
- Toggled preload-all back on (config drift) → sent follow-up "now show the very first one in detail" → server hit the
mode: "update" path (composio.use() + session.update()) and the agent returned a detailed write-up — confirming session.update() works without losing history or recreating the tool-router session.
Demo video (signed URL — expires 1 h after upload; ping me to re-issue if it lapses):
preload-demo-v4-fixed.webm
Related
ComposioHQ/composio#3409 (merged) — fixed the May 8 changelog's stale @composio/core minimum (0.10.0 → 0.9.1) so this PR's version pin matches the documented requirement.