Skip to content

Fix thread title generation truncating task context - #4827

Closed
its-rosetta wants to merge 1 commit into
get-bb:mainfrom
its-rosetta:fix/thread-title-full-prompt
Closed

its-rosetta wants to merge 1 commit into
get-bb:mainfrom
its-rosetta:fix/thread-title-full-prompt

Conversation

@its-rosetta

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

buildThreadTitlePrompt reused the fallback title's 80-column display limit to truncate the task sent to the AI title service. Details later in the first request disappeared before inference. For example, a request to show a plan graph's burndown chart was reduced to:

For the plan graph tooling, can we show in the background of the plan graph v...

The word "burndown" and the completion-history requirements occur after that cutoff. The title service needs that context to identify the requested work.

What changed

  • Build the title-generation prompt from the complete cleaned task text, including the full command text when a prompt contains only an invoked command.
  • Rename the private truncation helper to clampTitleFallback and keep it confined to fallback title derivation. Fallback labels still fit 80 display columns; generated titles still fit 48.
  • Update the template's variable description and cover long task text, wide Unicode text, supplementary Unicode characters, and long bare command names in the title-service integration tests.

How you verified

The four regression cases fail against the original implementation. With this change, all 45 tests across the title-generation unit and integration suites pass, including the existing fallback-width and generated-title checks.

pnpm exec turbo run test --filter=@bb/server --env-mode=loose -- test/threads/title-generation.test.ts test/threads/generated-thread-titles.test.ts
pnpm exec turbo run typecheck --filter=@bb/server --env-mode=loose
pnpm exec oxfmt --check apps/server/src/services/threads/title-generation.ts apps/server/test/threads/generated-thread-titles.test.ts packages/templates/src/templates/generate-thread-metadata.md

Verification used a fresh upstream checkout with a frozen lockfile. npm_config_cache pointed to a private writable cache for native test dependencies.

AGENT GENERATED

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thanks @its-rosetta for the PR. This repo needs approval before a PR. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ) and explain what you want to open a PR for and why. A maintainer then adds you to the allow list. This PR now closes on its own. Reopen it or open a new one after approval.

@github-actions github-actions Bot closed this Oct 3, 2026
brsbl added a commit that referenced this pull request Oct 4, 2026
## Human comments

## What was wrong

Thread title generation sent the AI title service the same 80-column
string bb uses as the fallback title, so the task was cut to 80 display
columns before inference. This has been true since title generation
moved to the templates package in March; #3887 kept the clamp when it
split out invoked commands. Anything after the first ~80 characters
never reached the model, so it guessed. In [Cole's #bugs
report](https://discord.com/channels/1522478522332090528/1556018286377041980),
the model only got this:

```text
For the plan graph tooling, Can we show in the background of the plan graph v...
```

The thread was titled "Add back-button navigation to plan graph tools",
even though the request was for a burndown chart.

## What changed

- `apps/server/src/services/threads/title-generation.ts`: the title
service now receives the full cleaned task (from Cole's #4827, which was
auto-closed by the contributor allowlist). It is capped at 4000 display
columns so a huge paste can't make titling slow or expensive. Fallback
titles still fit 80 columns, and generated titles still fit 48.
- `generate-thread-metadata.md`: updated the `cleanedPrompt` variable
description.
- Tests: added the burndown regression, a test for the 4000-column cap,
wide/supplementary Unicode cases, and a long bare skill name.

## How you verified

Remote CI (`@bb/server` title-generation suites). The new burndown and
long-skill-name cases fail on `main`, where the task is cut at 80
columns. The cap test covers a 10,000-character paste.

Original fix by @its-rosetta in #4827.

BB-Thread-ID: thr_a4y66pq7d2

> AGENT GENERATED

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

---------

Co-authored-by: its-rosetta <267385802+its-rosetta@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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