ykononov.com bb + agents / hands-on course Glossary FAQ RU

ykononov.com / Vibe coding from scratch: bb, Claude Code, Codex, and OpenCode / Module 09

Run several AI agents in parallel: worktrees and threads in bb

Module 09 of 11 · 20 min · updated 2026-11-28

Separate worktrees, parallel threads, and which agent gets which task.

In short

To keep two agents from editing the same files, give each thread a Worktree environment, a separate copy of the project. Merge finished work into the main version one thread at a time. Use the strongest model for planning and hard bugs, and OpenCode’s free models for small changes and review. The real limit on the number of agents is your own attention.

Worktree: every task gets its own desk

So far, you’ve had only one agent working at a time. That’s convenient, but you’ve probably noticed the pauses: the agent writes, you wait. The natural urge is to fill that time with a second task.

If you simply open a second thread in the same folder and give it a different task, two agents will start changing the same files at the same time. One rewrites a page while the other, in the same second, tweaks a button on it, and the result is no good to anyone. Picture two editors marking up the same paper copy of a manuscript at once.

The fix is to give each of them their own copy. In git this is called a worktree: a separate folder with a copy of the project and its own branch of history. bb creates one for you when you choose the Worktree environment for a new thread instead of Project checkout.

EVERY TASK GETS ITS OWN COPY Main folder the verified version Worktree 1 · “Stats” the thread where Claude Code works Worktree 2 · “Dark theme” the thread where Codex works the agents stay out of each other’s way; you merge finished work into the main folder one by one
The environment menu below the bb prompt box: Project checkout, Worktree, Reuse existing
The environment picker below the prompt box. Project checkout works in the project folder, Worktree works in a separate copy, and Reuse existing joins another thread’s environment, for a review, say.

What to keep in mind:

When you need this and when you don’tIf you’re doing one task at a time, stay in Project checkout; it’s simpler. You need a worktree in two cases: you want to run several tasks at once, or you’re trying a risky idea and don’t want to touch the working version until you’ve seen the result.

Practice: two tasks in parallel

Take two improvements that don’t overlap. For the habit tracker, for example: a dark theme and exporting the data to a file. If you’re building your own app, pick any two small, independent changes.

  1. Save your work. In the main thread: “Make a commit.” Copies are created from the saved state.
  2. First thread. Create a new thread with the Worktree environment and your main agent. The task:
    Add a dark theme with a toggle in the corner of the screen. It should remember my choice. Show me a short plan first. Once I confirm, build it, start the app, and give me the address so I can check it.
  3. Second thread. Without waiting for the first one, create another thread, again with the Worktree environment. Pick a different agent if you have one. The task:
    Add an Export button that saves all my habits and their checkmarks to a CSV file I can open in Excel. Show me a short plan first. Once I confirm, build it, start the app, and give me the address so I can check it.
  4. Watch. The sidebar shows which thread is working and which is waiting for your reply. Switch between them, approve the plans, answer the questions.
  5. Check each result separately. Each copy has its own address; the port numbers will differ. Don’t mix them up: the copy with the dark theme doesn’t have the export yet, and vice versa.
  6. Merge what’s ready. In each thread in turn:
    This task is done and approved. Commit it and merge this branch into the project's main branch. If it conflicts with other changes, stop and explain in plain language what the conflict is and what my options are.
  7. Check the main version. Go back to the main thread, start the app from the main folder, and make sure both improvements are there.
About conflictsIf two agents changed the same spot in the same file, git can’t decide on its own whose version is right when the second branch is merged. This is called a conflict, and it looks scarier than it is. The agent knows how to sort these out: ask it to explain what collided and to suggest a resolution. The best protection is to give parallel threads tasks that touch different parts of the app.
The thread menu in bb: Copy link, Pin, Mark unread, Notifications, Rename, Archive, Delete
The thread menu opens from the three-dot button next to the thread’s title. Archive removes the thread from the list, Pin keeps it at the top, and Notifications sets up notifications for this thread alone.

When you’re done, clean up after yourself. Finished threads can be archived, and after a while bb deletes their worktrees from disk. Archive only after merging: uncommitted changes in a deleted worktree can’t be recovered.

Which agent gets which task

Now that you have several agents, you have to decide who does what. I won’t give you a ready-made table saying “this one is better at interfaces, that one at data.” The balance shifts with every model release, and any such table is out of date within two months. Instead, here are principles that don’t go out of date.

TaskWho gets itWhy
Spec, plan, a hard bugYour main agent’s strongest model, with the reasoning level set to HighA mistake at this stage costs the most; this isn’t the place to economize
Routine work on an approved planThe default modelWhen it’s clear what to do, you don’t need a genius
Small changes: wording, colors, spacingA fast, lightweight model, or a free one in OpenCodeIt’s faster and doesn’t eat into your main usage limit
ReviewAn agent from a different companyAn independent view
Your main agent is stuckA different agent, in a new threadA different model makes different mistakes
You’ve hit your usage limitAny other agentThe work doesn’t stop

There are two ways to hand a task to another agent partway through. The simple one: open a new thread with a different agent and write “Continue the work started in the other thread. The current state is in the project files, and the task is such-and-such.” The convenient one: bb has a Hand off to new thread action. It creates a new thread that links to the original, so the new agent can read what was discussed.

This works because everything important lives in files, not in the agents’ heads: the spec is in SPEC.md, the rules are in AGENTS.md, and the current state is in the code and the git history. An agent is replaceable as long as the project is written down.

About OpenCode and free modelsWhat sets OpenCode apart is its choice of models. When the opencode agent is selected in the prompt box, the model list shows models from different companies: the ones you connected with the /connect command, and free ones such as DeepSeek V4.1 Flash Free, Big Pickle, MiMo, and Nemotron. They’re a fallback for when you’ve used up the limits on your main agents, and a way to avoid spending your subscription on small stuff. A practical setup: your main agent writes, and DeepSeek in OpenCode reviews or fixes wording and spacing for free. Keep the free models away from hard tasks: they make more mistakes and are worse at keeping track of a long context.

How many agents make sense

After a first success, it’s tempting to launch ten threads at once. Technically, bb lets you. In practice, you become the bottleneck.

Every parallel thread needs your attention at least three times: to set the task, to approve the plan, and to check the result. An agent writes code in minutes, but checking is still a human job, and it hasn’t gotten any faster. Three threads whose results you looked at carefully are worth more than ten you accepted without looking.

Some rules of thumb:

A word about long tasks. The agent doesn’t need you sitting next to it. Set the task, approve the plan, go to lunch: you’ll come back to a finished result or to the question the agent stopped on. Module 11 covers how to get notified about that on your phone and reply from there.

If you want moreAgents in bb can launch other agents themselves: one takes a big task, splits it into parts, hands them out to helpers in separate threads, and assembles the result. It’s a powerful mode, and one that burns through usage limits. Come back to it once you’re comfortable running two or three threads by hand.
Before you move on
  • I’ve created a thread with the Worktree environment
  • Two threads worked on different tasks at the same time
  • Both improvements are merged into the main version and work together
  • I’ve given a task to an agent other than my main one at least once

Review questions

What happens if two threads with different tasks work in the same project folder?

The agents change the same files at the same time and wreck each other’s work. Agents in different threads don’t know about each other. To keep them out of each other’s way, each needs its own copy of the project: a worktree.

What goes into a new worktree?

The project’s committed state; uncommitted changes aren’t included. The copy is made from the git history, which is why you need to commit before creating parallel threads.

What limits the number of agents working in parallel?

Your attention: every task has to be set and every result checked. Agents write fast, but checking is still a human job. Ten threads accepted without looking are worse than three you checked.

Why can you hand a task to a different agent partway through?

Because everything important is in the project files: spec, rules, code, history. An agent is replaceable as long as the project is written down. SPEC.md, AGENTS.md, and the git history are available to any agent in any thread.

This page covers a single module. The interactive version of the course has steps, quizzes, and checklists that save your progress.

Open this module in the course →
← 08. Safety net: history, review, rules 10. The agent as an assistant: skills, the browser, your files →

By Yury Kononov, Chief Technology Officer. The course is free and licensed under CC BY 4.0. Updated 2026-11-28. Contact the author: @ykononov.