Skip to content

Preserve arbitrary chat text across slash, paste, and naming boundaries #441

Closed

Description

@santoshkumarradha

What happened

On 2026-09-02, dev@09f1b3df, a real v3 chat task started from a folded multi-line paste appeared in the task rail as:

paste 1

The taskname call completed in 385 ms on deepseek/deepseek-v4-flash-0731; it received the full request, but the shared name cleaner accepted the paste transport label as a finished name. The task itself was admitted about 16 seconds later, so this was neither missing context nor a blocking name call.

The same audit found related text-boundary failures:

  • every line beginning with / is consumed by the command dispatcher, so /api/v1 returns 500, /user, or /Users/alice/repo fix this never reaches chat or task routing;
  • folded paste contents are not unfolded before inline /task, inline /standing, or a picked harness, so those doors receive [paste 1 · N lines] instead of the person's text;
  • paste expansion uses textual ReplaceAll, so a literal lookalike such as [paste 1 · 4 lines] elsewhere in the same draft is also replaced and the person's text is mutated;
  • the session-title role runs synchronously after EventTurnDone, leaving the session marked running while a cheap naming call is still in flight;
  • slash command tokenization only splits on an ASCII space, so a tab or newline after a valid command word is misclassified.

No core transport escaping defect was found: once submitted, quotes, slashes, backslashes, Unicode, code fences, $, and @ are carried as ordinary Go strings.

Replication

Deterministic (no model).

From a clean checkout of dev@09f1b3df:

go test ./internal/session -run 'Test.*(TaskName|Title)' -count=1
go test ./internal/tui3 -run 'Test.*(Slash|Paste|Task|Harness|Standing)' -count=1

The current pure helpers accept cleanTaskName("paste 1:") == "paste 1". A fake-agent v3 app consumes /api/v1 returns 500 as unknown command: /api/v1 instead of submitting it. A folded paste followed by an inline /task marker hands the fake task door the visible chip token rather than the fenced paste contents.

Field (real models).

With OPENROUTER_API_KEY set, run the isolated tagged regression added by the fix:

go test -tags e2e -run '^TestTaskNamingE2E$' -count=1 -timeout 8m -v ./internal/e2e/

It must pin the talk, shaper, task-name role, and tier fallbacks to exact model deepseek/deepseek-v4-flash-0731, start one disposable task from a paste-wrapped path-heavy request, observe a meaningful name, and cancel the task immediately. Expected cost is below one cent and expected wall time is under two minutes.

Where

  • enterLine and slash in internal/tui3/input.go and internal/tui3/app.go
  • homeEnter and homeView.runLabel in internal/tui3/home.go
  • composed / unfoldPastes in internal/tui3/pastechip.go, plus the task, standing, and picked-harness send doors
  • cleanTitle, maybeTitle, taskNameNeeded, cleanTaskName, and nameAhead in internal/session/title.go and internal/session/taskname.go
  • model-proposed task title admission in internal/session/task.go, and planner-node validation in internal/orchestrate
  • slash command parsing in internal/tui3/app.go

The fix

Make the syntax boundary explicit and shared:

  • only a recognized slash command or alias owns a leading slash; unknown slash-prefixed input is ordinary text and is submitted unchanged on chat and Home;
  • real dropped files and real workspace folders retain their existing meanings, and known commands continue to dispatch;
  • every route that speaks for the composer consumes the same composed payload exactly once, unfolding paste chips while retaining the compact shown text;
  • paste unfolding replaces only the tracked chip occurrence, never identical literal text the person typed;
  • naming sees the meaningful payload rather than transport scaffolding, and the shared cleaner rejects generic ordinal labels such as paste 1, task 2, part 3, step 4, and node 5 without rejecting semantic names such as issue 252 check or phase 2 rollout;
  • shaper titles, propose_task titles, and orchestrated planner-node titles pass the same validity law before they can suppress asynchronous naming;
  • a rejected ahead name falls through asynchronously to one retry from the shaped summary and brief;
  • session naming runs after the first turn without keeping the session in its running/steering state;
  • command splitting recognizes Unicode whitespace while preserving the argument text apart from documented outer trimming.

Acceptance

  • e2e: A real deepseek/deepseek-v4-flash-0731 run receives a paste-wrapped request containing paths, quotes, backslashes, Unicode, $, and @; the task is admitted without waiting for naming and its persisted/published title becomes a meaningful two- or three-word label, never a paste/task ordinal.
  • e2e: Through the fake-agent v3 chat and Home doors, /api/v1 returns 500, /user, // literal, and /Users/alice/repo fix this are submitted exactly once and unchanged; /help, a command alias, a real dropped file, and a real workspace folder keep their existing behavior.
  • e2e: Folded paste contents reach inline /task, inline /standing, and a picked harness in full, while the visible transcript/card retains the compact paste chip and the paste is consumed exactly once.
  • Unit: A literal string identical to a visible paste token remains literal when a real paste chip is unfolded elsewhere in the same draft.
  • Unit: Generic ordinal names and paste/fence scaffolding are rejected or removed consistently by session, task, shaper, propose_task, planner-node, resume-healing, and ahead-name paths; semantic numbered names remain valid, and a rejected ahead result causes exactly one non-blocking fallback rename persisted to the checkpoint.
  • Unit: A blocked session-title provider cannot keep the session in running/steering state after the turn is done; the title may land and persist later, exactly once.
  • Unit: /task arguments containing tabs/newlines, absolute paths, spaces, quotes, backslashes, Unicode, $, and @ reach StartTask byte-for-byte apart from documented outer trimming.
  • The chat manual explains that only recognized leading slash words execute and that unrecognized leading slash text is sent as prose. The change entry invalidates the former all-leading-slashes-are-commands rule.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added
    bug
    area:chat
    area:session
    on Sep 2, 2026
  2. santoshkumarradha commented on Sep 2, 2026

    @santoshkumarradha
    MemberAuthor

    Additional race found by the required real-provider regression:

    An immediate task cancellation could land after runFrontier published TaskRunning but before runTaskNode installed its cancellation handle. Cancel finalized the apparently handle-less task and closed node.done; the already-scheduled runner then continued, overwrote the terminal state, and TaskGraph.complete closed the channel again, panicking with close of closed channel.

    The fix makes cancellation-handle installation the lifecycle ownership boundary. If cancellation wins, the booked lane is returned and the late runner exits before work; if the runner wins, cancellation cuts its context and the runner remains the sole finalizer. A deterministic barrier test repeats the pre-handle race under -race.

    The paid E2E is now sequential so it proves both real-wire contracts without making them contend: one exact paste 1 task is immediately cancelled but must asynchronously rename and persist; a second pre-named task sends the same path/quote/backslash/Unicode/$/@ document to the real worker, which must echo the hostile literal exactly.

  3. santoshkumarradha commented on Sep 2, 2026

    @santoshkumarradha
    MemberAuthor

    Landed in #483 (dev@5e0fa6b9).

    The apparent provider hang was not one deadlock. The audit isolated three independent lifecycle failures:

    1. Session/task naming work was not fully detached and owned, so it could keep foreground state alive or return after session shutdown.
    2. A task cancelled between publication and cancellation-handle installation could be finalized by both cancellation and the runner.
    3. On the exact OpenRouter model, an unasked reasoning pass consumed all 32 naming output tokens and returned no visible name. Naming now requests reasoning off as a correctness requirement; an explicit configured tier suffix still wins and survives a catalog-silent model.

    The merged regression suite covers task/session naming ownership, immediate-cancel runner ownership, arbitrary slash/path/paste text, every paste lifecycle/send door, and provider-wire effort precedence. The real tagged OpenRouter E2E passed twice after the final fix. The final rebased run admitted the cancelled task in 17 ms, asynchronously persisted narrow path audit, and had a second deepseek/deepseek-v4-flash-0731 worker echo the hostile literal exactly ($0.003420, 13.56 s).

    PR CI passed: required gate 2m44s; full touched-package job 13m20s.

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

Metadata

Metadata

Labels

area:chatarea:sessionbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions