Skip to content

Comments

Slack: Use Cloud Agent Next infra#500

Merged
RSO merged 3 commits intomainfrom
slack-cloud-agent-next
Feb 25, 2026
Merged

Slack: Use Cloud Agent Next infra#500
RSO merged 3 commits intomainfrom
slack-cloud-agent-next

Conversation

@RSO
Copy link
Contributor

@RSO RSO commented Feb 24, 2026

This PR introduces a newly made up runSessionToCompletion helper that mimicks the behavior from the pre-websocket interface of Cloud Agents.

In the long run I'd like to move to the callbackUrl flow to prevent timeouts, but that seemed like a bigger change, and I wished to get this in quickly.

I've tested locally to confirm that the View Session button still works and that Cloud Agents are spawned as expected.

This PR introduces a newly made up `runSessionToCompletion` helper that mimicks the behavior from the pre-websocket interface of Cloud Agents.

In the long run I'd like to move to the callbackUrl flow to prevent timeouts, but that seemed like a bigger change, and I wished to get this in quickly.

I've tested locally to confirm that the `View Session` button still works and that Cloud Agents are spawned as expected.
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 24, 2026

Code Review Summary

Status: No New Issues Found | Recommendation: Address existing comments before merge

Overview

This PR migrates the Slack bot from the old cloud-agent streaming API to the new cloud-agent-next WebSocket-based API. The refactoring is clean and well-structured:

  • New runSessionToCompletion helper (run-session.ts) encapsulates the full session lifecycle (prepare → initiate → sign ticket → connect WebSocket → stream → result), making it reusable for other headless consumers.
  • slack-bot.ts is significantly simplified by delegating to the shared helper.
  • auth.ts now returns userId alongside authToken (needed for stream ticket signing) and converts the throw to a returned error object.
  • route.ts updates the DB query from cliSessions to cli_sessions_v2.

Existing inline comments from prior reviewers cover the notable issues (multiple as casts on event.data, behavior change in auth error handling). No additional issues found.

Files Reviewed (4 files)
  • src/app/slack/webhook/route.ts - 0 new issues (table rename)
  • src/lib/cloud-agent-next/run-session.ts - 0 new issues (covered by existing comments)
  • src/lib/slack-bot.ts - 0 new issues
  • src/lib/slack/auth.ts - 0 new issues (covered by existing comments)

onMessageCompleted: (_sid, _mid, message) => {
if (message.info.role !== 'assistant') return;
const text = extractTextFromMessage(message);
if (text) completionResult = text;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this logic. Will this work with partial results etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, but I assumed that onMessageCompleted is only called when the message is finalized, and that this line makes sure that we store the last message as the completion result.

@RSO RSO merged commit 35cab06 into main Feb 25, 2026
12 checks passed
@RSO RSO deleted the slack-cloud-agent-next branch February 25, 2026 08:28
RSO added a commit that referenced this pull request Feb 25, 2026
Reverts #500

The Cloud Agent can currently not run on the `kilocode` repository, so
I'm reverting this PR until we've fixed that.
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.

3 participants