Repository navigation
test: cover response_api content-format guards and system-image rejection - #35
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Closes the coverage gap flagged by the code scan in
src/agentlab/llm/response_api.py: the defensive guards in the message builders andClaudeResponseModelhad no tests, so a regression that silently drops malformed content (instead of raising) would pass CI.Tests added in
tests/llm/test_response_api.py, next to the existing builder tests:test_message_builder_rejects_unsupported_content— parametrized over all three builders (OpenAIResponseAPIMessageBuilder,AnthropicAPIMessageBuilder,OpenAIChatCompletionAPIMessageBuilder); a content item with neithertextnorimagemust raiseValueError("Unsupported content type: ...").test_openai_response_api_message_builder_assistant_text_is_output_text— assistant-role text maps tooutput_text(non-assistant staysinput_text, already covered).test_add_image_url_appends_png_base64_content—add_image_urlappends{"image": "data:image/png;base64,..."}and the payload decodes back to the original image.test_filter_system_messages_splits_system_and_other_messages/test_filter_system_messages_rejects_image_in_system_message— sys vs other split (including raw dict messages) and theTypeErrorguard.Tests only; no production code touched.
Note for reviewers
The image guard in
filter_system_messageschecksc.get("type") == "image", butMessageBuilder.add_imagestores{"image": ...}with no"type"key:So the guard only fires for content built with an explicit
"type"key, which is what the new test does. The test documents current behavior rather than the (arguably intended) behavior; fixing the guard to also match"image" in cwould change runtime behavior for any agent that attaches images to system messages, so it is left out of this test-only PR. Happy to follow up if you want the guard tightened.Verification
pytest tests/llm/test_response_api.py -m 'not pricy'→ 17 passed.black --checkclean on the changed file.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/4d335c1680c6462ab3a460c4f6b98a6f
Open in Devin Desktop: https://app.devin.ai/desktop/session/4d335c1680c6462ab3a460c4f6b98a6f?variant=devin