Skip to content

Fix: Normalize hooks on every run instead of caching#6944

Open
benmezger wants to merge 1 commit intoagno-agi:mainfrom
benmezger:fix/normalize-hooks
Open

Fix: Normalize hooks on every run instead of caching#6944
benmezger wants to merge 1 commit intoagno-agi:mainfrom
benmezger:fix/normalize-hooks

Conversation

@benmezger
Copy link
Contributor

@benmezger benmezger commented Mar 10, 2026

_hooks_normalised skips normalisation after the first run, causing a TypeError when pre_hooks or post_hooks are reassigned on a reused Agent or Team between runs. Agno calls the raw BaseGuardrail object instead of its bound method.

normalize_pre_hooks and normalize_post_hooks are cheap, so the optimisation is not worth the bug IMHO.

Summary

Describe key changes, mention related issues or motivation for the changes.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Tested in clean environment
  • Tests added/updated (if applicable)

@benmezger benmezger changed the title Normalize hooks on every run instead of caching Fix: Normalize hooks on every run instead of caching Mar 10, 2026
@benmezger benmezger force-pushed the fix/normalize-hooks branch from 5e40ab8 to 60d047a Compare March 10, 2026 15:53
_hooks_normalised skips normalisation after the first run, causing a
TypeError when pre_hooks or post_hooks are reassigned on a reused Agent
or Team between runs. Agno calls the raw BaseGuardrail object instead of
its bound method.

normalize_pre_hooks and normalize_post_hooks are cheap, so the
optimisation is not worth the bug IMHO. PR Remove _hooks_normalised and
normalise on every run.
@benmezger benmezger force-pushed the fix/normalize-hooks branch from 60d047a to 4bfc891 Compare March 10, 2026 15:54
@benmezger benmezger marked this pull request as ready for review March 10, 2026 15:55
@benmezger benmezger requested a review from a team as a code owner March 10, 2026 15:55
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