Describe the Bug
I am developing an app for automated research. I decided to use advanced-deep-research preset, but when I am sending request and proceed to receive Streamed output, I am receiving information that âBrowser still returns ukrainian websitres. I will try another approach - direct URL-s to known articles and sourcesâ.
Expected Behavior
To fullfill research completely.
Actual Behavior
It isnât completing request, maybe I am parsing it wrong, look at code below.
Steps to Reproduce
Payload:
endpoint /v1/responses
{
"input": <long prompt (about 40000 chars),
"stream": True,
"max_output_tokens": 128000,
"preset": "advanced-deep-research
}
Parsing loop:
for event in _sse_iter(resp):
if time.time() - start_t > cfg.timeout_sec:
log(" WARNING: timeout during streaming â partial content kept.")
break
etype = event.get("type", "")
out_idx = event.get("output_index", 0)
# --- Path A: full text in .done (all presets emit this) -------
if etype == "response.output_text.done":
text = event.get("text", "").strip()
if text:
done_texts[out_idx] = text
log(f" output_text.done [{out_idx}]: {len(text):,} chars")
# --- Path B: delta chunks (Claude-based presets) --------------
elif etype == "response.output_text.delta":
delta = event.get("delta", "")
if delta:
delta_buffers[out_idx] = delta_buffers.get(out_idx, "") + delta
# --- Path C: output_item.done with type=message (safety net) --
# advanced-deep-research emits this with full content[].text
elif etype == "response.output_item.done":
item = event.get("item", {})
if item.get("type") == "message":
for block in item.get("content", []):
if block.get("type") == "output_text":
text = block.get("text", "").strip()
if text and out_idx not in done_texts:
done_texts[out_idx] = text
log(f" output_item.done/message [{out_idx}]: {len(text):,} chars")
# Extract citations from search_results items streamed inline
elif item.get("type") == "search_results":
for result in item.get("results", []):
url_val = result.get("url", "")
if url_val and url_val not in citations:
citations.append(url_val)
# --- Entire response done: usage + any remaining citations ----
elif etype == "response.completed":
r = event.get("response", {})
# Citations may also appear in response.output search_results
for item in r.get("output", []):
if item.get("type") == "search_results":
for result in item.get("results", []):
url_val = result.get("url", "")
if url_val and url_val not in citations:
citations.append(url_val)
usage = r.get("usage", {})
usage_dict["prompt_tokens"] = usage.get("input_tokens")
usage_dict["completion_tokens"] = usage.get("output_tokens")
usage_dict["total_tokens"] = (
(usage.get("input_tokens") or 0) + (usage.get("output_tokens") or 0)
or None
)
log(f" response.completed | tokens={usage_dict} | citations={len(citations)}")
elif etype and not etype.startswith("response.output_text"):
log(f" Event: {etype}")
break
Environment
- API Version: Agent API, /v1/responses, advanced-deep-research
- SDK (if applicable): -
- Operating System: Windows