Skip to content

Conversation

@asimurka
Copy link
Contributor

@asimurka asimurka commented Jan 20, 2026

Description

This PR updates the default values of the tool_calls and tool_results attributes in QueryResponse, changing them from None (when no tool calls were made) to empty lists.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Improvements
    • Enhanced API response consistency: tool calls and tool results are now always included in query responses as empty lists when no tools are utilized, replacing the previous behavior where they could be absent or null. This improves client-side predictability and response handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Walkthrough

The QueryResponse model is updated to remove Optional types from tool_calls and tool_results fields, replacing them with non-optional lists that default to empty collections. Corresponding endpoint handlers are modified to unconditionally pass these fields, and tests are updated to reflect the new defaults.

Changes

Cohort / File(s) Summary
Model field signature updates
src/models/responses.py
Convert tool_calls and tool_results from Optional[list[...]] to list[...] with default_factory=list, eliminating None as a possible value and ensuring non-null list responses.
Endpoint handler alignment
src/app/endpoints/query.py
Update query_endpoint_handler_base to unconditionally assign summary.tool_calls and summary.tool_results to the QueryResponse instead of conditionally passing None when falsy.
Test expectation updates
tests/unit/models/responses/test_successful_responses.py
Change expected defaults for tool_calls and tool_results from None to empty lists in QueryResponse constructor tests.
Docstring formatting
src/app/endpoints/query_v2.py
Remove blank line in _build_tool_call_summary docstring Args section.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • tisnik
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: converting tool_calls and tool_results from Optional fields with None defaults to mandatory lists with empty list defaults.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@asimurka asimurka force-pushed the tool_call_extraction_improvement branch from 8e54420 to d08f406 Compare January 20, 2026 10:55
Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@are-ces
Copy link
Contributor

are-ces commented Jan 20, 2026

LGTM

@tisnik tisnik merged commit f077938 into lightspeed-core:main Jan 20, 2026
21 of 23 checks passed
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.

3 participants