feat(agent-tools): handle tool rejection and approval states#1333
Merged
Conversation
- Return structured tool results for user rejection, confirmation timeout, and execution timeout instead of generic failures - Add shared tool execution presentation helpers and contract coverage for rejection / timeout assistant messages - Introduce FlowChat approval bar with approve, reject, reject-with-instruction, permission options, and countdown UI - Render rejected tool state distinctly across FlowChat event handling and tool cards - Add focused web UI tests for approval controls, terminal card rejection display, and tool event handling - Update agentic tool settings and FlowChat locale strings
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 structured handling for agent tool rejection, confirmation timeout, and execution timeout states across the Rust tool pipeline and FlowChat UI.
Fixes #
Type and Areas
Type:
Feature / UI/UX / test
Areas:
Rust core, execution tool contracts, agent runtime, CLI, web UI, i18n
Motivation / Impact
Previously, user-rejected tool calls and confirmation / execution timeouts could surface as generic failures or argument errors. This change returns structured tool results for those cases so the assistant receives clearer guidance and avoids blindly retrying rejected or timed-out tool calls.
For users, FlowChat now shows an approval bar with approve, reject, reject-with-instruction, permission options, and a countdown when a confirmation timeout is available. Rejected tool calls render as a distinct state across tool cards instead of being folded into generic cancelled/error handling.
This also keeps CLI handling compatible with the expanded confirmation-needed event payload.
Verification
Passed:
pnpm run fmt:rspnpm run type-check:webpnpm run i18n:auditcargo check --workspacecargo test -p bitfun-agent-tools --test tool_contractscargo test -p bitfun-agent-runtime --test tool_confirmation_contractscargo test -p tool-runtime --test tool_pipeline_planningcargo test -p bitfun-core confirmation_rejection_returns_user_rejected_result_without_argument_errorcargo test -p bitfun-core confirmation_timeout_returns_timeout_result_without_argument_errorpnpm --dir src/web-ui run test:run src/flow_chat/components/ToolApprovalBar.test.tsx src/flow_chat/tool-cards/ExecProcessToolCardView.test.tsx src/flow_chat/services/flow-chat-manager/ToolEventModule.test.ts src/flow_chat/tool-cards/ReadFileDisplay.test.tsxReviewer Notes
The PR adds a new
Rejectedtool state/event path and extends confirmation-needed events with timeout metadata. The CLI match path now ignores unknown/additional confirmation fields so it remains compatible with the expanded payload.The FlowChat approval countdown test mock now performs basic i18n interpolation, which matches the component’s use of
remaining {{time}}.Checklist