Background Tasks
Run and manage long-running background processes (dev servers, tests) directly within your session.
For complex software development, the agent often needs to track long-running work and keep persistent background services (a dev server, a build watcher, test runners) alive while continuing the conversation loop. KnightCode handles this with two related pieces: a background-process registry and a durable task ledger.
Background Process Registry
When a real OS subprocess is spawned, KnightCode tracks it so it never leaks:
- Process Monitoring: A heartbeat runs every 5 seconds, checking that each registered process is still alive and pruning entries for any that have exited.
- Process State: Live process state is stored in
.knightcode/processes.jsoninside your project directory. Background command output is not permanently persisted to disk. - Auto-Cleanup: When KnightCode exits — via
/exitorSIGTERM— all registered child processes are torn down (SIGTERM, ortaskkillon Windows) to prevent orphans.Ctrl+C/SIGINTis intentionally suppressed so it cannot accidentally kill the app or its tasks.
Task Tool Suite
Separately, the agent has a suite of tools for durable, multi-session task tracking, persisted as a ledger at .knightcode/tasks.json in your project. These tools manage task records — the actual work is performed by other tools (e.g. Bash).
TaskCreate: Creates a durable task record and returns itstask-id.TaskList: Returns all tracked tasks with their current statuses.TaskGet: Reads the details of a specific task by ID.TaskOutput: Fetches the streamed output / progress log appended to a task (with optionaltailto limit to the most recent entries).TaskUpdate: Updates a task's fields — its description or status. Setting the status todeletedpermanently removes the record.TaskStop: Abandons anin_progresstask — it resets the status back topendingand clears the task's owner (with an optionalreasonrecorded in the output log). It does not complete the task; useTaskUpdatewithstatus: completedfor genuinely finished work. The task must currently bein_progress, or the call errors.
Working with Tasks
You do not need to run task tools manually; the agent uses them automatically. The read-only and record-keeping task tools (TaskCreate, TaskList, TaskGet, TaskOutput, TaskUpdate, TaskStop) run without an approval prompt — it's the underlying file edits and shell commands that the agent runs alongside them that surface approval cards in BUILD mode. The agent can periodically check a task's output (using TaskOutput) to verify, for example, that a dev server started without errors.