mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-24 23:58:15 +00:00
fix: only inject method on agent
This commit is contained in:
@@ -379,24 +379,21 @@ def _agent_to_agent_card(agent: Agent, url: str) -> AgentCard:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def inject_a2a_server_methods(target: Crew | Agent) -> None:
|
def inject_a2a_server_methods(agent: Agent) -> None:
|
||||||
"""Inject A2A server methods onto a Crew or Agent instance.
|
"""Inject A2A server methods onto an Agent instance.
|
||||||
|
|
||||||
Adds a `to_agent_card(url: str) -> AgentCard` method to the target
|
Adds a `to_agent_card(url: str) -> AgentCard` method to the agent
|
||||||
instance that generates an A2A-compliant AgentCard.
|
that generates an A2A-compliant AgentCard.
|
||||||
|
|
||||||
For Agents, this only injects methods if an A2AServerConfig is present.
|
Only injects if the agent has an A2AServerConfig.
|
||||||
For Crews, methods are always injected.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
target: The Crew or Agent instance to inject methods onto.
|
agent: The Agent instance to inject methods onto.
|
||||||
"""
|
"""
|
||||||
if not isinstance(target, Crew) and _get_server_config(target) is None:
|
if _get_server_config(agent) is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
def _to_agent_card(self: Crew | Agent, url: str) -> AgentCard:
|
def _to_agent_card(self: Agent, url: str) -> AgentCard:
|
||||||
if isinstance(self, Crew):
|
|
||||||
return _crew_to_agent_card(self, url)
|
|
||||||
return _agent_to_agent_card(self, url)
|
return _agent_to_agent_card(self, url)
|
||||||
|
|
||||||
object.__setattr__(target, "to_agent_card", MethodType(_to_agent_card, target))
|
object.__setattr__(agent, "to_agent_card", MethodType(_to_agent_card, agent))
|
||||||
|
|||||||
Reference in New Issue
Block a user