Skip to content

Stop the stt_prompt dedupe at paste positions, not inside longer words - #455

Open
cipoklean wants to merge 1 commit into
AssemblyAI:mainfrom
cipoklean:fix/stt-prompt-dedupe-word-boundary
Open

cipoklean wants to merge 1 commit into
AssemblyAI:mainfrom
cipoklean:fix/stt-prompt-dedupe-word-boundary

Conversation

@cipoklean

Copy link
Copy Markdown

What & why

Fixes #454.

STTPrompt.withoutTurnsAlreadyEnding decided a history entry is already carried by the prior chunk with a bare hasSuffix — no check of what precedes the match. A dictated "he" was peeled from the history whenever the field in front of the caret ended in "the" (or "cat" in "concat", "a" in "data" — spelling letters into a field is a real dictation shape): the match follows a letter, where no paste can ever sit. The dedupe meant to stop one utterance reaching the model twice was instead dropping utterances that were never pasted there, silently degrading the continuity stt_prompt exists to carry.

A paste can only sit in three positions — the start of the field, after whitespace (the separator the paste itself carried, or the field's own), or abutting an opener the separator defers to. The peel now requires one of the three:

  • InsertionSeparator.endsInOpener is public (it is exactly the opener question, already answered in one place) and withoutTurnsAlreadyEnding consults it for the abutment case.
  • A match preceded by a letter or digit — or anything that is none of the three positions — is the tail of a longer word and the entry stays, so a coincidence can no longer cost the model a real utterance. The peel is conservative in both directions: anything ambiguous is kept as history, and duplicate context is the cheaper failure than missing context.

How it was tested

The logic is pure text work, so it was extracted verbatim into a standalone harness and exercised on Linux Swift 6.2.4 before committing: every genuine dedupe still collapses (pasted runs, field-opening paste, whitespace-separated paste, opener-abutting paste, straight-quote word-start openers, interrupted runs), and every word-boundary coincidence is now kept (he/the, cat/concat, a/data, end/append, art/start). Three regression tests added to STTPromptTests pin the contract: a history entry inside a longer word is still sent, a paste abutting an opener still collapses, a paste that opened the field still collapses.

On this Linux host (no macOS toolchain): scripts/check.sh --portable passes end to end, and swift-format lint --strict is clean on all three touched files. CI on macos-26 is the authority on the Swift build and test run.

  • scripts/check.sh passes (or CI will, if I'm not on a Mac)
  • I read AGENTS.md and this doesn't reintroduce anything deliberately removed
  • Docs updated if behavior changed

withoutTurnsAlreadyEnding peeled a history entry on a bare hasSuffix, so a
dictated "he" vanished whenever the field ended in "the" (or "cat" in
"concat"): the match followed a letter, where no paste can sit. A paste
only opens the field, follows whitespace, or abuts an opener, so the peel
now requires one of the three, with InsertionSeparator.endsInOpener gone
public to answer the opener question from BlurtAssemblyAI.

Closes AssemblyAI#454

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

STTPrompt dedupe drops a history entry that is merely the tail of a longer word in the field

1 participant