-
-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
Description
Title: Feature: Session‑based Code Interpreter with Persistent State
Is your feature request related to a problem? Please describe.
- Multi‑step workflows: Today, each call to the interpreter is stateless, so variables, installed packages, and files are lost between calls.
- Re-initialization cost: Re-importing libraries, re-downloading datasets, and re-establishing context slows iteration.
- Brittle context passing: Manually re-sending prior outputs or code increases token usage and error risk.
Describe the solution you'd like
- Durable sessions: A session ID that pins execution to an isolated runtime where variables, files, and package state persist across calls.
- Session lifecycle: Create, resume, pause, checkpoint, restore, reset, and close; configurable TTL and resource limits.
- State persistence: Persist working directory, installed packages/cache, environment variables, and execution history.
- Observability & control: Streaming stdout/stderr, per-call metadata, resource usage, and session‑scoped logs.
- Portability: Export session as archive (code + env + files) for reproducibility; optional snapshot/restore.
- Runtimes: Python first; R/JS as follow‑ups, matching repository goals; kernel-like interactive behavior.
Describe alternatives you've considered
- Pass all context every call: Increases token usage, latency, and failure risk; doesn’t persist file system or package state.
- External storage + reload: Requires manual synchronization, is brittle, and still redoes environment setup each call.
- Long-running single job: Resource‑heavy, harder to isolate/secure, and fragile across timeouts or outages.
Additional context
- Alignment with open issues: Related to Feature Request: Interactive Python Kernel #46 (Interactive Python Kernel), Feature Request: API Server for Other Languages with Stateful Container Manager #47 (API Server with stateful manager), Feature Request: Security Presets #45 (Security Presets), Feature Request: Timeout Sandbox #43 (Firecracker backend), and Feature Request: Add Apple Container Backend Support for Enhanced Security on macOS #65 (Apple Container Backend on macOS).
- Security model: Per‑session isolation, quotas, timeouts, network egress policy, secrets via session‑scoped mounts, and audit trail.
- Implementation sketch: Session Manager service + backend orchestrator (k8s pods with PVCs; Firecracker/macos backends), checkpointing/snapshots, token‑scoped auth, idle cleanup.
- UX ideas: “New Session” button, session list with status/TTL/resources, quick actions (Pause/Restore/Reset), and export/archive.
Acceptance criteria
- Persistence: Variables, files, and installed packages remain available across multiple execute calls within the same session.
- Lifecycle controls: Create, resume, pause, reset, checkpoint, restore, and close function reliably with clear statuses.
- Reproducibility: Export/import yields the same environment and results on a fresh backend.
- Performance: Time‑to‑first‑execute ≤ N seconds; subsequent executes are faster due to cached state.
- Safety: Enforced isolation, quotas, timeouts, and configurable egress by preset; sessions auto‑clean after TTL.