AI tool security
Persistent terminals for AI: context and operational control
Learn how persistent terminals preserve directory, environment, and process context, and how output cursors, bounded history, cancellation, and recovery support multi-step work.
Why does starting a new shell for every command complicate AI tasks?
Directory changes, activated environments, and interactive programs often require a shared session. A persistent terminal retains that context for step-by-step operations. Because it runs real processes, input authorization, output reading, and session management must be designed together.
A persistent session still needs scoped authorization
A session retains working directory, process state, and interaction context. Tasks specify directories, permitted commands or inputs, and available resources. Credentialed processes need scoping too; local execution is not an isolation sandbox.
Interactive tools may wait for input or keep emitting output. Reading state, sending input, and terminating a process should be distinct actions, so the user can decide what happens next.
Read incremental output with cursors
Repeatedly reading an entire log wastes context and mixes old and new output. Cursors mark the read position for subsequent incremental reads. Results still need bounds and explicit truncation signals so partial output is not mistaken for a complete record.
- Distinguish running processes from completed operations.
- Check output for sensitive or out-of-scope content.
- Keep session identifiers, read positions, and key states.
Make cancellation and recovery explicit
Stopping a wait, cancelling a task, and terminating a process are different. Local cancellation does not automatically undo remote changes. Records should retain the last known state; connectors may need to check the actual outcome.
After an application restart, configuration and readable records can be restored, but an exited operating-system process cannot simply resume unchanged. Recovery procedures should reflect this distinction.
Read long-running tasks incrementally and retain the last confirmed process state. Make history truncation explicit and query the business system again when needed. A success message does not replace checks of exit status, temporary-material cleanup, or remote results.