Fix URL resolution and recipient guard in SimpleBrowserTool - #307
Fix URL resolution and recipient guard in SimpleBrowserTool#307Ultron09 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f36e2dd4af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if arg_id in page.urls: | ||
| function_args["url"] = page.urls[arg_id] |
There was a problem hiding this comment.
Preserve direct-URL semantics for string IDs
When the current page has its normal numeric-string link keys (for example, {"0": "https://…"}), a call with id: "0" now reports the mapped link URL in the Responses API action. However, open() treats every string ID as a direct URL and attempts to fetch the literal "0" (lines 493-496), so the emitted open_page URL no longer describes the operation that actually ran. Only resolve link IDs here when they have the same type/semantics as open(), or make open() resolve string link IDs too.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 456504e. \process_arguments()\ now checks \isinstance(arg_id, str)\ first to preserve direct-URL semantics matching \open(), and only resolves numeric link IDs when \�rg_id\ is an \int >= 0. Added unit tests in \ est_simple_browser_tool.py\ covering string ID direct URL preservation and negative ID navigation.
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Rechecked the current head after the string-ID fix. None recipients now exit safely, integer link IDs resolve against the page, string IDs keep direct-URL semantics, and find/open without an ID gets the current page URL.
That lines up with the actual browser operations now. I don't see a remaining issue in this patch.
Summary
Fixes two related bugs in
SimpleBrowserToolargument parsing that break web search action emission and server stability in the Responses API:Missing
urlinprocess_argumentsforopenandfindactions:process_arguments()only resolvedurlwhencursor >= 0was explicitly present infunction_args, or whenidwas a string.browser.open(id=0)(opening a link from the current search results with defaultcursor=-1) orbrowser.find(pattern="..."),process_arguments()returned the arguments dictionary without aurlfield.responses_api/api_server.py:generate_response):parsed_args["url"]raisedKeyError: 'url', which was caught byexcept Exceptionand causedactionto be set toNone. As a result, theWebSearchActionOpenPage/WebSearchActionFinditem was completely omitted from the API response.stream_response):urlfell back toNone, emitting invalid null URLs inweb_search_callSSE events.AttributeErroronNonerecipient inmaybe_get_function_args:maybe_get_function_args()directly calledmessage.recipient.startswith(...). Ifmessage.recipientisNone(standard for normal conversational messages), it crashed withAttributeError: 'NoneType' object has no attribute 'startswith'.Changes
maybe_get_function_args()to safely returnNonewhenmessage.recipientisNone.process_arguments(), retrieve the active page usingfunction_args.get("cursor", -1)whencurrent_cursor >= 0.page.urls, handle direct string URLs, and populatepage.urlforfindoropenoperations on the current page.tests/gpt_oss/tools/simple_browser/test_simple_browser_tool.pytestingmaybe_get_function_argsguards andprocess_argumentsacross default cursor, explicit cursor, direct URL, and in-page find scenarios.Verification
tests/gpt_oss/tools/simple_browser/test_simple_browser_tool.py.pytest): all 39 tests pass.