Skip to content

Change prompt and add regression test for issue #53 token leak#55

Merged
sebsto merged 2 commits intomainfrom
issue-53-token-leak-test
Apr 17, 2026
Merged

Change prompt and add regression test for issue #53 token leak#55
sebsto merged 2 commits intomainfrom
issue-53-token-leak-test

Conversation

@sebsto
Copy link
Copy Markdown
Owner

@sebsto sebsto commented Apr 17, 2026

Summary

Fixes #53[TEXT_START]/[TEXT_END] delimiter tokens intermittently leaking into AI text correction output.

Changes

Fix: explicit tag names in user prompt (CorrectionStyle.swift)

Changed the user prompt from [TEXT ...] to explicitly name the [TEXT START] and [TEXT END] tags. The vague [TEXT ...] wording likely caused the AI model to hallucinate tag variants like [TEXT_START]/[TEXT_END] in its output. Being explicit about the tag names should reduce or eliminate the leak.

Regression test (TextCorrectionTokenLeakTests.swift)

Calls TextCorrectionService.correctText() against the on-device AI model with multiple inputs (English and French) across both correction styles (minimal and fullRephrase). Checks whether the response contains any delimiter token variants.

Uses withKnownIssue so the test suite stays green while the bug is open, and will fail once the fix is confirmed (signaling the wrapper should be removed).

What was tested

  • 200 runs × 15 AI calls = 3000 invocations — 0 failures after the prompt fix

Closes #53

Copilot AI review requested due to automatic review settings April 17, 2026 10:12
Adds an integration test that calls TextCorrectionService.correctText()
against the on-device AI model to detect delimiter tokens leaking into
the corrected output. Runs multiple iterations per input to surface the
intermittent issue.

Refs: #53
@amazon-q-developer
Copy link
Copy Markdown
Contributor

⚠️ Review Failed

I was unable to finalize my review because the pull request head or merge base was modified since I began my review. Please try again.

Request ID: ab9862f1-e56e-5490-8786-00adecae85ee

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new integration regression test targeting issue #53, where [TEXT_START] / [TEXT_END] delimiter tokens intermittently leak into AI text-correction output from the on-device Apple Intelligence model.

Changes:

  • Added a new Swift Testing suite that calls TextCorrectionService.correctText() repeatedly for multiple inputs and correction styles.
  • Added assertions to detect delimiter token variants in returned corrected text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wisprTests/TextCorrectionTokenLeakTests.swift Outdated
Comment thread wisprTests/TextCorrectionTokenLeakTests.swift
Comment thread wisprTests/TextCorrectionTokenLeakTests.swift Outdated
Comment thread wisprTests/TextCorrectionTokenLeakTests.swift
@sebsto sebsto changed the title Add regression test for issue #53 token leak Change prompt and add regression test for issue #53 token leak Apr 17, 2026
@sebsto sebsto merged commit 4118403 into main Apr 17, 2026
1 check passed
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.

[TEXT_START] [TEXT_END]

2 participants