Skip to content

Add SkillExecutor.External() skill script execution mode #4132

@SergeyMenshykh

Description

@SergeyMenshykh

Summary

Add support for executing agent skill scripts via a user-provided executor, encapsulated as SkillExecutor.External().

Background

With the SkillExecutor abstract class and HostedCodeInterpreter mode established in #4131, this issue adds the second execution mode where script execution is delegated to a user/developer-provided callback. This is the second of three planned execution modes:

  1. SkillExecutor.HostedCodeInterpreter() — LLM code interpreter (Add SkillExecutor.HostedCodeInterpreter() skill script execution mode #4131)
  2. SkillExecutor.External() ← this issue
  3. SkillExecutor.Hybrid() — conditional routing between the two (future)

Requirements

  • Add a static External() factory method on SkillExecutor that accepts a user-provided execution delegate/predicate and returns a concrete sealed subclass instance.
  • The External mode (concrete sealed subclass) must:
    • Provide instructions that direct the LLM to call the execute_script tool for script execution.
    • Register an execute_script tool as a provided tool.
    • When execute_script is invoked, delegate execution to the user-provided callback, passing relevant context (script content, skill name, etc.).
  • The user-provided delegate should receive sufficient context to execute the script and return a result.
  • Add a sample project Agent_Step03_ScriptExecutionWithExternalExecutor demonstrating usage of this execution mode.
  • The execute_script tool should be wrapped with ApprovalRequiredAIFunction by default to require user approval before executing scripts externally.
    • The External() 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.

Acceptance Criteria

  • External() static factory method on SkillExecutor accepts a user-provided execution delegate
  • External mode is a sealed concrete subclass of SkillExecutor
  • External mode provides instructions directing the LLM to use execute_script
  • External mode registers an execute_script tool
  • execute_script tool invocations delegate to the user-provided callback
  • Unit tests cover mode initialization, instruction/tool provisioning, and delegate invocation
  • Integration with FileAgentSkillsProvider works consistently with the HostedCodeInterpreter mode
  • Agent_Step03_ScriptExecutionWithExternalExecutor sample project added
  • execute_script tool is wrapped with ApprovalRequiredAIFunction by default
    • Approval can be disabled via External(execute, requireApproval: false)
    • Unit tests cover both approval-enabled and approval-disabled paths

Part of #3499
Depends on #4131

Metadata

Metadata

Labels

No labels
No labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions