Skip to content

fix(terminal): use context.WithoutCancel for detached commands#195

Open
manusjs wants to merge 1 commit intovxcontrol:masterfrom
manusjs:fix/detached-command-context
Open

fix(terminal): use context.WithoutCancel for detached commands#195
manusjs wants to merge 1 commit intovxcontrol:masterfrom
manusjs:fix/detached-command-context

Conversation

@manusjs
Copy link

@manusjs manusjs commented Mar 11, 2026

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, ExecCommand with detach=true passed the parent context to the goroutine's getExecResult call. When the parent context was canceled (~2.5 min via Cloudflare tunnel / upstream proxy), the "detached" background command was killed too — making detach=true effectively a no-op.

Changes

  • terminal.go: When detach=true, wraps with context.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) to performPentester and other specialist performers via context.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.

…vent parent cancellation

When detach=true, the goroutine that waits for exec results now uses
context.WithoutCancel(ctx) so it is no longer killed when the parent
context is canceled (~2.5 min). Also adds a 10-minute default agent
execution timeout in performAgentChain so agents have a sensible
deadline instead of inheriting an arbitrary parent timeout.

Fixes vxcontrol#176

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent delegation context canceled — detached commands inherit parent context

1 participant