Repository navigation
test: unit tests for llm_utils, prompt_templates and HF helpers - #53
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…rs (3 xfail bugs) Co-Authored-By: Daniella Grimberg <daniella@cognition.ai>
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Author
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Co-Authored-By: Daniella Grimberg <daniella@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test-only PR (child 1/11 of the unit-test fan-out). Adds three hermetic test files covering the LLM utility layer; no
src/or existing test changes.tests/llm/test_llm_utils_unit.py(124 tests):messages_to_dict(dict/str, langchainconvert_message_to_dictpath androle_mapfallback via monkeypatched module globals),retry/retry_multiple(asserts the exact messages the fake chat receives on re-prompt),generic_call_api_with_retries(backoff delays, invalid-response/rate-limit/status-code table, exhaustion →RuntimeError, unexpected errors re-raised), OpenAI/Anthropic validity + retriable-vs-fatal status tables using real SDK exception classes,supports_tool_calling_for_openrouter(fakeopenai.Client), tokenizer helpers (fake tiktoken,cache_cleararound each test), parsers, image→base64,BaseMessage/Discussion.tests/llm/test_prompt_templates.py(24 tests):format_message,construct_prompt,get_prompt_templatematching/unknown model.tests/llm/test_huggingface_utils_unit.py(17 tests):_prepend_system_to_first_user(incl.column_remap),HFBaseChatModel.__init__(mockedAutoTokenizer, GPT2 → prompt-template fallback) and__call__(chat-template "roles must alternate" retry, server retry loop,n_samples,log_probs).time.sleepis monkeypatched everywhere; no network, keys, or model downloads.Coverage (target modules)
agentlab.llm.llm_utilsagentlab.llm.prompt_templatesagentlab.llm.huggingface_utilsRemaining uncovered in
llm_utils: import-time langchain detection (lines 25-35) and the__main__block.Tests: 165 (162 pass + 3 strict xfail), ~4s; pass serially, with
-n 4, and under random order.Bugs found (xfail strict,
src/not touched)call_openai_api_with_retries:get_openai_status_codereadshttp_status, but openai>=1 exceptions exposestatus_code→openai.InternalServerError(5xx) is re-raised instead of retried.call_anthropic_api_with_retries:anthropic.APIConnectionErroris in the retriable error tuple but has nostatus_code, so transient network failures are re-raised immediately.BaseMessage.merge(): collapses any single-element content via["text"]→KeyErrorwhen the only element is an image.Run
Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/9d3a89c26fdb4f2c94fe8b58e5a237aa
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/9d3a89c26fdb4f2c94fe8b58e5a237aa?variant=devin
Requested by: @danigrim
Devin Review