TAG
Autarkia
Everything filed under this tag.
3 entries01Writing
Generator Exceptions Surface on the First next(): try Around create_chat_completion(stream=True) Never Sees the Context Window Error2026-11-08Calling 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#AutarkiaLLM Request Observability: Logs Count Messages, and the Native Tools Schema Shows Up Nowhere2026-11-07With native function calling, tool definitions go in the tools parameter, not in messages. A log that measures message length can’t see them, and streaming responses omit usage by default. Autarkia sent 82 tools and 47,898 characters of schema every turn while the prompt log showed about 2,200 characters; the API counted 21k–23k tokens.#LLM#Python#Observability#AutarkiaBreaking Out of an Async Generator Triggers aclose(): Code After the Last Yield Never Runs2026-11-07The consumer breaks on the last event, the async generator gets aclose(), GeneratorExit is thrown into the suspended yield, and the create_task after it never runs while a finally would. Autarkia’s conversation-history save never ran once because of it; the pattern was fixed in April and reintroduced in August for a reasonable-sounding reason.#Python#asyncio#Streaming#Autarkia