Skip to content

feat: migrate to Haystack 3.0 hooks-based HITL API - #2

Merged
julian-risch merged 2 commits into
mainfrom
feat/haystack-3.0-compat
Jul 20, 2026
Merged

julian-risch merged 2 commits into
mainfrom
feat/haystack-3.0-compat

Conversation

@julian-risch

@julian-risch julian-risch commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Fixes https://github.com/deepset-ai/haystack-private/issues/456

Haystack 3.0 uses hooks for human-in-the-loop. The docs there link to this repository as the production-style HITL example.

What changed

Haystack 2.x (before) Haystack 3.0 (after)
Agent(..., confirmation_strategies={tool: strategy}) Agent(..., hooks={"before_tool": [ConfirmationHook(confirmation_strategies={tool: strategy})]})
agent.run_async(..., confirmation_strategy_context={...}) agent.run_async(..., hook_context={...})
ConfirmationStrategy.run/run_async positional-or-keyword params keyword-only (*,) per the v3 protocol

The strategy body is unchanged: ConfirmationHook reads hook_context from state via state.data (avoiding State.get's deep copy, which would break the live Redis client and asyncio queue) and forwards it to the strategy as the same confirmation_strategy_context kwarg as before.

  • pipelines/hitl/pipeline_wrapper.py: hooks-based Agent config, hook_context run arg, keyword-only strategy signatures
  • requirements.txt: hayhooks>=1.22.0; haystack-ai installed from git main
  • README.md: updated custom-tools snippet and the pipeline-side explanation; added a Haystack 3.0 note

Verification

I ran the demo myself following the readme. Used:

export OPENAI_API_KEY="your-api-key-here"
docker compose up -d --build

then deployed pipe function and asked for the weather. Confirmation pop up came up as expected. Double-checked that the Hayhooks container was running haystack version: 3.0.0rc0 because in the UI it feels exactly the same as with 2.x. 🎉

In addition, I let my coding agent run end-to-end agent.run_async(messages=..., hook_context=...) with a real OpenAI call: the LLM's weather_tool call was approved live through Redis and the agent answered from the tool result.

🤖 Generated with Claude Code

Haystack 3.0 recasts human-in-the-loop as a before_tool hook:
- Agent no longer accepts confirmation_strategies; register a
  ConfirmationHook under hooks={"before_tool": [...]} instead
- The confirmation_strategy_context run argument is replaced by the
  generic hook_context argument; the ConfirmationHook forwards it to
  each strategy as confirmation_strategy_context
- ConfirmationStrategy.run/run_async are keyword-only in the protocol

Also bumps hayhooks to >=1.22.0 (first release supporting Haystack v3)
and installs haystack-ai from the main branch until 3.0 is on PyPI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread requirements.txt Resolved
Comment thread README.md Resolved
@julian-risch

Copy link
Copy Markdown
Member Author

We can hold off merging this PR until the 3.0 release.

@julian-risch
julian-risch requested a review from sjrl July 11, 2026 16:44
@julian-risch julian-risch changed the title Migrate to Haystack 3.0 hooks-based HITL API feat: migrate to Haystack 3.0 hooks-based HITL API Jul 11, 2026
@julian-risch
julian-risch marked this pull request as ready for review July 11, 2026 16:47
Comment thread pipelines/hitl/pipeline_wrapper.py Resolved
Comment thread pipelines/hitl/pipeline_wrapper.py Resolved
Co-authored-by: Julian Risch <julianrisch@gmx.de>
Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
@julian-risch
julian-risch merged commit 375ae8c into main Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants