fix: Rebuild AgentResponse model in multi-turn A2A flows to support skill IDs

In multi-turn A2A conversations, the AgentResponse model was only rebuilt
in _execute_task_with_a2a() but not in subsequent turns handled by
_handle_agent_response_and_continue(). This meant that if the LLM returned
a skill ID on a later turn, it would fail validation.

This commit rebuilds the model in _handle_agent_response_and_continue()
using extract_agent_identifiers_from_cards() to include both endpoints
and skill IDs, ensuring all turns support skill ID resolution.

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-11-12 18:02:58 +00:00
parent d141078e72
commit 416c2665a7

View File

@@ -386,6 +386,9 @@ def _handle_agent_response_and_continue(
if "agent_card" in a2a_result and agent_id not in agent_cards_dict:
agent_cards_dict[agent_id] = a2a_result["agent_card"]
agent_identifiers = extract_agent_identifiers_from_cards(a2a_agents, agent_cards_dict)
agent_response_model = create_agent_response_model(agent_identifiers)
task.description = _augment_prompt_with_a2a(
a2a_agents=a2a_agents,
task_description=original_task_description,