SSH connection pooling: per-session, 20-minute TTL
- Pool keyed by session_id:host:port:username — parallel sessions share
  no state even when targeting the same server
- Per-key asyncio.Lock prevents concurrent connection creation races
- TTL (20 min) and is_closing() checked on every access; expired/closed
  connections are evicted and replaced transparently
- On disconnect error during command execution: evict + retry once with
  fresh connection
- current_session_id ContextVar (set by Agent before tool calls) is read
  in ssh_exec to build the pool key without changing tool signatures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d04c75d commit 108f65ddb164080310937bc6d8f3ecbecde7d775
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 9 Apr
Showing 4 changed files
View
.env.example
View
navi/core/agent.py
View
navi/tools/base.py
View
navi/tools/ssh_exec.py