instructor icon indicating copy to clipboard operation
instructor copied to clipboard

Openai websearch tool giving errors

Open springfig opened this issue 5 months ago • 1 comments

I'm using the following two code snippets with gpt-5 for grounded web search. Sometimes I get back instructor.exceptions.InstructorRetryException error where it is asking me to call my pydantic model in my response. Is there a way to enable a strict tool setting such that the schema is strictly followed? I'm using mode=instructor.Mode.RESPONSES_TOOLS_WITH_INBUILT_TOOLS. instructor.Mode.TOOLS_STRICT doesn't work when using the openai built in web search tool.

class Output(BaseModel):
    textbody: str = Field(..., description="The full response to the input question.")
    references: List[str] = Field(
        ..., description="The list of reference URLs or citations from the generated response."
    )
    output = client.responses.create(
        instructions="Use web_search_preview tool to answer the user question with active references and citation URLs.",
        input=query,
        tools=[{"type": "web_search_preview"}],
        tool_choice="auto",
        response_model=schema,
        model=model,
    )

Image

springfig avatar Aug 13 '25 23:08 springfig

You might need to use JSON mode.

jxnl avatar Aug 23 '25 04:08 jxnl