Skip to content

fix(desktop): trim shipped task prompt under the 10k sync bound - #19038

Open
Jr-kenny wants to merge 2 commits into
BasedHardware:mainfrom
Jr-kenny:fix/task-prompt-fits-sync-bound
Open

Jr-kenny wants to merge 2 commits into
BasedHardware:mainfrom
Jr-kenny:fix/task-prompt-fits-sync-bound

Conversation

@Jr-kenny

@Jr-kenny Jr-kenny commented Sep 26, 2026 •

Copy link
Copy Markdown

Failure-Class: none

What changed

Fixes #11481 (prompt-reduction path)

TaskAssistantSettings.defaultAnalysisPrompt was 13,716 characters, above the 10,000 code-point bound shared with ASSISTANT_ANALYSIS_PROMPT_MAX_LENGTH on the backend. SettingsSyncManager.promptForSync therefore omitted the shipped default from every settings PATCH, so the task assistant prompt never synced.

This change compresses the shipped default to 5,538 characters while keeping the extraction workflow, search rules, public-channel guard, specificity and forgettability checks, deadline rules, and source taxonomy. Oversized user-authored prompts are still omitted rather than truncated.

APIClientAssistantSettingsTests now asserts the shipped default fits the bound and is included in sync, instead of asserting it is oversized and omitted.

No backend limit change and no deploy sequencing. Insight and memory defaults already fit.

Product invariants

  • Desktop settings sync still uses unicode code-point length against the backend bound.
  • User-authored prompts longer than the bound stay local and are never truncated.

How it was verified

  • Recomputed defaultAnalysisPrompt.unicodeScalars.count on the new literal: 5,538 ≤ 10,000.
  • Updated testShippedTaskPromptFitsBackendSyncContract to pin fit-and-sync for the shipped default and kept testOversizedCustomPromptIsOmittedWithoutTruncation for user-authored overflow.
  • Full macOS XCTest lane is on CI for this path.

Review in cubic

Compress defaultAnalysisPrompt so it fits ASSISTANT_ANALYSIS_PROMPT_MAX_LENGTH
and actually syncs. Oversized user prompts still omit rather than truncate.

Fixes BasedHardware#11481

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Jr-kenny - this is the right shape for #11481: the issue explicitly lists trimming the shipped default as an accepted alternative to raising the bound, and this keeps the backend limit, the client 10k constant, and the omit-don't-truncate protection for user-authored prompts all untouched. The compression itself is careful: comparing old and new literals section by section, the workflow, tool-use rules (search-before-extract, similarity > 0.8 duplicate/refine/already-done handling), both commitment patterns, the public-channel guard, specificity and forgettability checks, deadline rules, and the full source taxonomy all survive. Recomputing the compiled literal the way Swift strips closing-delimiter indentation gives 5,538 Unicode scalars <= 10,000, so promptForSync will now include the default in the settings PATCH.

Requesting changes for two test regressions and one description inaccuracy:

  1. desktop/macos/Desktop/Tests/TaskAssistantPromptTests.swift:47 - testDefaultPromptSkipsPublicChannelRequestsNotDirectedAtUser pins five exact phrases that no longer exist in the trimmed prompt ("CRITICAL FOR PUBLIC/GROUP CHANNELS", "merely observing a public channel", "cannot tell whether the request is directed at them", "otherwise clearly addressed to the user", "questions posted to the community at large"), so five XCTAssertTrue calls will fail. The guard behavior is preserved in the new "PUBLIC/GROUP CHANNELS:" section, so the fix is to re-pin the assertions to the new phrasing, e.g. "PUBLIC/GROUP CHANNELS", "visible evidence shows the user is directly involved", "If they are only observing, or you cannot tell, call no_task_found", "Do not extract broad community bug reports or feature requests".

  2. desktop/macos/Desktop/Tests/APIClientAssistantSettingsTests.swift:130 - testShippedDefaultIsOmittedFromSyncWithoutBlockingLaterHydration still asserts promptForSync(default) == nil ("the shipped default is over the bound, so it still cannot be sent"). After this PR the default fits, so promptForSync returns it and the XCTAssertNil fails. The scenario it guards (an oversized shipped default not blocking later hydration) is still worth covering for the legacy case - consider keeping it with a synthetic oversized "previous default" the way testPersistedPreviousShippedDefaultStillHydrates does, or retire it with a comment pointing there. The "shipped default is over the 10k bound" premise in the comment block at lines 93-102 is also stale now.

  3. The description says "Full macOS XCTest lane is on CI for this path", but all workflows on this head are still awaiting maintainer approval to run (first PR), so nothing has executed yet - worth softening so it doesn't read as executed evidence.

Non-blocking, for a maintainer to weigh: desktop/windows/src/main/assistants/tasks/prompt.ts documents itself as the "Verbatim Mac defaultAnalysisPrompt" and still carries the full 13k version, so the two platforms' task prompts now diverge for the first time; a follow-up port (or a note in #11481) would keep that parity comment honest.

Once the two test updates land, this should be in good shape.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added needs-tests PR introduces logic that should be covered by tests macOS labels Sep 26, 2026
Point the public-channel assertions at the compressed wording, and cover the
legacy oversized shipped default with a synthetic previous default so later
hydration is still pinned now that the current default fits the 10k bound.
@Jr-kenny

Copy link
Copy Markdown
Author

Pushed the requested test updates.

  1. TaskAssistantPromptTests now pins the public-channel guard against the compressed wording (PUBLIC/GROUP CHANNELS, directly-involved check, no_task_found when observing/unclear, no community bug reports).
  2. The hydration test is now testOversizedShippedDefaultIsOmittedFromSyncWithoutBlockingLaterHydration, using a synthetic oversized previous default. The current shipped default is covered by testShippedTaskPromptFitsBackendSyncContract as fitting and syncing.
  3. Softening the claim about CI below.

macOS XCTest has not run on this head yet (first-time workflow approval). The change is ready for CI once that runs.

@Git-on-my-level
Git-on-my-level dismissed their stale review September 27, 2026 05:29

Prior automated change request dismissed: the two failing test assertions were re-pinned to the compressed wording and the omitted-default hydration test was rewritten with a synthetic oversized previous default (commit 45fd946).

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution and removed needs-tests PR introduces logic that should be covered by tests labels Sep 27, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @Jr-kenny — the follow-up commit resolves all three items from the earlier change request:

  • TaskAssistantPromptTests.swift: the public-channel guard assertions are re-pinned to the compressed wording, and every pinned phrase matches the new literal (the "direct message" negative assertion correctly stays absent).
  • APIClientAssistantSettingsTests.swift: the hydration test is now testOversizedShippedDefaultIsOmittedFromSyncWithoutBlockingLaterHydration with a synthetic oversized previous default, which keeps the legacy pre-trim scenario covered while testShippedTaskPromptFitsBackendSyncContract pins the new fit-and-sync contract. The rewritten comment block reads correctly now.
  • Softening the CI claim was the right call.

Recomputing the compiled literal the way Swift strips closing-delimiter indentation gives 5,538 Unicode scalars ≤ 10,000, so promptForSync now includes the shipped default in the settings PATCH, and the omit-don't-truncate protection for oversized user-authored prompts stays intact (testOversizedCustomPromptIsOmittedWithoutTruncation still pins it).

One remaining verification step before merge: as a first-time contributor, the workflow runs need maintainer approval, so the macOS XCTest lane hasn't actually executed on this head yet — approving the workflow run is the last thing standing between this and CI evidence.

Non-blocking follow-up worth a note in #11481: desktop/windows/src/main/assistants/tasks/prompt.ts still labels itself the "Verbatim Mac defaultAnalysisPrompt" and carries the pre-trim 13k version, so the two platforms' task prompts now diverge for the first time; a small port would restore that parity claim.


by AI on behalf of David — leaving for human maintainer review for the merge decision and first-run workflow approval.

This branch has not been deployed

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

Labels

macOS positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shipped default task prompt (13.7k chars) exceeds the 10k assistant-prompt sync bound, so it never syncs

2 participants