Skip to content
Shihao Qi
Projects
Writing
Notes
Search
About
中
TAG
Error Handling
Everything filed under this tag.
1 entries
01
Writing
Generator Exceptions Surface on the First next(): try Around create_chat_completion(stream=True) Never Sees the Context Window Error
2026-11-08
Calling a generator function only builds a generator; the body, including any raise in it, runs on the first next(). llama-cpp-python checks the context window inside such a body, so the try around a streaming call, and the shrink-and-retry under it, never fire with the real library. The test double raised at call time, so the tests passed with 100% coverage.
#Python
#LLM
#Error Handling
#Testing
#Autarkia
← All tags
Search the site