Skip to content

fix(migrate): auto-add question param to retrieval tools with filters#46

Open
MicaPerdomo wants to merge 1 commit intocogsol:mainfrom
MicaPerdomo:fix/12-retrieval-tool-question-param
Open

fix(migrate): auto-add question param to retrieval tools with filters#46
MicaPerdomo wants to merge 1 commit intocogsol:mainfrom
MicaPerdomo:fix/12-retrieval-tool-question-param

Conversation

@MicaPerdomo
Copy link

Summary

  • _retrieval_tool_payload only added the question parameter when the parameters list was empty. If a retrieval tool defined filter parameters (e.g. genre, language), question was skipped, causing a 500 error at runtime because the API had no way to receive the search query.
  • Changed the condition from if not params to if not any(p.get("name") == "question" for p in params) so question is always present unless explicitly defined by the user.
  • Added 3 tests covering: empty params, filter-only params, and explicit question already present.

Note: the original code used append (position didn't matter on an empty list). The fix uses insert(0, ...) to place question first, which makes semantic sense as the primary parameter. If the API doesn't depend on parameter order, append would also work — but insert(0, ...) is a reasonable default for readability and convention.

Closes #12

Test plan

  • test_adds_question_when_params_empty — no regression on the original behavior
  • test_adds_question_when_only_filter_params — the actual bug scenario
  • test_does_not_duplicate_question_if_already_present — backward compat with explicit question
  • Full suite: 103/103 passing

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.

BaseRetrievalTool does not auto-add question parameter when other parameters exist

1 participant