Skip to content

Fit keyterms_prompt to the documented 8000-character cap - #458

Open
cipoklean wants to merge 1 commit into
AssemblyAI:mainfrom
cipoklean:fix/keyterms-cap-8000
Open

cipoklean wants to merge 1 commit into
AssemblyAI:mainfrom
cipoklean:fix/keyterms-cap-8000

Conversation

@cipoklean

Copy link
Copy Markdown

What & why

Fixes #453.

KeyTerms.characterCap was 2048, documented in-code as "the cap the API places on config.keyterms_prompt". The reference says 8000 characters in all four of its tellings (the /v1/transcribe/live reference, the prompting-and-keyterms guide, the quickstart, the buffered /v1/transcribe), termCap's own docstring ten lines below already quoted the correct figure back, and the first-party SDKs enforce the limit client-side at the same value — maxKeytermsPromptLength = 8000 in both services/dictation and services/sync of assemblyai-node-sdk. The repo's own history says where 2048 came from: it was the cap llm_instruction carried at the time (StyleProfileStore.swift, CleanupInstruction.swift), reused for the wrong field — exactly the failure mode the docstring warns about for stt_prompt.

The cost was silent vocabulary loss: a key term list between 2048 bytes and the documented cap was truncated by KeyTerms.fitted — terms the user typed dropped from boosting, no feedback anywhere — though the API would have accepted them.

The change is the number alone. The byte counting stays as it was: the documented unit is "characters", unmeasured against the endpoint for this field, and bytes can only overestimate a multi-byte term's cost, so the fitted list can never 400 the request. If a measurement ever shows the endpoint counts scalars the way stt_prompt does, the conservative reading can be revisited on evidence rather than inference.

How it was tested

  • The pinned-value test in KeyTermsTests now pins 8000; the rest of that suite (fit-to-cap, whole-terms, term-cap independence, inclusive boundary) is value-independent and exercises the new figure.

  • scripts/check.sh --portable green end-to-end on this Linux host; swift-format lint --strict clean on every touched file. 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

KeyTerms borrowed 2048 — the cap llm_instruction carried at the time —
for a field the reference documents at 8000 characters in all four of
its tellings, and which the first-party SDKs enforce client-side at the
same value. Lists between the two were silently truncated: terms the
user typed were dropped from boosting though the API would accept them.
The byte counting stays — the documented unit is characters, unmeasured,
and bytes can only overestimate.

Closes AssemblyAI#453

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.

KeyTerms fits keyterms_prompt to 2048 bytes; the reference documents 8000 characters

1 participant