fix: use Core PerformAsync for agent monitoring — app stays alive
The monitoring goroutine that waits for agent completion was a raw `go func()` that Core didn't know about. ServiceShutdown killed it immediately on CLI exit. Now uses PerformAsync which registers with Core's WaitGroup: - ServiceShutdown waits for all async tasks to drain - `core-agent workspace dispatch` blocks until agent completes - Agent lifecycle properly tracked by the framework Also whitelist agentic.monitor.* and agentic.complete in entitlement checker. Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
b57be6eb91
commit
19d849aa75
2 changed files with 11 additions and 3 deletions
|
|
@ -383,11 +383,16 @@ func (s *PrepSubsystem) spawnAgent(agent, prompt, wsDir string) (int, string, er
|
|||
s.broadcastStart(agent, wsDir)
|
||||
s.startIssueTracking(wsDir)
|
||||
|
||||
go func() {
|
||||
// Register a one-shot Action that monitors this agent, then run it via PerformAsync.
|
||||
// PerformAsync tracks it in Core's WaitGroup — ServiceShutdown waits for it.
|
||||
monitorAction := core.Concat("agentic.monitor.", core.PathBase(wsDir))
|
||||
s.Core().Action(monitorAction, func(_ context.Context, _ core.Options) core.Result {
|
||||
<-proc.Done()
|
||||
s.onAgentComplete(agent, wsDir, outputFile,
|
||||
proc.Info().ExitCode, string(proc.Info().Status), proc.Output())
|
||||
}()
|
||||
return core.Result{OK: true}
|
||||
})
|
||||
s.Core().PerformAsync(monitorAction, core.NewOptions())
|
||||
|
||||
return pid, outputFile, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,10 @@ func (s *PrepSubsystem) OnStartup(ctx context.Context) core.Result {
|
|||
if !core.HasPrefix(action, "agentic.") {
|
||||
return core.Entitlement{Allowed: true, Unlimited: true}
|
||||
}
|
||||
// Read-only actions always allowed
|
||||
// Read-only + internal actions always allowed
|
||||
if core.HasPrefix(action, "agentic.monitor.") || core.HasPrefix(action, "agentic.complete") {
|
||||
return core.Entitlement{Allowed: true, Unlimited: true}
|
||||
}
|
||||
switch action {
|
||||
case "agentic.status", "agentic.scan", "agentic.watch",
|
||||
"agentic.issue.get", "agentic.issue.list", "agentic.pr.get", "agentic.pr.list",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue