Skip to content

test: cover LiteLLM response parsing and tool-call handling with mocked tests - #37

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789678015-litellm-parse-tests
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789678015-litellm-parse-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Closes a code-scan coverage gap: LiteLLMModel._parse_response, its extraction helpers, and LiteLLMAPIMessageBuilder.handle_tool_call were only exercised by live pricy provider tests, so every response-shape branch was unverified in CI. This adds 19 network-free tests to tests/llm/test_litellm_api.py built on a FakeMessage / SimpleNamespace stand-in for a litellm chat completion.

Fake response shape used throughout:

SimpleNamespace(choices=[SimpleNamespace(message=FakeMessage({"content": ..., "reasoning": ..., "text": ...}, tool_calls=[...]))])

Behaviours now pinned:

  • reasoning wrapped as <think>...</think>\n (plus custom wrap_tag) and concatenation order reasoning + text + content
  • tool-call JSON arguments parsed into ToolCalls; None when the message has no tool_calls; malformed arguments surface as json.JSONDecodeError
  • use_only_first_toolcall=True truncates extraction to the first call
  • action formatting: single call -> get_weather(location='Paris'), multiple -> newline-joined, empty/None -> None
  • _extract_env_actions_from_text_response returns None (the degenerate non-tool action space)
  • handle_tool_call emits the raw assistant message followed by {"name", "role", "tool_call_id", "content"} dicts, truncates raw_call.tool_calls to one under use_only_first_toolcall, rejects image tool responses, and raises without responded_tool_calls

No production code changed.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/be1f1fd646a74dfb9f2988ee920ac028
Open in Devin Desktop: https://app.devin.ai/desktop/session/be1f1fd646a74dfb9f2988ee920ac028?variant=devin

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

0 participants