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
Copy Markdown
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 2 times, most recently 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
@benmezger benmezger force-pushed the fix/normalize-hooks branch 3 times, most recently from 7972b2f to ab81c28 Compare March 17, 2026 06:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

This pull request has been automatically marked as stale due to 14 days of inactivity. If this is still relevant, please update it or leave a comment.

@github-actions github-actions Bot added the stale label Apr 1, 2026
@benmezger
Copy link
Copy Markdown
Contributor Author

cc: @harshsinha03 mind having a look at this?

@benmezger benmezger force-pushed the fix/normalize-hooks branch from ab81c28 to 1826f78 Compare April 2, 2026 10:50
@github-actions github-actions Bot removed the stale label Apr 4, 2026
@benmezger benmezger force-pushed the fix/normalize-hooks branch 2 times, most recently from c5e9ce0 to 7848855 Compare April 11, 2026 11:54
`_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 7848855 to 03a2a82 Compare April 25, 2026 21:56
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