Skip to content

Chain-of-thought and structured output #800

Closed
@akira108

Description

@akira108

Please read this first

  • Have you read the docs?Agents SDK docs: Yes
  • Have you searched for related issues? Others may have had similar requests: Yes

Question

I'd like to enforce LLM to chain-of-thought and step by step tool calls and ultimately want to return a structured output built with a Pydantic model. To achieve that, I'm using StopAtTools and stop when structured output is built.

tool_use_behavior = StopAtTools(stop_at_tool_names=[build_output.name])

where

@function_tool
def build_output(foo: Foo):
    return foo

Today I can make this work by calling run_streamed, inspecting each interim tool-call result, and returning when the build_output call of the wanted type appears.

Is there a way to achieve the same thing without using run_streamed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions