Skip to content

integrate structured output into chains? #394

@dmlond

Description

@dmlond

It does not seem like it is possible to run a chain that produces structured output. Am I missing something? It seems like there are a couple of places where structured output would be useful.

  1. Within an agent that runs in a chain.
    I had to ensure that the fetch agent returned structured output from a url, and some urls do not. I had to add `respond in YAML format" to the standard fetch agent information input
@fast.agent(
    "gather",
    "Given a URL, provide a complete and comprehensive summary of the required attachments in Section IV Application and Submission Information. respond in YAML format",
    servers=["fetch"], # Name of an MCP Server defined in fastagent.config.yaml
)

Seems like having a way to inject a Pydantic or other supported structured output would be nicer

@fast.agent(
  name="gather",
  instruction="Given a URL....",
  structured=SomeModel
)
  1. At the end of a chain, it would be nice to finanlize it into structured output.
    This could be accomplished if the last agent run in a chain was configured with a structured, e.g. 1. Or you could allow something like
async def main():
    async with fast.run() as agent:
        # using chain workflow
        requirements, message = await agent.mychain(args).structured(model=SomeModel)
        ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions