feat(tools): add interactive_prompt tool with Discord UI support#39911
Open
TerminalSausage wants to merge 4 commits into
Open
feat(tools): add interactive_prompt tool with Discord UI support#39911TerminalSausage wants to merge 4 commits into
TerminalSausage wants to merge 4 commits into
Conversation
Implements structured interactive prompts with button choices and modal forms, rendered as Discord embeds + components with auth gating. New files: - tools/interactive_prompt_tool.py — schema, validation, tool entry point - tools/human_input_gateway.py — cross-platform prompt registry (per-session wait/resolve, timeout, cleanup) - tools/discord_auth_helpers.py — shared auth check for interactive views - tools/discord_interactive_views.py — Discord modal + choice button views - gateway/platforms/discord_components.py — Discord Components API adapter - tests/tools/ — 79 tests (4 files) Modified files: - gateway/run.py — interactive_prompt_callback wiring + gateway shutdown cleanup (clear_all for clarify + interactive prompts) - gateway/platforms/base.py — send_interactive_prompt adapter method - plugins/platforms/discord/adapter.py — Discord render override - agent/agent_runtime_helpers.py, agent/tool_executor.py — tool call paths - tools/clarify_gateway.py — clear_all() for shutdown cleanup - toolsets.py — toolset registration 79 tests passing. Docs committed separately.
P1: Fix double-JSON-encoding — detect and pass through already-serialized JSON strings from production gateway callbacks instead of re-encoding. P1: Add text-fallback resolution for non-rich platforms — add get_pending_for_session/mark_awaiting_text/resolve_text_response to human_input_gateway, wire base-platform send_human_input to mark text-capture, add gateway intercept for interactive_prompt text replies. P2: Use config-aware timeout in AIAgent intercepted paths — both agent_runtime_helpers.py and tool_executor.py now call get_interactive_prompt_timeout() when timeout_seconds is absent. P2: Wrap interactive_prompt in _finish_agent_tool in runtime_helpers so post-tool-call hooks fire (timing, metrics, tracing). P2: Use get_hermes_home() instead of hardcoded ~/.hermes for upload cache path in discord_interactive_views.py. P2: Implement per-policy auth checks — any_allowed_user only checks user allowlist, any_allowed_role only checks role allowlist, any_allowed_user_or_role checks union. P3: Enforce runtime validation — reject invalid display_type and auth_policy values, clamp timeout_seconds to 60-3600 range. 45 new tests covering all 7 findings.
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
interactive_prompt— a new tool that lets agents present structured interactive forms (buttons, modals with text/select/checkbox/file-upload fields) to users on Discord and CLI. Bridges the gap betweenclarify(single-choice quick prompts) and full conversation, giving agents a way to collect multi-field input, route workflows via button actions, and render rich Discord UI components.What it does
session_owner_only,any_allowed_user,any_allowed_role,any_allowed_user_or_roleKey files
tools/interactive_prompt_tool.pytools/discord_interactive_views.pytools/human_input_gateway.pytools/discord_auth_helpers.pygateway/platforms/discord_components.pygateway/run.pygateway/platforms/base.pyplugins/platforms/discord/adapter.pyagent/tool_executor.pyagent/agent_runtime_helpers.pytools/clarify_gateway.pyclear_all()utilitytoolsets.pycli-config.yaml.exampledocs/interactive-prompt-tool-spec.mdwebsite/docs/reference/tools-reference.mdwebsite/docs/developer-guide/gateway-internals.mdTests
py-cord; CI runs full suite)_finish_agent_toolwrapping, profile-aware cache paths, per-policy auth, runtime validationKnown limitations