Skip to main content

Terminal and background tasks

Explyt CLI runs long commands, such as a dev server, a watcher, a long build, or tests, in the background. The command keeps running while you and the agent move on to the next task.

Why it matters​

Without background mode, the agent would wait for the server or build to finish and couldn't continue. With background tasks, you can, for example, start a server and then test it with requests from the same chat.

How to use it​

Describe the task in the chat:

Start the server in the background
Run the full test suite in the background, and while it runs, deal with the compiler warnings

The agent decides which commands to run in the background. When a background command finishes, the agent is notified and takes the result into account.

How it works​

The agent has three tools for commands:

ToolWhat it does
bashRuns a command right away or starts it in the background
bash_outputReads a background task's output or waits a given time for it to finish
bash_killStops a background task

The model sets the command's wait time with the timeout parameter: 120 seconds by default, one hour at most. If the command doesn't finish in time, the CLI doesn't stop it: the command detaches and keeps running in the background. The model is told about this and gets a notification when the command finishes.

A background task's output is written to a file in the agent's service folder, not in the project, so no service files appear in your repository.

So that the agent doesn't forget about a running task, the CLI reminds it after 4, 8, and 30 minutes.

Completion notifications​

When the agent finishes a task, the CLI shows a desktop notification:

  • on Windows, a Windows system notification;
  • on macOS and Linux, through terminal escape codes, notify-send, or osascript.

No notifications are shown while the terminal window is in focus.

Viewing output and stopping a task​

  • To see the output, ask the agent: Show the server output.
  • To stop a task, ask: Stop the server. The agent first sends the process a graceful termination signal and, if it doesn't exit, a forced one. On Windows, taskkill is used.
  • A command that runs longer than its time limit isn't interrupted; it moves to the background.

Running commands are shown in the work panel in the terminal. In a task's history, the b key sends it to the background and s stops it. Ctrl+O shows or hides the full tool output in the chat.

Your own commands in the terminal​

You can also run a command yourself without leaving the CLI:

InputWhat happens
!commandRuns the command and sends its output to the agent
!!commandRuns the command without sending its output to the agent

If the agent is working at the time, the result of ! arrives after its answer. To just look at the output, use !! or wait until the agent is done.

Limitations​

  • The full output of a finished background task is kept for 30 minutes after it ends. The last 2,000 lines (up to 50 KB) stay available until the end of the session.
  • The number of simultaneous background tasks is limited.
  • On Windows without bash, commands run in PowerShell.