Skip to content

feat(gateway/feishu): interactive clarify card#26332

Open
Restry wants to merge 1 commit into
NousResearch:mainfrom
Restry:feishu-clarify-card
Open

feat(gateway/feishu): interactive clarify card#26332
Restry wants to merge 1 commit into
NousResearch:mainfrom
Restry:feishu-clarify-card

Conversation

@Restry

@Restry Restry commented May 15, 2026

Copy link
Copy Markdown

Adds Feishu support for the existing clarify primitive — agents can ask the user a question and render up to 4 tappable buttons (plus an ✏️ Other fallback) instead of forcing a typed reply. Mirrors the existing Telegram/Discord implementation; reuses tools/clarify_gateway.py end-to-end.

What

  • send_clarify(...) builds an interactive card with one button per choice. Picking a choice resolves the clarify; picking Other flips the card into text-capture mode so the next message becomes the response. Open-ended (no choices) renders as plain markdown and the existing text-intercept handles it.
  • _handle_clarify_card_action(...) authorizes the operator (_is_interactive_operator_authorized), looks up the question via tools.clarify_gateway._entries, and replaces the card with a resolved/awaiting variant.
  • _resolve_clarify(...) schedules the unblock first and only then drops state, so a missing event loop leaves the entry recoverable on retry.
  • _escape_lark_markdown(...) sanitizes **, _, [, ], ` in user-controlled question / choice / user_name fields before interpolation into Lark markdown.

Why

Feishu was the only major adapter without send_clarify, so any clarify call from an agent fell back to the plain-text path even though Feishu cards render great. CARD-ONLY workflows now stay structured all the way through.

Notes

  • New button namespace hermes_clarify_action (avoids collision with the existing hermes_action approval namespace).
  • Single-file change: gateway/platforms/feishu.py (+236 lines).
  • No new deps. No schema or contract changes to clarify_gateway.

Test plan

Manual on a live Feishu deploy:

  • ✅ Multi-choice card renders with numbered buttons.
  • ✅ Click resolves agent + replaces card with green confirmation.
  • Other flips to awaiting card; next typed message resolves.
  • ✅ Open-ended (no choices) renders question and the typed-text path resolves.
  • ✅ Question containing **, _, [ ], ` renders intact (escape verified).
  • ✅ Unauthorized operator click is rejected silently.

Mirror the Telegram clarify-card pattern for Feishu so agents can ask
questions via tappable buttons instead of forcing the user to type.

- send_clarify renders one button per choice (max 4) plus an Other
  fallback that flips the card into text-capture mode
- _handle_clarify_card_action authorizes the operator, looks up the
  question text via tools.clarify_gateway, and replaces the card with
  a resolved/awaiting variant
- _resolve_clarify schedules unblock first and only then drops state,
  so a missing event loop leaves the entry recoverable
- _escape_lark_markdown sanitizes user-controlled question/choice/user
  fields before they hit Lark markdown
NishantEC

This comment was marked as outdated.

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter P2 Medium — degraded but workaround exists labels May 15, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competes with #11981 (Feishu interactive clarify card) and overlaps with #23740 (clarify bridge to messaging platforms, includes Feishu). Also related to #9613 (Feishu Card V2 forms upgrade).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants