Skip to content

docs: stop the custom LLM example at the earliest stop word - #8806

Open
Felix Shi (shi-felix) wants to merge 3 commits into
crewAIInc:mainfrom
shi-felix:docs/stopword-earliest-match
Open

Felix Shi (shi-felix) wants to merge 3 commits into
crewAIInc:mainfrom
shi-felix:docs/stopword-earliest-match

Conversation

@shi-felix

@shi-felix Felix Shi (shi-felix) commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

The manual stop-word example in the custom LLM guide cut at the first entry in self.stop that appeared in the response, not at the earliest match. Reordering the stop list therefore changed the output, and it disagreed with BaseLLM._apply_stop_words, which the same guide points readers toward.

Fixes #8002.

Changes

  • docs/edge/en/learn/custom-llm.mdx: the example now collects the match positions and cuts at the smallest one, then .strip()s — the same behaviour as BaseLLM._apply_stop_words. A short paragraph says why the order no longer matters and why the whitespace is trimmed.
  • docs/edge/ko/learn/custom-llm.mdx: the same change in the Korean guide.
  • lib/crewai/tests/test_custom_llm.py: a ManualStopWordLLM that mirrors the documented snippet, plus the runnable check the issue asks for — both stop-list orders and a response with no match.

docs/edge/ar/learn/custom-llm.mdx has no stop-word section in this checkout (its translation stops before "Required Methods"), and docs/edge/pt-BR/learn/custom-llm.mdx carries # (não traduzir blocos de código) placeholders where the code blocks should be, so there is no matching guidance to update in those two locales. I left them alone rather than adding a section the translators have not reached yet.

Testing

Both stop-list orders now agree, and the old snippet disagreed:

['LATE', 'EARLY'] | old: 'hello EARLY middle ' | new: 'hello'
['EARLY', 'LATE'] | old: 'hello '             | new: 'hello'
python -m pytest lib/crewai/tests/test_custom_llm.py -k "stop_word"
3 passed, 8 deselected in 18.91s

Python 3.13.14 on Windows, no model calls and no credentials.

AI assistance

Written with AI assistance (WorkBuddy) and reviewed before submission.


Note

Low Risk
Documentation and test-only changes; no runtime LLM or agent behavior is modified in this PR.

Overview
Fixes the custom LLM guide’s manual stop-word snippet so it matches BaseLLM._apply_stop_words: it now finds all stop-word positions, truncates at the earliest match (not the first list entry that appears), and **.strip()**s the result.

English and Korean custom-llm.mdx pages get the updated code plus a short note that stop-list order no longer affects output. test_custom_llm.py adds a ManualStopWordLLM copy of the documented logic and tests for both stop-list orderings and responses with no matches, so the guide and tests stay aligned (fixes #8002).

Reviewed by Cursor Bugbot for commit 98065ae. Bugbot is set up for automated code reviews on this repo. Configure here.

@mintlify

mintlify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 5bb70b0.

Approve preview

@strix-security

strix-security Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 117 commits after the last Strix review (c83d755). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

✅ No open security findings.

PR summary: The PR fixes the manual stop-word example in the custom LLM documentation (English and Korean) so it truncates at the earliest matching stop word and strips surrounding whitespace, matching `BaseLLM._apply_stop_words`, and adds tests that pin the documented behaviour.

Review summary

This PR is documentation-only in substance: it corrects the manual stop-word truncation example in the English and Korean custom-LLM guides so the cut happens at the earliest matching stop word (matching BaseLLM._apply_stop_words) rather than at the first entry in self.stop, and adds a test-local ManualStopWordLLM helper plus three tests that lock the documented behaviour in place. All three changed files were read in full. No production code path, authentication or authorization logic, input handling, query construction, file/network operation, cryptographic primitive, or configuration was touched, and the test additions do not modify runtime behaviour. No security issues found in the changed code.

Review 1 on this PR · c83d755 · requested Oct 30 05:49 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[docs] Fix custom LLM stop-word example to stop at the earliest match

1 participant