Skip to content

The current create_agent agent's invoke() response cannot include a structured_response. #32951

@precious0612

Description

@precious0612

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Example Code

Such as

class StructuredResponse(BaseModel):
    id: str
    context: str

agent = create_agent(model=llm, response_format=StructuredResponse)

result = agent.invoke()

Error Message and Stack Trace (if applicable)

The standard result must include both "message" and "structured_response"; however, currently, it only contains "message."

Description

I have printed the response content; it is also in JSON format, but it only includes the "message." The final AIMessage contains the complete structured result. The "finish_reason" being "stop" indicates that it worked correctly.

System Info

python test.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featurelangchainRelated to the package `langchain`

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions