Skip to content

backends: a Claude session titled from its first prompt shows the appended host-context block #3789

Closed

Description

@schlessera

Context

A Claude chat that has no summary yet takes its title from the raw first prompt. That prompt can carry the host-context block brain-kit appends to the user's words, so the block shows up in the session list.

  • prepare (packages/ui-sdk/src/server/session-prompt-context.ts:61-72) appends [Host context for this turn; advisory facts, never permission] … [End host context] to the user's text whenever a host fact changed. It keeps the original text separately (state.turns[id].original).
  • History replay uses the original, so the transcript is clean.
  • The list does not. listSessions uses s.customTitle || s.summary || s.firstPrompt (packages/ui-backend-claude/src/history.ts:69), and the transcript archive copies the same expression into its manifest (packages/ui-backend-claude/src/transcript-archive.ts:294). firstPrompt is the text that went over the wire, block included.

Observed on a hosted 0.44.0 install. GET /api/sessions returned 108 sessions. In 10 of them the title reads like Continue [Host context for this turn; advisory facts, never permission] sandbox: # Where files go in this turn **Profile: \governed`.** …`. Short first prompts ("Continue", a one-line correction) are the worst case: the host block is most of the title. The block also puts host sandbox guidance in front of anyone who sees the list.

Scope

  • When a title falls back to firstPrompt, strip the host-context block, on the live list and in new archive manifests. The block's delimiters are fixed and owned by session-prompt-context.ts. Export one function from there that removes the block, so the delimiter is never spelled twice. Alternatively, look up the stored original for that session.
  • Apply the same rule to already-archived manifests when they are listed (listArchivedSessions). Rewriting committed manifests is out of scope.
  • Check Pi's session list for the same fallback and fix it with the same function if it is affected.

Out of scope

Acceptance criteria

  • A session whose first prompt is "Continue" plus a host-context block lists with title "Continue". A history.ts test proves it and fails before the change.
  • An archived session whose manifest title contains the block lists without it.
  • A first prompt that contains the opening delimiter as user-typed text, with no closing delimiter, is left unchanged. Removal only takes a complete trailing block.
  • Host-context delimiter definitions stay owned by session-prompt-context.ts; title consumers use its helper or exact stored ownership and do not duplicate delimiter literals. A complete trailing block is removed while unmatched user-typed opening text is preserved.

Verification

  • bun run test packages/ui-backend-claude/tests (history and archive listing cases) and the session-prompt-context unit tests.
  • Mutation: return the raw firstPrompt, and the new title test fails.

Contract impact

None. ChatSession.title stays a nullable display string. Only its derived value is cleaned.

Bounded reproduction — 2026-11-09

Inspected source: 9c7eb25825fdad5f4485db0df472188805edb450; Bun 1.4.4 (38afee6c8), frozen lockfile, isolated temporary checkout, repository test wrapper and offline preload. Command: bun run test ./tmp/triage/new-issues.test.ts. A temporary keyless fixture used real sessionPromptContext(...).prepare("Continue", { sandbox: "Use the voyage scratch area." }), fed its wire text to the injectable SDK session metadata, and called real createHistory(...).listSessions(). The title was the complete wire text, including both host-context delimiters and the sandbox fact. TITLE_EXCLUDES_HOST_CONTEXT failed expecting "Continue". Only temporary fictional files and metadata were used. The fixture failed at the named behavioral assertion, after module loading succeeded. Temporary diagnostic fixtures are outside authored source; this triage changes no product code.

Triage 2026-11-09 at main 9c7eb25825fdad5f4485db0df472188805edb450: Recorded the bounded intended-assertion failure and clarified current source/verification. The existing p1 and 0.45.0 commitment are preserved. It remains standalone: the GitHub-tools epic does not own this backend correction, and no existing open epic owns its full deliverable.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: backendsAgentBackend implementations and the seam they share.
    priority: p1Scheduled into the current or next milestone.
    on Nov 9, 2026
  2. added this to the 0.45.0 milestone on Nov 9, 2026
  3. added
    area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 9, 2026
  4. self-assigned this
    on Nov 15, 2026
  5. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-fe97c28a. Branch: fix/3789-claude-session-title.

    Checking overlap with neighbouring Claude backend work; scoped to session title display.

  6. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Completed by PR #4022, squash a9bcdbd6734c1733390570e2a68c10afde3b00a9. Live and archived first-prompt titles omit a complete trailing host-context block; unmatched opening text remains intact. Provider prompts and stored transcripts are unchanged. Pi already takes the first line before the appended block.

    Failing-first and restored mutation evidence, 32 passing focused tests, build, and preflight are recorded in the PR. Candidate run 43758006657 passed. Automatic main push run 43760470794 passed all 17 jobs; each executing job checked out the actual squash. Issue and PR retain release milestone 0.45.0. No follow-up issues were filed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: backendsAgentBackend implementations and the seam they share.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.priority: p1Scheduled into the current or next milestone.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions