Encourage web search usage in GPT handler - #117
Merged
Conversation
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.
Motivation
Description
WEB_SEARCH_TOOL, anallowed_toolsWEB_SEARCH_TOOL_CHOICE, and expanded system guidanceWEB_SEARCH_GUIDANCEto explicitly prefer web_search for facts and current information inhandlers/gpt_handler.py.should_force_web_search(user_input)heuristic to detect prompts that should require a web search on the first model turn (URLs, time-sensitive terms, recent years, and key prefixes).build_response_create_kwargs(...)to centralize Responses API call construction and attach thetool_choicewhenforce_web_searchis true, and switched the handler to use this builder for initial and follow-up Responses calls.Web Search Forcedflag in the diagnostic footer for visibility and adjusted the web_search tool spec to usesearch_context_size: "high".tests/test_gpt_handler.pycovering the heuristic and kwargs builder.Testing
python -m py_compile handlers/gpt_handler.py tests/test_gpt_handler.py, which succeeded.python -m unittest tests/test_gpt_handler.py, which passed (all tests OK).OPENAI_API_KEY="" python3 -m unittest discover -s tests -p "test_*.py", which failed due to external network/proxy errors contacting third-party services (yt-dlp, yfinance, etc.); these failures are environment/network-related and not caused by the GPT handler changes.Codex Task