-
Notifications
You must be signed in to change notification settings - Fork 19
fix: prevent safeoutputs session expiry during long-running agent tasks #3079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1e812a6
d1d8095
66d9146
97149f0
1039c17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,13 @@ const ( | |
|
|
||
| // Default configuration values | ||
| const ( | ||
| DefaultIdleTimeout = 30 * time.Minute | ||
| // DefaultIdleTimeout is the maximum duration a STDIO-backend connection can remain unused | ||
| // before being removed from the session pool. Set to 6 hours to accommodate long-running | ||
| // workflow tasks (e.g. ML training, large builds) that may not make MCP calls for extended | ||
| // periods. Note: this is distinct from HTTP backend keepalive (config.DefaultKeepaliveInterval) | ||
| // which keeps the remote session alive on the HTTP server side; STDIO connections run as local | ||
| // child processes whose sessions are bounded only by this pool eviction window. | ||
| DefaultIdleTimeout = 6 * time.Hour | ||
| DefaultCleanupInterval = 5 * time.Minute | ||
|
Comment on lines
+42
to
49
|
||
| DefaultMaxErrorCount = 10 | ||
| ) | ||
|
|
@@ -152,10 +158,12 @@ func (p *SessionConnectionPool) cleanupIdleConnections() { | |
| logPool.Printf("Cleaning up connection: backend=%s, session=%s, reason=%s, idle=%v, errors=%d", | ||
| key.BackendID, key.SessionID, reason, now.Sub(metadata.LastUsedAt), metadata.ErrorCount) | ||
|
|
||
| // Close the connection if still active | ||
| // Close the underlying connection to release resources (cancel context, close SDK session) | ||
| if metadata.Connection != nil && metadata.State != ConnectionStateClosed { | ||
| // Note: mcp.Connection doesn't have a Close method in current implementation | ||
| // but we mark it as closed | ||
| if err := metadata.Connection.Close(); err != nil { | ||
| logPool.Printf("Error closing connection during cleanup: backend=%s, session=%s, err=%v", | ||
| key.BackendID, key.SessionID, err) | ||
| } | ||
| metadata.State = ConnectionStateClosed | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KeepaliveIntervalis added toGatewayConfig, but it isn’t wired into the stdin JSON config path:StdinGatewayConfig/the embedded JSON schema don’t include a keepalive field, andconvertStdinConfigdoesn’t callapplyGatewayDefaultswhenstdinCfg.Gatewayis present. As a result, for--config-stdinruns (which are schema-validated), keepalive will remain0and be effectively disabled, undermining the main fix. Please extend the stdin schema +StdinGatewayConfigto accept a keepalive value (likelykeepaliveIntervalin camelCase), propagate it intoGatewayConfig, and ensure defaults are applied for the stdin conversion path too.