Background tasks
How a long command becomes a background job, how long it runs, and where its output goes.
A slow command does not stop the agent from working. When a shell command runs longer than a short observation window, it becomes a background job. The job keeps running, and the agent can continue the conversation.
What happens when a command runs long?
- The agent starts a shell command.
- The agent watches the command for a short time: one second by default, and at most ten seconds. A command that finishes in this time returns its result directly.
- A command that is still running becomes a background job. The process continues without a restart. The agent gets the job ID and the output so far. The agent can also choose to wait in the foreground instead. Then the command stops if it prints no output for a time limit: two minutes by default, and at most ten minutes.
- The agent can read more output, wait for the job, or stop it.
The agent can also start a job in the background directly, for example a web server or a file watcher.
How long does a background job run?
There is no fixed time limit and no fixed number of jobs. A job stops when one of these events occurs:
- The command exits.
- The agent stops the job.
- The agent set a deadline for the job and the deadline passes. A deadline can be at most ten minutes.
- The environment is recycled.
Each background job stops when the run ends. The agent collects the job's results before it replies. This includes workers on their own copies of the Workspace files.
A background job does not make Plori deliver a result to you. If the environment stops before the job finishes, the job stops too. Check the job's output before you rely on it.
Where does the output go?
Each job writes its combined output to a log file in the agent's environment. The log keeps at most 10 MiB. Plori discards output after that limit and writes a notice at the end of the log. For a large result, ask the agent to write the result to a file in the Workspace and to keep that file.
Related
- Scheduled runs: start work at a fixed time instead of keeping it running.
- Why a workflow engine can say OK after a failed step: accepting a job is not the same as finishing it.
- Workspaces: which files persist between runs.