Repository navigation
Add opt-in SpecStream search for OfficeQA rollouts - #514
Open
SpecStream (Specstreamai) wants to merge 1 commit into
Open
SpecStream (Specstreamai) wants to merge 1 commit into
SpecStream (Specstreamai) wants to merge 1 commit into
Conversation
env.search_mode=specstream runs the OfficeQA controller search loop on SpecStream's web search API, beside the Parallel and Keenable modes. It is never selected automatically: the default and auto stay offline. Each generated query is one POST to /v1/web-search with q, num and speed=fast as JSON, and SPECSTREAM_API_KEY in an Authorization: Bearer header. The task question is not sent. No key, credential or account is bundled; a missing key fails the rollout before the first model call and before any request. It uses the core httpx dependency, so no extra is needed. Service errors fail the rollout without falling back, with the API's error.message and the key redacted before the text is cut. Redirects are not followed. One deadline (search_timeout_seconds) covers all queries of a round and is checked again after each response. The config reference gets a data-boundary section listing exactly what a request carries, plus the comparability caveat about the paper's Google-backed search setting.
This branch has not been deployed
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.
Adds
env.search_mode=specstream, an opt-in web search mode for the OfficeQA controller search loop. It has the same shape as the Keenable mode from #368, and it includes the #381 follow-ups from the start. It runs only when you select it and setSPECSTREAM_API_KEY. The default andautostayoffline, and the other modes do not change.I work on SpecStream. SpecStream runs this API. Search costs $1 per 1,000 fast searches, billed to the key's account. This PR always sends
speed=fast.This is search only. The OfficeQA loop has no page reader slot, so there is no extract call.
Conditions from #352
_normalize_search_modereturnsspecstreamonly when it is spelled out. The default,autoand unknown values stayoffline. Tests:test_auto_and_other_modes_never_select_specstream, andtest_fresh_config_never_calls_specstream. In that test a key is set and the model asks for search underautoandoffline, and the mock transport must see zero requests.SPECSTREAM_API_KEYis read from the environment only. If it is missing or blank,_run_custom_search_processfails the rollout before the first model call.specstream_searchalso refuses to run without it, before any request.httpx.pyproject.toml, lockfiles and CI do not change.{"data": {"sources": [...]}}envelope, bad evidence and timeouts all raise. The 401, 402, 429 and 503 tests patch the custom, Parallel and Keenable paths to fail if reached.follow_redirects=False. A followed 307 would resend the query body to another origin, and to a same-origin target it would also resend the bearer key. A test returns a 307 and checks that one request was made.docs/reference/config.mdlists what a request carries: a JSON body withq,num(env.search_max_num_results) and"speed": "fast", the key in anAuthorization: Bearerheader, and SkillOpt'sUser-Agent. The task question is not sent. The section says a generated query can still repeat text from the question, the document context or the skill. It has the comparability caveat about the paper's Google-backed search setting.tests/test_officeqa_specstream_search.py(58 tests) runs the client againsthttpx.MockTransportand asserts the exact request. Nothing reaches the live service.Follow-ups from #368 and #381, built in
error.messagefrom{"error": {...}}, or else the raw body. It replaces the key with[redacted]before the 1000 character cut. Tests cover a key echoed inerror.message(checked infail_reasonandconversation.json), one in a plain text body, and one straddling the cut.search_timeout_secondsdeadline covers all queries of a round.time.monotonic() > deadlineis checked again after each response, so a slow last query fails the round too.follow_redirects=Trueopenai_chat/qwen_chatbackend checkautoorofflineselecting SpecStreampayload["sources"]read instead ofpayload["data"]["sources"]speedother thanfasterror.messagesearch_max_num_resultsis per query here, as for Keenable, so the config table notes 16 results per round with the defaults. It is capped at 50. A missing or non-stringtitlefalls back to the URL. A source without aurlis skipped. An emptysnippetfalls back to the joinedhighlights.Files
skillopt/envs/officeqa/specstream_search.py: the client. It mirrorskeenable_search.py: one keyedPOSTper query, the same rendering, the same deadline and the same error rules.skillopt/envs/officeqa/rollout.py: thespecstreammode constant, its_normalize_search_modebranch, the four controller mode sets, the missing key check and the dispatch branch.docs/reference/config.md: the table rows and the data boundary section.CHANGELOG.md: one entry under Unreleased.tests/test_officeqa_specstream_search.py: the tests.Tested
All commands ran with
SPECSTREAM_API_KEYunset.python -m pytest -q tests/test_officeqa_specstream_search.py tests/test_officeqa_keenable_search.py tests/test_officeqa_parallel_search.py: 132 passed on Python 3.10, 3.11 and 3.12 (.[dev,parallel]).python -m pytest -q: 2688 passed, 11 skipped, 4 xfailed on Python 3.10, 3.11 and 3.12 (.[dev,parallel], withSKILLOPT_TEST_REAL_OPENCODE=0andSKILLOPT_TEST_REAL_OPENCODE_SOURCE=0as in CI).python -m mkdocs build --strict: passes.ruff checkon the three changed Python files: clean.No live SpecStream or model call was made.
To turn it off, remove
env.search_mode=specstreamor unsetSPECSTREAM_API_KEY. To remove it, revert this one commit.