Skip to content

.NET: How to intercept agent selection events in magentic orchestration? #13405

@tomasz-tomczykiewicz

Description

@tomasz-tomczykiewicz

I’m working with magentic orchestration in Semantic Kernel and I would like to log or intercept the moment when the manager selects the next agent in the workflow. The goal is to capture something like: “Manager delegated the next step to XXX”.

Is there an official mechanism (event, callback, or hook) to observe the agent-selection step?
If not, is such a feature planned or possible to expose?
Is there a recommended workaround for logging delegation decisions at runtime?

In telemetry I can see that records internal decision details, including a Reason field explaining why the manager selected a particular agent. It would be very useful to have programmatic access to this information in code.

Currently the only practical way to detect delegation is to inspect the first message produced by an agent via ResponseCallback, but this happens after the work by the agent is done. I am looking for a way to capture the decision at the moment the manager chooses the agent, ideally with access to the same Reason data visible in telemetry.

Thanks for any guidance on how to achieve this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions