Skip to content

Auto-render Slack ask_user questions as buttons when options are simple#187

Merged
LIU9293 merged 2 commits intomainfrom
feat/slack-ask-user-buttons-175989
Apr 18, 2026
Merged

Auto-render Slack ask_user questions as buttons when options are simple#187
LIU9293 merged 2 commits intomainfrom
feat/slack-ask-user-buttons-175989

Conversation

@LIU9293
Copy link
Copy Markdown
Contributor

@LIU9293 LIU9293 commented Apr 18, 2026

Summary

  • Moves the "send buttons vs plain text" decision out of the agent system prompt and into the Slack IM adapter — Ode now auto-renders interactive Slack buttons whenever a question's options qualify as "simple" (2-5 labels, each ≤ 15 chars, no newlines), and falls back to the existing Options: a / b / c plain text otherwise.
  • Both entry points share one renderer: the SDK-emitted question.asked event (Path B, previously always plain text) and the LLM-invoked /api/action ask_user (Path A, previously 2-5 options only, hard-errored otherwise). The action API no longer rejects >5 options; they just render as text.
  • Drops the Slack-specific ask_user/buttons guidance line from buildSystemPrompt — the LLM doesn't need to know about it anymore.

Changes

  • packages/core/runtime/helpers.ts — new hasSimpleOptions() heuristic.
  • packages/core/types.tsIMAdapter gains an optional sendQuestion(channelId, threadId, question, options, prefix?) hook.
  • packages/ims/slack/api.ts — extract postSlackQuestion() (blocks when simple, plain text otherwise); simplify ask_user case to reuse it.
  • packages/ims/slack/client.ts — Slack adapter implements sendQuestion via a lazy import of ./api to avoid circular deps.
  • packages/core/kernel/request-run.ts and pending-question.ts — prefer im.sendQuestion when available, fall back to existing sendMessage + formatSingleQuestionPrompt for other platforms.
  • packages/agents/shared.ts — remove the "use ask_user / buttons are enough" Slack system-prompt line.
  • Unit tests for hasSimpleOptions edge cases (len/newline/bounds) and for the multi-question follow-up using sendQuestion.

Testing

  • bun test packages/core packages/agents packages/ims → 211 pass, 0 fail.
  • Manual: posted ask_user with 3 short options to a live thread (rendered as buttons) and with a long-label option (fell back to plain text).

Discord and Lark adapters don't implement sendQuestion, so they keep the existing plain-text behavior unchanged.

Kai Liu added 2 commits April 18, 2026 14:01
Moves the "render buttons vs plain text" decision out of the system prompt
and into the Slack IM adapter. Ode now inspects each question's options and
posts an interactive actions block whenever they qualify as simple (2-5
labels, each <= 15 chars, no newlines), falling back to "Options: a / b / c"
text otherwise. Both the SDK-emitted question.asked flow and the LLM-invoked
ask_user action share the same renderer, so behavior is consistent.
@LIU9293 LIU9293 merged commit 8b4d96e into main Apr 18, 2026
2 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