Skip to content

Fix v1 lifecycle handler discovery#1347

Open
xeophon wants to merge 1 commit into
mainfrom
fix-v1-lifecycle-handler-discovery
Open

Fix v1 lifecycle handler discovery#1347
xeophon wants to merge 1 commit into
mainfrom
fix-v1-lifecycle-handler-discovery

Conversation

@xeophon
Copy link
Copy Markdown
Member

@xeophon xeophon commented May 11, 2026

Summary

  • require lifecycle handler marker attributes to be exactly True
  • avoid collecting unrelated callable attributes/classes as lifecycle handlers

Validation

  • uv run ruff check verifiers/v1/utils/lifecycle_utils.py
  • uv run ruff format --check verifiers/v1/utils/lifecycle_utils.py

Note

Medium Risk
Changes which callables are discovered as lifecycle handlers by requiring marker attributes to be exactly True, which could alter runtime behavior for existing toolsets that relied on truthy non-boolean markers.

Overview
Fixes v1 lifecycle handler discovery so only callables explicitly marked with lifecycle attributes (e.g. stop, setup, update, cleanup) set to True are collected.

This tightens handler filtering in both Runtime._rollout_handlers and collect_handlers, reducing accidental pickup of unrelated callable members and making stage-based lifecycle execution more predictable.

Reviewed by Cursor Bugbot for commit 2c375c5. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Comment thread verifiers/v1/utils/lifecycle_utils.py
@xeophon xeophon force-pushed the fix-v1-lifecycle-handler-discovery branch from 6890a9f to 2c375c5 Compare May 11, 2026 19:19
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2c375c5. Configure here.

Comment thread verifiers/v1/runtime.py
handlers.append(cast(Callable[..., object], handler))
for _, method in inspect.getmembers(toolset, predicate=callable):
if not getattr(method, attr, False):
if getattr(method, attr, False) is not True:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed handler discovery fix at third occurrence

Medium Severity

The _toolset_binding_targets method at line 966 still uses the old truthiness check (getattr(method, attr, False)) to discover lifecycle handler methods, while the same pattern was intentionally tightened to is True in _rollout_handlers and collect_handlers. This means _toolset_binding_targets can still falsely pick up unrelated callable attributes as lifecycle handler binding targets — the exact bug this PR intends to fix.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c375c5. Configure here.

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.

1 participant