Skip to content

feat: add after_tool hook needed for tool result offloading#11843

Open
sjrl wants to merge 3 commits into
v3from
add-after-tool-hook
Open

feat: add after_tool hook needed for tool result offloading#11843
sjrl wants to merge 3 commits into
v3from
add-after-tool-hook

Conversation

@sjrl

@sjrl sjrl commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Added an after_tool hook point to the Agent. Hooks registered under after_tool run after tools execute, once their result messages are in state.data["messages"], and before the exit check and the next LLM call. Use it to rewrite the freshly produced tool-result messages, for example to offload, redact, truncate, or summarize results before the next LLM call sees them. It does not run on the plain-text exit step, where no tools run. Register it
like any other hook: hooks={"after_tool": [my_hook]}.

How did you test it?

New tests

Notes for the reviewer

First step towards adding tool result offloading as a feature.

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: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Preview Jul 1, 2026 1:12pm

Request Review

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/agents
  agent.py
  haystack/hooks
  __init__.py
  protocol.py
Project Total  

This report was generated by python-coverage-comment-action

@sjrl sjrl self-assigned this Jul 1, 2026
@sjrl sjrl marked this pull request as ready for review July 1, 2026 13:13
@sjrl sjrl requested a review from a team as a code owner July 1, 2026 13:13
@sjrl sjrl requested review from julian-risch and removed request for a team July 1, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant