Can't get full response of advance-deep-research preset prompt

:bug: 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”.

:white_check_mark: Expected Behavior

To fullfill research completely.

:cross_mark: Actual Behavior

It isn’t completing request, maybe I am parsing it wrong, look at code below.

:counterclockwise_arrows_button: 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
            

:globe_showing_europe_africa: Environment

  • API Version: Agent API, /v1/responses, advanced-deep-research
  • SDK (if applicable): -
  • Operating System: Windows

Hi FKey,

It looks like your streaming response might be getting cut off because of token limits or how the parser handles large chunks. One approach that some developers use is splitting the input into smaller segments or sending requests in batches, then combining the outputs. You might also want to experiment with tools designed for managing large research queries, I’ve found that this website provides helpful ways to organize and process big data inputs efficiently.

Hopefully, trying smaller segments or using such tools can help you get complete responses from the advanced-deep-research preset.