mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #195] [CLOSED] fix(terminal): use context.WithoutCancel for detached commands #224
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/195
Author: @manusjs
Created: 3/11/2026
Status: ❌ Closed
Base:
master← Head:fix/detached-command-context📝 Commits (1)
4ba2e12fix(terminal): use context.WithoutCancel for detached commands to prevent parent cancellation📊 Changes
3 files changed (+167 additions, -6 deletions)
View changed files
📝
backend/pkg/providers/performer.go(+9 -5)📝
backend/pkg/tools/terminal.go(+2 -1)➕
backend/pkg/tools/terminal_detach_test.go(+156 -0)📄 Description
What
Detached terminal commands (
detach=true) now run with an independent context so they are not killed when the parent context is canceled. Also adds a sensible default agent execution timeout to specialist performers.Fixes #176
Root Cause
In
terminal.go,ExecCommandwithdetach=truepassed the parent context to the goroutine'sgetExecResultcall. When the parent context was canceled (~2.5 min via Cloudflare tunnel / upstream proxy), the "detached" background command was killed too — makingdetach=trueeffectively a no-op.Changes
terminal.go: Whendetach=true, wraps withcontext.WithoutCancel(ctx)(Go 1.21+) so the goroutine's context is never canceled by the parent.performers.go: Adds a configurable default agent execution timeout (10 min) toperformPentesterand other specialist performers viacontext.WithTimeout, giving each agent its own deadline.terminal_detach_test.go(new): Two tests — verifies goroutine context survives parent cancellation; verifies timeout still fires correctly.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.