Skip to content

Task queue for an AI agent

A task queue for assigning work to an AI agent.

Motivation

More and more LLMs are available for free, and I kept regretting that I was too lazy to make use of them. On August 9, 2025, Qwen Code went so far as to announce a free plan allowing 2,000 requests a day with no token limit. Even sending one request every minute around the clock would leave 560 requests unused.

I thought it would be good to have a system that makes use of this opportunity.

  • I should always be able to assign work easily.
  • I should be able to check progress and results easily.
  • I should be able to set priorities.
  • When it runs out of work I assigned, it should find something useful to do for me on its own.
  • The goal should be producing the results I want, rather than assigning lots of work (using lots of tokens).

Design

GitHub issues seem like a good fit.

  • Always assign work easily → With the mobile app and the gh CLI, I can create issues anytime.
  • Check progress and results easily → Have the agent post interim progress updates as comments on the issue.
  • Set priorities → Attach suitable priority labels to issues and have the agent recognize them when choosing the next task.
  • Do something useful on its own when assigned work runs out → Register a few tasks that never end and can keep improving with more time, and have it alternate among them (a simple round-robin to start) when there is nothing else to do.

A shell script could repeat the following process indefinitely.

  1. Retrieve the highest-priority GitHub issue. If there are no issues, wait a minute and query again.
  2. Create a working directory named for the issue number and make it the current directory.
  3. Pass the issue body to Qwen Code and instruct it to handle the task.
  4. When Qwen Code exits, check whether the predefined completion condition is satisfied. If not, GOTO 3; if so, GOTO 1.

Put the completion condition on the last line of the issue body in this format:

Do something. Blahblah.

check: npm run test

Run the command in check: an exit code of 0 means success; anything else means failure. If there is no check on the last line, run colon and always treat the result as success.

Using s4 for the completion condition implements stateless AI–human interaction, allowing complex projects to continue across multiple agent sessions.

Implementation

I had Qwen Code put together a rough implementation. It works for now. Here is the initial prompt for assigning it work:

Your job is to complete the issue nnn.

  • Using “gh” CLI, read the issue and their comments to understand the context.
  • The current working directory is your workspace and you may use it freely. Note that the directory is not connected to the repository.
  • There could be files created by your co-workers. Read the files carefully.
  • Before you start, leave a comment in the issue that you’re going to start working on it and describe your plan briefly.
  • If you’ve spent more than 5 minutes on the issue, regularly check if there are any new comments from your co-workers. If there are, read them and update your plan accordingly. Write your updated plan as a comment.
  • If you’ve finished the issue, write the summary of your work as a comment in the issue, and attach “ready” label. NEVER close the issue.
  • If the main artifact of the issue is a text, or can be described in text, write it as a comment.
  • All your comments MUST start with “🤖”

Remaining work

  • Find “tasks that never end and can keep improving with more time” and register them at low priority.
  • Give high-priority requests to an expensive agent and leave the rest to Qwen Code? Or let me specify the agent when creating an issue? Or route tasks automatically?
  • Sandbox Qwen Code.
  • Have the bot post from a different account(?). Right now it uses my GitHub account, which means I don’t receive comment notifications.
Created
Updated

Machine-translated from the Korean original.

2026 © ak | markdown | 한국어