Skip to content

Killing Subagent Processes #1509

@larswaechter

Description

@larswaechter

Hello, in my scenario I manually invoke an Embabel agent using the AgentPlatform. Simplified version:

    AgentProcess agentProcess = null;
    CompletableFuture<AgentProcess> future = null;
    
    try {
      ProcessOptions process = new ProcessOptions()
          .withContextId("123");

      agentProcess = agentPlatform.createAgentProcessFrom(
          myAgent,
          process,
          blackboard
      );

      future = agentPlatform.start(agentProcess).get(30, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
      future.get().kill(); // How to kill subagents?
    }

Within myAgent I call other subagents using RunSubagent.fromAnnotatedInstance() method. My goal is to kill the parent agent and all its subagent processes when a timeout is thrown (after 30s here). What's the best way to achieve this?

I know that the AgentProcess contains a kill method but this does only kill the parent and not the child processes?
My idea was to get the processes from the AgentProcessRepository but it does not provide something like fun findByParentId(id: String): List<AgentProcess>. Is there any linkage between a parent agent and its children?

Thank you!

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions