Skip to content

test: cover truncate_tokens start offset and no-op branches - #41

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789677905-truncate-tokens-tests
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789677905-truncate-tokens-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Closes a coverage gap flagged by a code scan: truncate_tokens was only exercised with start=0 and a text longer than max_tokens, leaving the offset slice and the already-within-limit return untested.

Adds two tests in tests/llm/test_llm_utils.py:

  • test_truncate_tokens_with_start: pins the exact window tokens[start:start+max_tokens] (start=2, max_tokens=3 -> " a simple test"), so an off-by-one at either boundary fails.
  • test_truncate_tokens_within_limit_returns_text_unchanged: asserts the else branch returns the original string byte-for-byte (no decode round-trip), including the exact-fit boundary len(tokens) == max_tokens.

Note the third assertion documents existing behavior that start only shrinks the window it compares against: truncate_tokens(text, max_tokens=4, start=2) returns the whole text (6 tokens) rather than the offset slice, since len(tokens) - start <= max_tokens.

No production code changed.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/949458399186449f8cd7a5b706135d59
Open in Devin Desktop: https://app.devin.ai/desktop/session/949458399186449f8cd7a5b706135d59?variant=devin

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

0 participants