You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for conditional routing of skill script execution between the hosted code interpreter and a user-provided executor, encapsulated as SkillExecutor.Hybrid(). This mode lives in the AgentSkills sample project, not in the Microsoft.Agents.AI library.
Background
With SkillExecutor.HostedCodeInterpreter() (#4131) and SkillExecutor.External() (#4132) established in the core library, this issue adds a third execution mode that conditionally routes each script to one of the two based on a user-provided predicate. This mode lives in the AgentSkills sample project and serves as a reference for how to extend SkillExecutor from consuming code. This is the third of three planned execution modes:
Add a static Hybrid() factory method on SkillExecutorin the AgentSkills sample project that accepts:
A route selector predicate — given script context (extension, skill name, etc.), returns whether to use the hosted code interpreter or the external executor.
A user-provided execution delegate — called when the route selector chooses external execution.
The Hybrid mode (concrete sealed subclass) must:
Provide instructions that direct the LLM to call resolve_executor before executing a script to determine which execution path to use.
Register both resolve_executor and execute_script tools.
When resolve_executor is invoked, call the route selector predicate and return the result to the LLM.
When execute_script is invoked, delegate to the user-provided execution callback.
This class should not be added to Microsoft.Agents.AI. It should demonstrate how to extend SkillExecutor from consuming code.
The execute_script tool should be wrapped with ApprovalRequiredAIFunction by default to require user approval before executing scripts externally.
The Hybrid() factory method should accept an optional parameter to disable approval (e.g., requireApproval: bool = true). When enabled: new
ApprovalRequiredAIFunction(AIFunctionFactory.Create(executeScript)). When disabled, the tool is registered directly.
Note: resolve_executor does not require approval as it only determines routing, not execution.
Acceptance Criteria
Hybrid() static factory method implemented in the AgentSkills sample project
Hybrid mode is a sealed concrete subclass of SkillExecutor
Hybrid mode registers resolve_executor and execute_script tools
resolve_executor invocations delegate to the user-provided route selector predicate
execute_script invocations delegate to the user-provided execution callback
Hybrid mode provides instructions guiding the LLM to call resolve_executor before script execution
Sample demonstrates usage with routing based on script extension or skill name
Serves as a reference for extending SkillExecutor outside the core library
execute_script tool is wrapped with ApprovalRequiredAIFunction by default
Approval can be disabled via Hybrid(routeSelector, execute, requireApproval: false)
resolve_executor tool does not require approval
Unit tests cover both approval-enabled and approval-disabled paths
Summary
Add support for conditional routing of skill script execution between the hosted code interpreter and a user-provided executor, encapsulated as
SkillExecutor.Hybrid(). This mode lives in the AgentSkills sample project, not in theMicrosoft.Agents.AIlibrary.Background
With
SkillExecutor.HostedCodeInterpreter()(#4131) andSkillExecutor.External()(#4132) established in the core library, this issue adds a third execution mode that conditionally routes each script to one of the two based on a user-provided predicate. This mode lives in the AgentSkills sample project and serves as a reference for how to extendSkillExecutorfrom consuming code. This is the third of three planned execution modes:SkillExecutor.HostedCodeInterpreter()— LLM code interpreter (AddSkillExecutor.HostedCodeInterpreter()skill script execution mode #4131)SkillExecutor.External()— user-provided executor (AddSkillExecutor.External()skill script execution mode #4132)SkillExecutor.Hybrid()← this issue (sample only)Requirements
Hybrid()factory method onSkillExecutorin the AgentSkills sample project that accepts:Hybridmode (concrete sealed subclass) must:resolve_executorbefore executing a script to determine which execution path to use.resolve_executorandexecute_scripttools.resolve_executoris invoked, call the route selector predicate and return the result to the LLM.execute_scriptis invoked, delegate to the user-provided execution callback.Microsoft.Agents.AI. It should demonstrate how to extendSkillExecutorfrom consuming code.ApprovalRequiredAIFunction(AIFunctionFactory.Create(executeScript)). When disabled, the tool is registered directly.
Acceptance Criteria
Hybrid()static factory method implemented in the AgentSkills sample projectHybridmode is a sealed concrete subclass ofSkillExecutorHybridmode registersresolve_executorandexecute_scripttoolsresolve_executorinvocations delegate to the user-provided route selector predicateexecute_scriptinvocations delegate to the user-provided execution callbackHybridmode provides instructions guiding the LLM to callresolve_executorbefore script executionSkillExecutoroutside the core libraryPart of #3499
Depends on #4131 and #4132