Skip to content

feat: allow HITL to review materialized tool calls - #12517

Closed
lorenzozanee wants to merge 1 commit into
deepset-ai:mainfrom
lorenzozanee:fix/hitl-materialized-tool-calls
Closed

feat: allow HITL to review materialized tool calls#12517
lorenzozanee wants to merge 1 commit into
deepset-ai:mainfrom
lorenzozanee:fix/hitl-materialized-tool-calls

Conversation

@lorenzozanee

Copy link
Copy Markdown

Related Issues

Proposed Changes:

HITL currently shows only the LLM-produced arguments, while tools with inputs_from_state receive additional values from State at execution time. The reviewer therefore approves an incomplete view of the call.

This PR adds an opt-in mode to surface fully materialized calls before execution:

  • BlockingConfirmationStrategy(include_state_inputs=True) and ConfirmationHook(include_state_inputs=True) materialize inputs_from_state via the same _inject_state_args used by tool_calling._run_tool
  • default is False for backward compatibility
  • hook flag propagates to strategies so a single ConfirmationHook(include_state_inputs=True) covers the wildcard * case
  • State-typed parameters are shown as "<State>" to avoid dumping whole state
  • serialization preserves the flag for both types and State missing keys are handled without error

The materialization happens at before_tool time from the current State snapshot, matching execution-time injection for the stable single-tool case. For multi-tool batches where an earlier tool writes a key read by a later one, the approved view reflects the state at approval time; the existing per-batch re-materialization at dispatch still determines the final execution value.

How did you test it?

  • reproduction script with a tool using inputs_from_state={"selected_customer_id":"customer_id"} and State(selected_customer_id="cust_84319"): without the flag the UI sees {"reason":"duplicate"}, with the flag it sees {"reason":"duplicate","customer_id":"cust_84319"} and final_tool_params matches
  • test/hooks/human_in_the_loop (99 passed) and test/components/agents/test_agent_hitl.py (7 passed) including new cases TestMaterializedStateInputs for strategy and hook propagation
  • verified to_dict/from_dict round-trips for both BlockingConfirmationStrategy and ConfirmationHook
  • hatch run fmt clean

Notes for the reviewer

Opt-in only, no behavior change by default. Follow-up provenance labeling (llm_arg vs state_injected) and redaction can build on this materialization path without changing the approval contract.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title.
  • I have added a release note file.
  • I have run pre-commit hooks and fixed any issue.

Allow BlockingConfirmationStrategy and ConfirmationHook to show
inputs_from_state values alongside LLM arguments when
include_state_inputs is enabled. Materialization reuses the same
_inject_state_args logic used at execution time so the approval view
matches what the tool will receive. Hook-level flag propagates to
strategies via transient state so both levels can opt in.

Fixes deepset-ai#12060
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@lorenzozanee is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @lorenzozanee, thanks for your interest in contributing to Haystack! 🙏

⚠️ You currently have 6 open pull requests in this repository (#12516, #12513, #12497, #12495, #12469 and this one). Our review capacity is limited, so please hold off opening more PRs until we've had a chance to review your first 2 open PRs. This helps us give each contribution the attention it deserves. Thank you!

This is an automated message to help us keep the review queue healthy.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @lorenzozanee, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from sjrl August 31, 2026 01:40
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Aug 31, 2026
@HaystackBot
HaystackBot marked this pull request as draft August 31, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-pending PR is in draft until the contributor signs the CLA topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Human-in-the-Loop to review fully materialized tool calls

4 participants