The full picture
Task intake
Tasks enter Optio through one of three channels:- Web UI
- GitHub Issues
- Linear
Go to Tasks → New Task and fill in the title, repository, and description. The task is created immediately and enters the queue.You can also create tasks from templates on the Templates page, or set up recurring tasks on the Schedules page.
The task lifecycle
Every task moves through a defined set of states. All transitions are validated — invalid transitions are rejected.Pending → Queued
When you create a task, it enters
pending briefly while Optio validates the request, then transitions to queued and a BullMQ job is added with the task’s priority value (lower number = higher priority).If a task has dependencies on other tasks, it enters waiting_on_deps instead of queued and waits until all dependencies complete.Queued → Provisioning
The task worker picks up the job. Before starting, it checks two concurrency limits:
- Global limit — by default, 5 tasks can run simultaneously across all repositories
- Per-repo limit — by default, 2 tasks can run concurrently in the same repository’s pod
provisioning.Provisioning → Running
Optio finds or creates a Kubernetes pod for the target repository — this is the pod-per-repo model described below. Once the pod is ready, Optio execs into it, creates a git worktree for the task’s branch, writes the task description to
.optio/task.md, and launches the agent.The task moves to running as soon as the agent process starts.Running → PR Opened
The agent reads the task file, writes code in the isolated worktree, and opens a pull request against the repository’s default branch. Optio streams the agent’s structured JSON output to the dashboard in real time.When a PR URL is detected in the agent output, Optio stores the PR number and transitions the task to
pr_opened. The agent process exits — it has done its job.The worktree is cleaned up from the pod.PR monitoring
The PR watcher runs every 30 seconds as a repeating background job. For each task in
pr_opened state, it fetches the PR’s current data from GitHub:- CI check runs and their statuses
- Review state (approved, changes requested, pending)
- PR state (open, merged, closed)
Feedback loop
The PR watcher doesn’t just observe — it acts. Depending on what it finds, it triggers one of several responses:
- CI failing → transitions task to
needs_attention, re-queues it, and resumes the agent with the CI failure output as additional context - Merge conflicts → same as CI failure — agent is resumed and asked to rebase
- Review requests changes → if
autoResumeOnReviewis enabled for the repo, the review comments are passed to the agent as a resume prompt - CI passes → if code review is enabled, a review agent is launched as a subtask
- PR merged → task transitions to
completed, linked issues are closed, cost is recorded - PR closed without merge → task transitions to
failed
Pod-per-repo architecture
Optio uses a pod-per-repo model rather than creating a new container for every task. This is the central performance optimization. When the first task arrives for a repository:- Optio creates a Kubernetes pod with a persistent volume
- The pod clones the repository and runs any
.optio/setup.shsetup script present in the repo - The pod then runs
sleep infinity— it stays alive waiting for work
- Optio
execs into the existing pod - Runs
git fetch origin && git worktree addto create an isolated branch checkout - Launches the agent in that worktree
- Cleans up the worktree when the agent exits
Code review agent
Optio can automatically run a second AI agent to review the code before merging. The review agent:- Is launched as a subtask of the original coding task
- Runs in the same repo pod, scoped to the PR branch
- Uses a separate prompt template and can use a different (cheaper) model
- Posts review comments to the PR
- Blocks the parent task from advancing until it completes
