Skip to content

Add background=True in deep research agent notebook #1938

@loopasam

Description

@loopasam

The deep agent intro notebook (https://cookbook.openai.com/examples/deep_research_api/introduction_to_deep_research_api#inspect-intermediate-steps) states: "Set the background parameter to True. Since a Deep Research task can take several minutes to execute, enabling background mode will allow you to run the request asynchronously without having to worry about timeouts or other connectivity issues."

But the code doesn't actually set it in:

response = client.responses.create(
  model="o3-deep-research",
  input=[
    {
      "role": "developer",
      "content": [
        {
          "type": "input_text",
          "text": system_message,
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": user_query,
        }
      ]
    }
  ],
  reasoning={
    "summary": "auto"
  },
  tools=[
    {
      "type": "web_search_preview"
    },
    {
      "type": "code_interpreter",
      "container": {
        "type": "auto",
        "file_ids": []
      }
    }
  ]
)

Fix:

add background=True parameter in the call, e.g.

response = client.responses.create(
    model="o3-deep-research",
    input=[
        {
          "role": "developer",
          "content": [
              {
                  "type": "input_text",
                  "text": system_message,
              }
          ]
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": user_query,
                }
            ]
        }
    ],
    background=True,
    reasoning={
        "summary": "auto"
    },
    tools=[
        {
            "type": "web_search_preview"
        },
        {
            "type": "code_interpreter",
            "container": {
                "type": "auto",
                "file_ids": []
            }
        }
    ]
)

and the polling code should be added too? cf: https://platform.openai.com/docs/guides/background#polling-background-responses

But maybe it makes the notebook too complex. As an alternative, link to https://platform.openai.com/docs/guides/background

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions