a2aproject / a2aproject/a2a-samples

Mismatch between AI Response and Structured Output in LangGraph Example

Open
#117 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.8k
Forks
751
PR merge metrics
No merged PRs in 30d

Description

In the LangGraph example, you are using create_react_agent with a structured output (which is required for A2A). However, under the hood, what create_react_agent does is run the model twice: once with bind_tools and once with with_structured_output. With bind_tools, the model knows about the tool, and its response is correct, but it's not formatted, so the status can't be extracted. On the other hand, with with_structured_output, the model doesn't know about the tools (because none are bound), so the response doesn't include any information about them, and it's completely different from the bind_tools response. In fact, sometimes this response doesn't even make sense. If you look at the state, you'll see that the first option is correct, while the second one is not, as the first will appear in the message list, and the second will be in the structured output field.

```json
{
"messages": [
{
"role": "HumanMessage",
"content": "Hello, I want to build a minisite"
},
{
"role": "AIMessage",
"content": "Hello! I can help you with that. To build the minisite, I'll need you to provide information about the tool you'd like to add. I'll need the name, description, key benefits, key features, FAQs, real use cases, and how to get started with the tool.\n\nIs it okay if we start with that?"
}
],
"structured_response": {
"status": "input_required",
"message": "Hello! To help you build your minisite, I need more information. What topic would you like the minisite to be about? Do you have any content ready, such as text or images? Do you have any design or layout preferences?"
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.