Skip to content

[codex] strengthen manager prompt guidance and thread-storage links - #13

Merged
SawyerHood merged 4 commits into
mainfrom
bb/compare-middleman-manager-prompt-thr_khy8hhi3pz
May 15, 2026
Merged

SawyerHood merged 4 commits into
mainfrom
bb/compare-middleman-manager-prompt-thr_khy8hhi3pz

Conversation

@SawyerHood

@SawyerHood SawyerHood commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Strengthen the manager prompt's delegation-first operating contract.
  • Add clearer manager user-communication guidance and anti-polling guidance for child thread progress checks.
  • Document full absolute-path Markdown links for manager deliverables.
  • Allow thread timeline Markdown links to files inside the current manager thread's thread-storage folder to open in the manager storage preview tab.
  • Keep links to other threads' storage paths rejected, while preserving existing workspace file-link behavior.
  • Regenerate the templates registry for the prompt change.

Validation

  • node packages/templates/scripts/generate-templates.mjs
  • git diff --check
  • pnpm exec turbo run test --filter=@bb/templates
  • pnpm exec turbo run typecheck --filter=@bb/app
  • pnpm exec turbo run test --filter=@bb/app -- src/lib/thread-local-file-links.test.ts

Note: the first templates test attempt failed because dev dependencies were not installed under NODE_ENV=production; after installing dev dependencies with CI=true NODE_ENV=development pnpm install --frozen-lockfile --prod=false, the targeted test passed.

@SawyerHood SawyerHood changed the title [codex] strengthen manager prompt guidance [codex] strengthen manager prompt guidance and thread-storage links May 15, 2026
@SawyerHood
SawyerHood marked this pull request as ready for review May 15, 2026 23:04
@SawyerHood
SawyerHood merged commit bd87aac into main May 15, 2026
1 check passed
ymichael added a commit that referenced this pull request Nov 5, 2026
## Human comments

## What was wrong

Merge, Mark ready and Convert to draft did two lookups to find a pull
request bb already had. First, `requireActionTarget` always ran an
uncached branch discovery (`loadPullRequest(env, null, true)`: git
config reads, then a GraphQL search by head branch). Then `act` ran `gh
pr merge` with no selector, after reading the branch config again. With
no selector, gh resolves the PR from the branch itself: five more git
processes (`remote -v`, two `config --get-regexp`, `symbolic-ref`,
`rev-parse @{push}`) and its own GraphQL search by branch. Each git
process is slow in `~/Projects/bb` (about 4.5k branches, a 10k-line
`.git/config`). This is finding #13 in the Nov 4 hot-path audit ("Merge:
precheck by URL and pass it to gh").

## What changed

Only `plugins/github-pr-status`. This is rebased on #7071, which made
`views` take `known: { url, branchName }` and return the workspace's
`refs`.

- `server.ts`: the action precheck passes the PR URL the store already
holds as `known`. It still bypasses caches, so state and mergeability
are checked fresh. The precheck now gets `refs` back from its own
`views` result. It then rediscovers by branch when the PR has merged or
closed, or when its `headRefName` isn't `refs.branchName` from that same
read. A stale stored URL is therefore never acted on. For example, after
a branch switch, a refused Mark ready updates the plugin's branch map
without touching the stored URL, and the next Merge would otherwise act
on the old branch's PR. A fork PR whose upstream branch has a different
name never matches the local branch, so it always rediscovers. That
costs main's lookup plus one URL read, and still acts on the right PR.
With no stored URL, the precheck discovers by branch, as before. `act`
receives the URL of the PR that passed the precheck.
- `contract.ts` / `host.ts` / `host/git-host.ts`: `act` takes a required
`url` and runs `gh pr merge|ready <url> …`. The host no longer reads the
current branch or the upstream config for actions.
`runPullRequestActionForCurrentBranch` becomes `runPullRequestAction`.
- One visible change: an action from a detached workspace now fails in
the precheck with "No pull request found" instead of the host's "Cannot
update pull request from a detached workspace".
- No `HOST_DAEMON_PROTOCOL_VERSION` bump and no plugin SDK change. `act`
is this plugin's own host contract, and the server ships the host
artifact for each plugin generation.
- README sentence on actions updated.

## How you verified

**Real data**: the `~/Projects/bb` worktree for this PR's own branch
(open PR #7070), measured on origin/main after #7071 against this
branch. The plugin's real host entry ran under
`experimental_createHostEntryHarness`, making the same `views` → `act`
calls the server makes for a merge. A `gh` shim on `PATH` rewrote `gh pr
merge|ready <args>` into `gh pr view <same selector> --json <the fields
gh pr merge fetches>`. That exercises gh's PR finder without merging.
The merge mutation itself is the same on both sides and is not in these
numbers. Three interleaved rounds of 15 per side ran at load average
8–11.

| per merge | main (after #7071) | branch |
|---|---|---|
| git processes | 12 | 3 |
| gh processes (GraphQL round trips) | 2 | 2 |
| precheck p50 (n=45) | 853 ms | 767 ms |
| act, excluding the mutation, p50 (n=45) | 614 ms | 433 ms |
| total p50 / mean (n=45) | 1494 / 1510 ms | 1188 / 1252 ms |

Per-round total p50, main → branch: 1552 → 1242, 1466 → 1170, 1424 →
1188 ms.

What remains is GitHub latency: one GraphQL read for the precheck plus
gh's own read before the mutation.

**Tests**: `pnpm exec turbo run test typecheck lint
--filter=bb-plugin-bb--github-pr-status` passes (179 tests). New server
tests use a fake host that applies the real `views` rule: URL read only
when `known.branchName` matches the workspace branch.
- A merge after a load prechecks with `known` set to the stored URL and
branch, and passes that URL to `act`.
- When the stored PR has closed and the branch has a newer PR, the newer
PR's URL is used.
- Branch switch, then a refused Mark ready, then Merge: the stored URL
points at an open PR for another branch, so the action must go to the
current branch's PR. Without the head-branch check this test fails,
because it acts on pull/6 instead of pull/7.
- Host tests assert `gh pr ready|merge <url>` args, including from a
fork-tracking workspace.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael pushed a commit that referenced this pull request Nov 25, 2026
…lability read (#8187)

## Human comments

## What was wrong

A nested bb whose Account Pooler proxies to a parent pool decides per
turn whether it can route through the parent, using `ParentAvailability`
in `plugins/account-pool/src/parent-pool.ts`. `load()` gives the
parent's `/availability` 2 s, and on any error or non-OK status returns
`UNAVAILABLE_POOL`. `get()` caches that result for the full 30 s TTL,
the same as a good answer. So one slow read from a busy parent takes the
child off the pool for 30 s, and every turn that starts in that window
runs with no pool credentials. On a child with no Claude login of its
own, Claude Code answers `Not logged in · Please run /login` and
Provider Retry skips the turn as not retryable. On one child this
happened three times in a day, each time the parent's host was under
heavy load.

## What changed

- `plugins/account-pool/src/parent-pool.ts`: `ParentAvailability`
remembers the last good availability.
- A failed read keeps serving it, and the next read is tried after 5 s
instead of 30 s.
- Once reads have failed for 60 s in a row, the parent is reported
unavailable and that answer is cached for the normal TTL, as before. A
parent that has never answered is reported unavailable, and the read is
retried after 5 s.
  - The read timeout goes from 2 s to 5 s.
- `plugins/account-pool/src/parent-pool.test.ts`: three cases, all of
which fail on `main`:
  - one failed read keeps the last good value and retries after 5 s;
- a parent that stays down is reported unavailable after 60 s, then
cached for the TTL;
  - a failed first read is retried after 5 s.
- No wire, CLI or doc changes.

## How you verified

- New tests on `main`'s `parent-pool.ts`: the 3 new tests fail with
`expected { claude: false, codex: false } to deeply equal { claude:
true, codex: false }`, and the other 13 pass. With the change: 16/16.
- After the final commit: `pnpm exec turbo run typecheck lint test
--filter=bb-plugin-account-pool --force` passed 10/10 tasks, with 14
test files and 402 tests passing. Lint reported 3 warnings, all in
`app.tsx`, which this PR does not touch. `pnpm exec turbo run
lint:type-aware --filter=bb-plugin-account-pool --force` passed 7/7
tasks with 0 warnings. `pnpm exec turbo run prepare:bundled
--filter=bb-plugin-account-pool` passed 7/7 tasks. `oxfmt --check`
passes on both files.
- Standalone reproduction with real HTTP and the real clock.
`ParentAvailability` uses the real `fetch` and the shipped TTL and
timeouts against a local HTTP parent, and one `get()` per second stands
in for a turn start. `main` and this branch ran side by side.

  One slow answer (request #2 answers in 8 s, then normal), on `main`:

  ```
  [  0.0s] parent: request #1 -> 200 {claude:true}
  [  0.1s] child:  turn start -> ROUTED (claude via parent pool)
  [ 30.2s] parent: request #2 answering in 8s
[ 32.2s] child: warn could not read parent availability: The operation
was aborted due to timeout
[ 32.2s] child: turn start -> NOT ROUTED (turn runs with no login) after
waiting 2003ms
  [ 62.3s] parent: request #3 -> 200 {claude:true}
  [ 62.3s] child:  turn start -> ROUTED (claude via parent pool)
  summary: 43 turn starts routed, 30 not routed, 3 parent requests
  ```

  With the change:

  ```
  [  0.0s] parent: request #1 -> 200 {claude:true}
  [  0.1s] child:  turn start -> ROUTED (claude via parent pool)
  [ 30.2s] parent: request #2 answering in 8s
[ 35.2s] child: warn could not read parent availability: The operation
was aborted due to timeout
[ 35.2s] child: turn start -> ROUTED (claude via parent pool) after
waiting 5003ms
  [ 40.2s] parent: request #3 -> 200 {claude:true}
  [ 70.4s] parent: request #4 -> 200 {claude:true}
  summary: 70 turn starts routed, 0 not routed, 4 parent requests
  ```

  A parent that stays down (503 from 25 s on), on `main`:

  ```
  [  0.0s] parent: request #1 -> 200 {claude:true}
  [  0.1s] child:  turn start -> ROUTED (claude via parent pool)
  [ 30.2s] parent: request #2 -> 503 (down)
[ 30.2s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 30.2s] child:  turn start -> NOT ROUTED (turn runs with no login)
  [ 60.4s] parent: request #3 -> 503 (down)
[ 60.4s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 90.5s] parent: request #4 -> 503 (down)
[ 90.5s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [120.7s] parent: request #5 -> 503 (down)
[120.7s] child: warn could not read parent availability: parent
availability returned HTTP 503
  summary: 30 turn starts routed, 100 not routed, 5 parent requests
  ```

With the change, the child keeps routing for 60 s after the first
failure, then reports the parent unavailable and goes back to reading
every 30 s:

  ```
  [  0.0s] parent: request #1 -> 200 {claude:true}
  [  0.1s] child:  turn start -> ROUTED (claude via parent pool)
  [ 30.2s] parent: request #2 -> 503 (down)
[ 30.2s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 35.2s] parent: request #3 -> 503 (down)
[ 35.2s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 40.2s] parent: request #4 -> 503 (down)
[ 40.2s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 45.3s] parent: request #5 -> 503 (down)
[ 45.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 50.3s] parent: request #6 -> 503 (down)
[ 50.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 55.3s] parent: request #7 -> 503 (down)
[ 55.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 60.3s] parent: request #8 -> 503 (down)
[ 60.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 65.3s] parent: request #9 -> 503 (down)
[ 65.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 70.3s] parent: request #10 -> 503 (down)
[ 70.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 75.3s] parent: request #11 -> 503 (down)
[ 75.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 80.3s] parent: request #12 -> 503 (down)
[ 80.3s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 85.4s] parent: request #13 -> 503 (down)
[ 85.4s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 90.4s] parent: request #14 -> 503 (down)
[ 90.4s] child: warn could not read parent availability: parent
availability returned HTTP 503
  [ 90.4s] child:  turn start -> NOT ROUTED (turn runs with no login)
  [120.5s] parent: request #15 -> 503 (down)
[120.5s] child: warn could not read parent availability: parent
availability returned HTTP 503
  summary: 90 turn starts routed, 40 not routed, 15 parent requests
  ```

<details><summary>repro.mts (run from the repo root as
<code>node_modules/.bin/tsx repro.mts
$PWD/plugins/account-pool/src/parent-pool.ts
slow-once|down</code>)</summary>

  ```ts
  import { createServer } from "node:http";
  import type { AddressInfo } from "node:net";
  
const [modulePath, scenario] = process.argv.slice(2) as [string,
"slow-once" | "down"];
  const { ParentAvailability } = await import(modulePath);
  
  const TOKEN = "vqMIj4xUiI3PyvKS2SllSKHsOfxLF_sAZwzNAAvV9TQ";
  const started = Date.now();
const t = () => ((Date.now() - started) / 1000).toFixed(1).padStart(5);
  let request = 0;
  
  const server = createServer((req, res) => {
    request += 1;
    const n = request;
    const elapsed = (Date.now() - started) / 1000;
    if (req.headers["x-bb-account-pool-token"] !== TOKEN) {
      res.writeHead(401).end();
      return;
    }
    const answer = () => {
      res.writeHead(200, { "content-type": "application/json" });
      res.end(JSON.stringify({ claude: true, codex: false }));
    };
    if (scenario === "slow-once" && n === 2) {
      console.log(`[${t()}s] parent: request #${n} answering in 8s`);
      setTimeout(() => { if (!res.destroyed) answer(); }, 8_000);
      return;
    }
    if (scenario === "down" && elapsed > 25) {
      console.log(`[${t()}s] parent: request #${n} -> 503 (down)`);
      res.writeHead(503).end();
      return;
    }
    console.log(`[${t()}s] parent: request #${n} -> 200 {claude:true}`);
    answer();
  });
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1",
resolve));
  const { port } = server.address() as AddressInfo;
  
  const availability = new ParentAvailability({
parent: { baseUrl:
`http://127.0.0.1:${port}/api/v1/plugins/account-pool/http`, token:
TOKEN },
    fetch,
    now: Date.now,
    onError: (error: unknown) =>
console.log(`[${t()}s] child: warn could not read parent availability:
${error instanceof Error ? error.message : String(error)}`),
  });
  
  const durationS = scenario === "slow-once" ? 75 : 130;
  let last: string | null = null;
  let routed = 0;
  let unrouted = 0;
  while ((Date.now() - started) / 1000 < durationS) {
    const before = Date.now();
    const value = await availability.get();
    const waited = Date.now() - before;
    if (value.claude) routed += 1; else unrouted += 1;
const state = value.claude ? "ROUTED (claude via parent pool)" : "NOT
ROUTED (turn runs with no login)";
    if (state !== last || waited > 500) {
console.log(`[${t()}s] child: turn start -> ${state}${waited > 500 ? `
after waiting ${waited}ms` : ""}`);
      last = state;
    }
    await new Promise((r) => setTimeout(r, 1_000));
  }
console.log(`summary: ${routed} turn starts routed, ${unrouted} not
routed, ${request} parent requests`);
  server.close();
  process.exit(0);
  ```

  </details>

- **Not checked:** an isolated nested bb against a slow parent bb end to
end. The reproduction drives the same class the server constructs, with
the same options except `onError`.

Fixes #8188

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant