Skip to content

feat(feishu): upgrade askQuestion to interactive Card V2 forms#9613

Open
Damue01 wants to merge 1 commit into
NousResearch:mainfrom
Damue01:feat/feishu-ask-card-form
Open

feat(feishu): upgrade askQuestion to interactive Card V2 forms#9613
Damue01 wants to merge 1 commit into
NousResearch:mainfrom
Damue01:feat/feishu-ask-card-form

Conversation

@Damue01

@Damue01 Damue01 commented Apr 14, 2026

Copy link
Copy Markdown

What

Upgrade Feishu's clarify / askQuestion tool from plain-text messages to interactive Card V2 forms with real-time inline response updates.

Why

The existing plain-text clarify flow on Feishu requires users to type exact option text back — there's no visual structure, and multi-question forms are impossible. Card V2 forms provide native select menus, freeform text inputs, and multi-select checkboxes, matching Feishu's own product UX.

Changes

File What changed
tools/clarify_tool.py Extended schema with questions array — each question supports header, options[], allowFreeformInput, and multiSelect
gateway/platforms/base.py Added send_clarify_prompt(questions=...) to base adapter interface
gateway/platforms/feishu.py Implemented _build_clarify_card() (V1 button card), _build_ask_form_card() (V2 multi-field form), _build_inline_card_response() (inline update), _handle_card_action_event() (callback with sender name resolution)
gateway/run.py Wired _clarify_callback_sync to pass questions to platform adapters; text fallback for non-card platforms
gateway/stream_consumer.py Strip leading \n from streamed edits to avoid blank-looking messages
cli.py Updated CLI _clarify_callback to accept **kwargs for forward compatibility
run_agent.py Thread questions kwarg through both tool dispatch paths

How it works

  1. Agent calls askQuestion with structured questions → adapter builds a Card V2 form (or falls back to V1 button card for single questions without freeform input).
  2. User interacts in Feishu (select options / type freeform) → card action callback fires → adapter resolves sender name via Contact API and builds a formatted answer string.
  3. The original card is updated in-place via P2CardActionTriggerResponse (no separate edit_message call) → resolved answer is returned to the agent as the tool result.

How to test

pytest tests/gateway/test_feishu.py tests/gateway/test_feishu_approval_buttons.py tests/tools/test_clarify_tool.py -v

Manual testing: Start the gateway (hermes gateway), send a message in Feishu that triggers the agent to ask a clarifying question — verify the card renders with selectable options and updates inline after selection.

Test results

Suite Passed
tests/gateway/test_feishu.py 106
tests/gateway/test_feishu_approval_buttons.py 36
tests/tools/test_clarify_tool.py 31
Total 173

Screenshots

20260414-192547
20260414-192552

Platforms tested

  • Linux (WSL2 Ubuntu, Python 3.11)

@Damue01 Damue01 force-pushed the feat/feishu-ask-card-form branch from 54ad731 to 354c80e Compare April 14, 2026 11:24
@Damue01 Damue01 changed the title feat(feishu): interactive card-based askQuestion with inline response updates feat(feishu): upgrade askQuestion to interactive Card V2 forms Apr 14, 2026
@Damue01 Damue01 force-pushed the feat/feishu-ask-card-form branch from 8a7dc84 to 354c80e Compare April 14, 2026 12:15

@RuckVibeCodes RuckVibeCodes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[gus-first-pass] feat(feishu): upgrade askQuestion to interactive Card V2 forms - Clear feature addition, no issues found.

Replace plain-text clarify messages with Feishu Card V2 interactive
forms that support single/multi-select options, freeform text input,
and real-time inline response updates.

Changes:
- Extend clarify tool schema with structured questions array
  (header, options, multiSelect, allowFreeformInput)
- Add send_clarify_prompt(questions=...) to gateway base adapter
- Implement Card V2 form builder (_build_ask_form_card) and V1
  button card (_build_clarify_card) with adaptive layout
- Handle card action callbacks with sender name resolution via
  Contact API, return formatted answers as tool results
- Inline card update via P2CardActionTriggerResponse (no separate
  edit_message call)
- Wire questions param through gateway runner and run_agent dispatch
- Strip leading newlines in streamed edits (stream_consumer fix)
- Update CLI clarify callback for forward compatibility

Tests: 173 passed (106 feishu + 36 approval + 31 clarify)
@Damue01 Damue01 force-pushed the feat/feishu-ask-card-form branch from 354c80e to a8c0a83 Compare April 15, 2026 06:53
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #11981 (Feishu interactive clarify card resolution) and #12459 (Feishu Card 2.0 for markdown). This PR is a more comprehensive implementation covering multi-field V2 forms with inline updates.

@Feng-H

Feng-H commented Apr 30, 2026

Copy link
Copy Markdown

Hi, I'm a daily Feishu user of Hermes Agent. This feature would be a huge improvement — currently the plain-text clarify flow on Feishu requires typing exact option text back, which is not user-friendly at all. Interactive Card V2 forms with native select menus would make the Feishu experience much better.

Is it possible to evaluate and merge this soon? Many Feishu users would benefit from it. Thanks!

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.

4 participants