Skip to content

CallbackSet API#23243

Merged
luisorofino merged 4 commits intoloa/openmetrics-ai-genfrom
loa/react-pt2
Apr 10, 2026
Merged

CallbackSet API#23243
luisorofino merged 4 commits intoloa/openmetrics-ai-genfrom
loa/react-pt2

Conversation

@luisorofino
Copy link
Copy Markdown

@luisorofino luisorofino commented Apr 9, 2026

What does this PR do?

Refactors the ReAct callback system from a single ReActCallback Protocol (requiring all 4 methods) into a CallbackSet decorator-based registry where observers register only the events they care about.

Four new/changed source files:

  • react/types.py (new) — ReActResult moved here to avoid a circular import
  • react/callbacks.py (new) — four per-event callable Protocols + CallbackSet
  • react/process.py (changed) — drops ReActCallback, uses callback_sets: list[CallbackSet], dispatch loops collapse to single fire_* calls
  • tests for callbacks are also added

This PR also changes the name of the file client.py to anthropic_client.py (as well as its test), for it to be more descriptive. In that file, Anthropic-specific logic will live isolated from the rest of the model-agnostic files.

Motivation

The old ReActCallback Protocol forced every observer to implement all 4 lifecycle methods even when it only cared about one. The new CallbackSet API lets callers register only what they need using decorator syntax:

cb = CallbackSet()

@cb.on_complete
async def log_done(result: ReActResult) -> None:
    print(f"Done in {result.iterations} iterations")

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@dd-octo-sts dd-octo-sts bot added the ddev label Apr 9, 2026
@luisorofino luisorofino added the qa/skip-qa Automatically skip this PR for the next QA label Apr 9, 2026
@datadog-official

This comment has been minimized.

@luisorofino luisorofino marked this pull request as ready for review April 9, 2026 10:40
@luisorofino luisorofino requested a review from a team as a code owner April 9, 2026 10:40
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 97.03390% with 7 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (loa/openmetrics-ai-gen@1e530c8). Learn more about missing BASE report.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@luisorofino luisorofino merged commit 22465c8 into loa/openmetrics-ai-gen Apr 10, 2026
304 checks passed
@luisorofino luisorofino deleted the loa/react-pt2 branch April 10, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddev qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants