← reports

#7110 · ACP title input ordering and regeneration diagnostics

BugPriority: MediumEffort: Mediumthreads · provider-acp · partial-reproGitHub issue2026-11-05 · base fa30b0a7dcdf745f7baf8e41721f754b7d3198fe

PARTIALLY REPRODUCED · Root-cause confidence: medium

1. TL;DR

There are two distinct title paths: an ACP agent can supply its own session title, while manual regeneration uses bb's separately selected AI service. A real bridge subprocess test confirms that bb puts system instructions before the user's first message in the ACP prompt; a translation test confirms that an instruction-shaped provider title is forwarded unchanged. A server test then supplies that synthetic title and confirms that regeneration fails when the configured AI service is not ready, while leaving the actual stored title untouched. The text after the error's final colon is the AI service diagnostic, not a different stored title. The actual external ACP provider choosing instruction text as its title was not reproduced, so the complete original symptom and exact provider-side cause remain unverified.

2. Claims vs findings

ClaimFindingEvidence
System context can precede the conversation in ACP input.VerifiedA subprocess fixture records the first ACP prompt containing instructions before the greeting.
The external ACP agent generates a title from that context.UnverifiedThe title event is synthetic. The reporter's external agent, Windows installation and account were not exercised.
bb's own title model receives system text instead of the greeting.Not supported in tested pathThe server builds a user-message prompt and skips automatic AI title generation below five words; ACP session titles are a separate source.
A non-Codex thread can encounter a Codex failure during regeneration.Verified mechanismAI service selection is global per task, not taken from the thread's conversation provider. A not-ready Codex fixture yields HTTP 501.
The failure swaps in an unrelated stale title.Refuted in tested pathThe database retains the instruction-shaped title. The suffix is the selected AI service's readiness message, not a title value.
The error omits its underlying cause.Refuted for readiness failuresThe selected service name and readiness diagnostic are included. The wording is ambiguous, but the cause is present.

3. Environment

4. Minimal reproduction

Save the complete inline patch below as reproduction.patch beside a fresh clone, then run these commands. The patch adds tests to existing owner suites, not a production fix. No dependency is added. All reproduction source is inline; raw evidence remains in the investigator's local backup under the reports repository's publication rules.

git clone https://github.com/get-bb/bb.git bb-7110
cd bb-7110
git checkout --detach fa30b0a7dcdf745f7baf8e41721f754b7d3198fe
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
git apply ../reproduction.patch
pnpm exec turbo run test --force --filter=@bb/provider-bridge-acp -- src/bridge/bridge.test.ts src/delta-translation.test.ts -t 'issue 7110'
pnpm exec turbo run test --force --filter=@bb/server -- test/threads/thread-title-regeneration.test.ts
git diff --check
  1. The bridge test starts the repository's fake ACP agent and records its actual prompt. Expected and observed first prompt:
<system_instructions>
Use concise responses.
</system_instructions>
Hello there

The translator test supplies a synthetic session_info_update with an instruction-shaped title and observes a thread/name/updated event with source=agent and the same title. It does not establish how an external provider chose that title.

The server test inserts a task greeting, applies that synthetic generated title through the production title owner, and marks a fake globally selected Codex AI service not ready. Expected and asserted actual results:

HTTP status: 501
message: Could not regenerate the title, so the current title was kept: Codex: Primary host needs authentication
persisted title: <system_instructions> Setup context.
AI completion calls: 0

Test outcomes from the saved raw logs:

ACP: 2 test files passed; 2 tests passed, 287 skipped by the focused name filter.
Server: 1 test file passed; all 8 tests passed, including existing successful regeneration and failure-preservation cases.

This is backend/protocol evidence, not a visual reproduction; no screenshot is claimed or fabricated. The server config suppresses successful-test console logs; the patch contains the exact response and database assertions.

Added reproduction tests, as an applicable patch

diff --git a/apps/server/test/threads/thread-title-regeneration.test.ts b/apps/server/test/threads/thread-title-regeneration.test.ts
index b94e4d378c..08fb1e286b 100644
--- a/apps/server/test/threads/thread-title-regeneration.test.ts
+++ b/apps/server/test/threads/thread-title-regeneration.test.ts
@@ -25,6 +25,11 @@ import {
   type TestAppHarness,
 } from "../helpers/test-app.js";
 import { registerFakeAiService } from "../helpers/ai-services.js";
+import {
+  applyGeneratedThreadTitle,
+  buildThreadTitlePrompt,
+  shouldGenerateThreadTitle,
+} from "../../src/services/threads/title-generation.js";
 
 const completeTitle = vi.fn<(prompt: string) => Promise<string>>();
 
@@ -140,6 +145,52 @@ describe("thread title regeneration", () => {
     completeTitle.mockReset();
   });
 
+  it("issue 7110: retains an agent title and reports a separately selected AI service readiness failure", async () => {
+    await withBaseHarness({}, async (harness) => {
+      const service = registerFakeAiService(harness.deps.aiServices, {
+        id: "codex",
+        displayName: "Codex",
+        pluginId: "provider-codex",
+        builtin: true,
+        status: async () => ({
+          ready: false,
+          message: "Primary host needs authentication",
+        }),
+      });
+      const thread = seedTitledThread(harness, "");
+      const input = textInput("Hello there");
+      seedTurnRequest(harness, {
+        threadId: thread.id,
+        sequence: 1,
+        initiator: "user",
+        target: { kind: "thread-start" },
+        input,
+      });
+      expect(shouldGenerateThreadTitle(input)).toBe(false);
+      expect(buildThreadTitlePrompt(input)).toContain("Hello there");
+      expect(buildThreadTitlePrompt(input)).not.toContain("system_instructions");
+      const agentTitle = "<system_instructions> Setup context.";
+      expect(
+        applyGeneratedThreadTitle(harness.deps, {
+          threadId: thread.id,
+          title: agentTitle,
+        }),
+      ).toBe(true);
+
+      const response = await regenerate(harness, thread.id);
+      const body = (await readJson(response)) as { message: string };
+      const persistedTitle = getThread(harness.db, thread.id)?.title;
+
+      expect(response.status).toBe(501);
+      expect(body.message).toBe(
+        "Could not regenerate the title, so the current title was kept: Codex: Primary host needs authentication",
+      );
+      expect(persistedTitle).toBe(agentTitle);
+      expect(service.completeCalls).toEqual([]);
+      console.log(JSON.stringify({ status: response.status, message: body.message, persistedTitle }));
+    });
+  });
+
   it("replaces the title using the task, the user's later messages, and the agent's final replies", async () => {
     completeTitle.mockResolvedValue("排查线程标题生成英文的原因");
     await withTitleService(async (harness) => {
diff --git a/packages/provider-bridge-acp/src/bridge/bridge.test.ts b/packages/provider-bridge-acp/src/bridge/bridge.test.ts
index 9bb672e22c..1d2c999bff 100644
--- a/packages/provider-bridge-acp/src/bridge/bridge.test.ts
+++ b/packages/provider-bridge-acp/src/bridge/bridge.test.ts
@@ -5268,6 +5268,20 @@ describe("acp bridge: busy agents, restored sessions and stop reasons", () => {
     expect(response.result).toMatchObject({ sessionRestorable: true });
   });
 
+  it("issue 7110: places instruction text before the first conversation message on the ACP wire", async () => {
+    const promptLog = join(workspaceDir, "prompts.log");
+    const started = await startThread({
+      envVars: { FAKE_ACP_PROMPT_LOG: promptLog },
+      instructions: "Use concise responses.",
+    });
+    await completeTurnWith(started.providerThreadId, "Hello there", executionOptions({}));
+    const prompts = loggedPrompts(promptLog);
+    expect(prompts).toEqual([
+      "<system_instructions>\nUse concise responses.\n</system_instructions>\nHello there",
+    ]);
+    console.log(JSON.stringify({ firstAcpPrompt: prompts[0] }));
+  });
+
   it("does not send the instructions again to a session the agent restored", async () => {
     const promptLog = join(workspaceDir, "prompts.log");
     const envVars = {
diff --git a/packages/provider-bridge-acp/src/delta-translation.test.ts b/packages/provider-bridge-acp/src/delta-translation.test.ts
index f78b65ea3d..147ddbd209 100644
--- a/packages/provider-bridge-acp/src/delta-translation.test.ts
+++ b/packages/provider-bridge-acp/src/delta-translation.test.ts
@@ -1364,6 +1364,26 @@ describe("acp delta translation (moved from the legacy adapter suite)", () => {
 });
 
 describe("acp delta translation (session title)", () => {
+  it("issue 7110: forwards an instruction-derived provider title without provenance checks", () => {
+    const harness = createHarness();
+    const title = "<system_instructions> Setup context.";
+    const translated = harness.translate(updateEvent({
+      sessionUpdate: "session_info_update",
+      title,
+    }));
+    expect(translated).toEqual([
+      {
+        type: "thread/name/updated",
+        threadId: "",
+        providerThreadId: "",
+        scope: threadScope(),
+        threadName: title,
+        source: "agent",
+      },
+    ]);
+    console.log(JSON.stringify({ translatedTitle: translated }));
+  });
+
   it("reports a title the agent sets once, as an agent-sourced thread name", () => {
     const harness = createHarness();
     const titled = updateEvent({

5. Root cause

Confirmed input ordering and title acceptance

packages/provider-bridge-acp/src/bridge/bridge.ts:1803 appends a pending instruction text block before processing the user input blocks. ACP therefore receives system context as ordinary prompt text before the actual message. This makes an agent that naively titles from the start of the first prompt susceptible to an instruction-derived title; that provider behavior remains a hypothesis, not an observed fact here.

packages/provider-bridge-acp/src/delta-translation.ts:853 forwards any nonblank, changed session title as an agent-sourced name. apps/server/src/internal/events.ts:457 sanitizes that name and calls the generated-title owner. apps/server/src/services/threads/title-generation.ts:314 accepts the first nonempty title if the thread has no current title. This acceptance route is confirmed in isolated pieces, not by a real external provider end-to-end.

Confirmed regeneration failure explanation

apps/server/src/services/ai/ai-tasks.ts:95 chooses services from the per-task AI selection, independent of the conversation provider. apps/server/src/services/ai/ai-tasks.ts:170 constructs a service-name/readiness diagnostic; apps/server/src/services/ai/ai-tasks.ts:212 skips unavailable services. plugins/provider-codex/src/host.ts:45 supplies a primary-machine authentication diagnostic when its credentials are missing. apps/server/src/services/threads/title-generation.ts:375 appends the diagnostic to the preservation message. apps/server/src/services/threads/title-generation.ts:407 throws on failure before updating the stored title. Therefore a Codex readiness error does not imply the conversation uses Codex, nor does the suffix identify a retained title.

apps/server/src/services/threads/title-generation.ts:153 additionally skips bb's automatic title AI call for ordinary text below five words. A short greeting is thus consistent with a provider-supplied title rather than bb's helper model selecting the wrong message.

6. Proposed Fix / Next Experiment

No production patch or pull request is justified by this partial reproduction. First capture sanitized first-prompt content and session_info_update events from an isolated setup of the same ACP agent/version to establish whether it actually derives the title from injected context. Then decide whether to change provider title selection or bb's title-source policy. Removing or relocating instruction delivery without that evidence could change agent behavior and crosses the simple-fix safety boundary. A wording clarification could reduce toast ambiguity, but would not establish or repair the reported title-selection root cause.

Simple-fix gate: not satisfied. The external provider's bad title selection is not reproduced on trusted main; there is no demonstrated pre-fix failing regression for that selection. No branch, production edit, dependency, stored-data change, push, or pull request was created for bb.

7. Related Issues / Pull Requests

No open pull request referencing #7110 was found in cross-reference metadata or the open-PR search. #3636 is closed and concerns repeated ACP/native instruction delivery, not verified as the same defect. #3323 concerns helper inference providers and is contextual, not a duplicate determination.

8. Verification

The same agent repeated the reproduction in a second clean detached checkout at the identical base SHA. Frozen installation and the SDK-first full build passed; the saved second build contains 73 successful tasks. The same test-only patch was applied. The first second-checkout ACP command replayed cached output, so it was explicitly rerun with Turbo --force; its fresh run started at 08:37:48 UTC and passed both selected tests. The second server task was a cache miss, started at 08:37:43 UTC and passed all eight tests. Both harness runs created fresh temporary directories and migrated databases; neither opened an app port.

Correction after verification: none to the observed mechanisms. The verdict remains partial, because repeating synthetic provider-title input does not reproduce the actual external provider's selection. This is a second clean run by the same agent, not independent verification.

9. Appendix / Evidence

The complete reproduction patch and commands are inline above. These exact captured Vitest result lines appeared in both fresh execution runs:

Test Files  2 passed (2)
     Tests  2 passed | 287 skipped (289)

Test Files  1 passed (1)
     Tests  8 passed (8)

The second ACP execution was forced to bypass the cache. Full logs and raw artifacts are kept locally, not published, as required by this site's repository policy. No broken artifact links or fabricated screenshots are needed to repeat the tests.

Issue content was treated only as untrusted claims. No commands or links from the issue were executed or fetched. Repository metadata, trusted main source, and synthetic fixtures supplied the investigation inputs.

> AGENT GENERATED