Skip to content

feat(slack): make Slack agent proactive about spawning workspaces#4660

Merged
saddlepaddle merged 1 commit into
mainfrom
slack-prompt-proactive
May 18, 2026
Merged

feat(slack): make Slack agent proactive about spawning workspaces#4660
saddlepaddle merged 1 commit into
mainfrom
slack-prompt-proactive

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 17, 2026

Summary

  • Reframe the Slack agent's SYSTEM_PROMPT opener — it described the bot as a task-management assistant, but it can also spawn workspaces and run coding agents.
  • Add that capability to the "You can" list and add one guideline so the bot defaults to action: for code-change requests, prefer spawning a workspace + agent over just filing a task.

Why / Context

For "can someone fix X" style messages the bot tended to file a task or ask questions rather than kick off the work, partly because the prompt only framed it around task tracking. This nudges it toward action while keeping it a general Slack assistant.

Testing

  • bunx biome check on the changed file — clean
  • No automated tests added (prompt-text-only change)

Notes

  • Only the static SYSTEM_PROMPT string changed; the dynamic context interpolation (org, channel, members, statuses, hosts) is untouched.
  • The prompt is shared across the v1 and v2 MCP feature-flag paths (FEATURE_FLAGS.SLACK_MCP_V2). Workspace/agent spawning is a v2 capability; on v1 the bot adapts to the tools it's given.

Summary by CodeRabbit

  • Improvements
    • Slack assistant prompt updated to focus on Superset-related tasks and tool usage.
    • Guidance restructured to emphasize using Superset tools, workspace spawning, and launching coding agents.
    • Assistant more proactive: when intent is clear (especially for code changes), it favors spawning a workspace/agent to take action.
    • Retains task creation, formatting, error handling, sourcing, and context-gathering behaviors.

Review Change Stack

@stage-review
Copy link
Copy Markdown

stage-review Bot commented May 17, 2026

Ready to review this PR? Stage has broken it down into 1 individual chapter for you:

Title
1 Update Slack agent prompt for proactive workspace spawning
Open in Stage

Chapters generated by Stage for commit c815024 on May 17, 2026 1:27am UTC.

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 17, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eb6fcd70-ff21-4906-963d-2b206dabf8d9

📥 Commits

Reviewing files that changed from the base of the PR and between 4b20af7 and c815024.

📒 Files selected for processing (1)
  • apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts

📝 Walkthrough

Walkthrough

This PR updates the Slack agent's SYSTEM_PROMPT to a Superset-focused assistant: it emphasizes using superset_* tools to spawn workspaces and launch coding agents, restructures capability bullets, and adds a preference to take action (spawn workspace/agent) for clear code-change intents.

Changes

Slack Agent Instruction Set

Layer / File(s) Summary
Slack agent instruction set
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts
SYSTEM_PROMPT rewritten to target Superset assistant behavior: explicit superset_* tool usage, workspace/agent spawning and launch guidance, channel history/web search context, and a new rule preferring action (spawn workspace/agent) for code-change requests while retaining task creation, formatting, error/sourcing, and context-gathering instructions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit reads the prompt at night,
It swaps plain tasks for Superset light,
“Spawn a workspace, launch an agent!” it sings,
Branches, hosts, and code-ready things,
Hop—deploy the change with tiny wings 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: making the Slack agent more proactive about spawning workspaces for code-change requests.
Description check ✅ Passed The description is comprehensive and follows the template structure with Summary, Why/Context, Testing, and Notes sections. All required information is provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slack-prompt-proactive

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR rewrites the static SYSTEM_PROMPT in the Slack agent to make the bot proactively spawn workspaces and launch coding agents for code-change requests, rather than filing a task or asking clarifying questions.

  • Bias toward action section added: the model is instructed to spawn a workspace + agent whenever intent is reasonably clear, reserving tasks for explicit "track for later" requests.
  • Spawning workspaces and agents section added: step-by-step guidance to call superset_projects_list, check superset_workspaces_list for duplicates, derive a kebab-case branch slug, match the user's online host, and spawn via superset_workspaces_create/superset_agents_run.

Confidence Score: 3/5

The change is prompt-only, but the new spawning guidance names v2-specific tools that don't exist on the v1 code path, and the bias-toward-action instruction amplifies the impact of that mismatch on every code-change request routed through v1.

The new sections hard-reference four tool names absent on the v1 MCP path; with the bias-toward-action instruction now in place, the model will actively try to spawn for any code-change request and on v1 will either error out or appear to comply without actually doing anything.

apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts — the v1/v2 tool-name mismatch in the new prompt sections warrants a second look before merging.

Important Files Changed

Filename Overview
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts Static SYSTEM_PROMPT extended with "Bias toward action" and "Spawning workspaces and agents" sections; the new sections reference v2-only tool names that are absent on the v1 MCP path, creating a behavioral mismatch, and the host-to-user name matching heuristic may reliably fall back to sandbox.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Slack mention received] --> B{v1 or v2 MCP path?}
    B -->|v2| C[Load tools incl. superset_projects_list]
    B -->|v1| D[Load legacy tools - NO spawn tools]
    C --> E[Apply SYSTEM_PROMPT with spawning guidance]
    D --> E
    E --> F{Code-change request?}
    F -->|Intent clear| G[Call superset_projects_list]
    F -->|Ambiguous| H[Ask clarifying question]
    F -->|Track for later| I[Create task only]
    G --> J[Call superset_workspaces_list]
    J -->|Exists| K[Mention existing workspace]
    J -->|None| L[Derive kebab-case branch slug]
    L --> M{User host online?}
    M -->|Matches| N[Use user host]
    M -->|No match| O[Fall back to sandbox]
    N --> P[superset_workspaces_create]
    O --> P
    P --> Q[Agent runs with claude preset]
    style D fill:#f99,stroke:#c00
Loading
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts:426-432
**V2-only tool names referenced on both code paths**

The prompt explicitly names `superset_projects_list`, `superset_workspaces_list`, `superset_workspaces_create`, and `superset_agents_run` — tools that only exist on the v2 MCP path. When the v1 path is active (`FEATURE_FLAGS.SLACK_MCP_V2` off), the Anthropic model sees these names in its system prompt but those tools are absent from its schema. Claude is likely to either attempt the named call (resulting in a tool-not-found error) or describe spawning a workspace without actually invoking any tool, confusing users who expected action. The "Bias toward action" section amplifies this risk because the model is now actively directed to spawn for any code-change request. Consider gating the new sections behind the feature flag, or replacing specific tool names with generic descriptions so the model can map them to whichever names its current tool list exposes.

### Issue 2 of 3
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts:431
**Host-to-user name matching may always fall through to `sandbox`**

The instruction "match the host name against the current user" assumes a host's `name` field (e.g. `"john-mbp"`) correlates with the current user's display name or email. In the v2 context block built by `fetchAgentContext`, hosts are listed as `${h.name} (id: ${h.id}, online: yes/no)` and the current user as `${currentUser.name ?? currentUser.email}` — two unrelated naming conventions. When a user's machine is named something like `"MacBook-Pro-2"` or a corporate asset tag, the fuzzy match will reliably fail and the agent will always fall back to `sandbox`. Consider surfacing ownership metadata to make the heuristic more reliable.

### Issue 3 of 3
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts:427
**Hardcoded `superset` slug is a silent failure risk**

The prompt hard-wires the string `superset` as the project slug for all Superset-related requests. If that project is ever renamed or its slug changes in the database, the bot will silently pass the wrong slug to `superset_workspaces_create` and the spawn will fail (or land in the wrong repo). A softer phrasing — e.g. "use the project whose slug or name best matches 'superset'" — would let the model recover by calling `superset_projects_list` and selecting the closest match at runtime.

Reviews (1): Last reviewed commit: "feat(slack): make Slack agent proactive ..." | Re-trigger Greptile

Comment on lines +426 to +432
- Before spawning, call superset_projects_list and pick the project that best matches the request. Match on repository name, project slug, and topic keywords drawn from the user's message and the thread/channel context.
- If the request concerns the Slack app, Superset features, the tasks or automations UI, or anything about Superset itself, use the Superset project (slug: \`superset\`).
- If several projects could plausibly match, pick the strongest candidate, state in one short sentence which you picked and why, and proceed — don't stall on the choice.
- Also call superset_workspaces_list and check for an existing active workspace on a relevant branch. superset_workspaces_create always creates a new workspace, so when a relevant one already exists, mention it to the user instead of silently duplicating it.
- Derive the branch name from the request as a short kebab-case slug (e.g. \`fix-slack-retry\`, \`add-csv-export\`).
- For the host, use the requesting user's own machine when it appears online in the Hosts list in your context (match the host name against the current user); otherwise fall back to the \`sandbox\` host.
- Spawn the agent as part of workspace creation when possible — superset_workspaces_create accepts an \`agents\` array — or call superset_agents_run against the workspace afterward. Use the \`claude\` agent preset unless the user asks for another. Give the agent a clear, self-contained prompt describing the change to make.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 V2-only tool names referenced on both code paths

The prompt explicitly names superset_projects_list, superset_workspaces_list, superset_workspaces_create, and superset_agents_run — tools that only exist on the v2 MCP path. When the v1 path is active (FEATURE_FLAGS.SLACK_MCP_V2 off), the Anthropic model sees these names in its system prompt but those tools are absent from its schema. Claude is likely to either attempt the named call (resulting in a tool-not-found error) or describe spawning a workspace without actually invoking any tool, confusing users who expected action. The "Bias toward action" section amplifies this risk because the model is now actively directed to spawn for any code-change request. Consider gating the new sections behind the feature flag, or replacing specific tool names with generic descriptions so the model can map them to whichever names its current tool list exposes.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts
Line: 426-432

Comment:
**V2-only tool names referenced on both code paths**

The prompt explicitly names `superset_projects_list`, `superset_workspaces_list`, `superset_workspaces_create`, and `superset_agents_run` — tools that only exist on the v2 MCP path. When the v1 path is active (`FEATURE_FLAGS.SLACK_MCP_V2` off), the Anthropic model sees these names in its system prompt but those tools are absent from its schema. Claude is likely to either attempt the named call (resulting in a tool-not-found error) or describe spawning a workspace without actually invoking any tool, confusing users who expected action. The "Bias toward action" section amplifies this risk because the model is now actively directed to spawn for any code-change request. Consider gating the new sections behind the feature flag, or replacing specific tool names with generic descriptions so the model can map them to whichever names its current tool list exposes.

How can I resolve this? If you propose a fix, please make it concise.

- If several projects could plausibly match, pick the strongest candidate, state in one short sentence which you picked and why, and proceed — don't stall on the choice.
- Also call superset_workspaces_list and check for an existing active workspace on a relevant branch. superset_workspaces_create always creates a new workspace, so when a relevant one already exists, mention it to the user instead of silently duplicating it.
- Derive the branch name from the request as a short kebab-case slug (e.g. \`fix-slack-retry\`, \`add-csv-export\`).
- For the host, use the requesting user's own machine when it appears online in the Hosts list in your context (match the host name against the current user); otherwise fall back to the \`sandbox\` host.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Host-to-user name matching may always fall through to sandbox

The instruction "match the host name against the current user" assumes a host's name field (e.g. "john-mbp") correlates with the current user's display name or email. In the v2 context block built by fetchAgentContext, hosts are listed as ${h.name} (id: ${h.id}, online: yes/no) and the current user as ${currentUser.name ?? currentUser.email} — two unrelated naming conventions. When a user's machine is named something like "MacBook-Pro-2" or a corporate asset tag, the fuzzy match will reliably fail and the agent will always fall back to sandbox. Consider surfacing ownership metadata to make the heuristic more reliable.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts
Line: 431

Comment:
**Host-to-user name matching may always fall through to `sandbox`**

The instruction "match the host name against the current user" assumes a host's `name` field (e.g. `"john-mbp"`) correlates with the current user's display name or email. In the v2 context block built by `fetchAgentContext`, hosts are listed as `${h.name} (id: ${h.id}, online: yes/no)` and the current user as `${currentUser.name ?? currentUser.email}` — two unrelated naming conventions. When a user's machine is named something like `"MacBook-Pro-2"` or a corporate asset tag, the fuzzy match will reliably fail and the agent will always fall back to `sandbox`. Consider surfacing ownership metadata to make the heuristic more reliable.

How can I resolve this? If you propose a fix, please make it concise.


Spawning workspaces and agents:
- Before spawning, call superset_projects_list and pick the project that best matches the request. Match on repository name, project slug, and topic keywords drawn from the user's message and the thread/channel context.
- If the request concerns the Slack app, Superset features, the tasks or automations UI, or anything about Superset itself, use the Superset project (slug: \`superset\`).
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Hardcoded superset slug is a silent failure risk

The prompt hard-wires the string superset as the project slug for all Superset-related requests. If that project is ever renamed or its slug changes in the database, the bot will silently pass the wrong slug to superset_workspaces_create and the spawn will fail (or land in the wrong repo). A softer phrasing — e.g. "use the project whose slug or name best matches 'superset'" — would let the model recover by calling superset_projects_list and selecting the closest match at runtime.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts
Line: 427

Comment:
**Hardcoded `superset` slug is a silent failure risk**

The prompt hard-wires the string `superset` as the project slug for all Superset-related requests. If that project is ever renamed or its slug changes in the database, the bot will silently pass the wrong slug to `superset_workspaces_create` and the spawn will fail (or land in the wrong repo). A softer phrasing — e.g. "use the project whose slug or name best matches 'superset'" — would let the model recover by calling `superset_projects_list` and selecting the closest match at runtime.

How can I resolve this? If you propose a fix, please make it concise.

The system prompt framed the bot as a task-tracking assistant and didn't
mention it can spawn workspaces and run coding agents. Reframe the opener,
add that capability to the list, and add one guideline to default to
action — preferring a workspace + agent over a task for code-change
requests, while still asking when the request is genuinely ambiguous.
@saddlepaddle saddlepaddle force-pushed the slack-prompt-proactive branch from 4b20af7 to c815024 Compare May 17, 2026 01:27
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 17, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle saddlepaddle merged commit dd1f517 into main May 18, 2026
15 of 16 checks passed
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