A2A protocol integration for Embabel Agent Framework enabling agent-to-agent communication
Conversion of internal agent capabilities (Goals) to A2A-compatible skill definitions.
Factory interface for creating agent skills.
/**
* Factory interface for creating agent skills from internal capabilities.
*/
interface AgentSkillFactory {
/**
* Create skills for the given namespace.
* @param namespace Skill namespace prefix (typically agent platform name)
* @return List of AgentSkill objects
*/
fun skills(namespace: String): List<AgentSkill>
}Default implementation converting Embabel Goals to A2A AgentSkills.
/**
* Converts Embabel Goals to A2A AgentSkills.
* @param goals Set of goals to convert
*/
class FromGoalsAgentSkillFactory(
private val goals: Set<Goal>
) : AgentSkillFactory {
override fun skills(namespace: String): List<AgentSkill>
}AgentSkill(
id = "${namespace}_goal_${goal.name}",
name = goal.name,
description = goal.description,
tags = goal.tags.toList(),
examples = goal.examples.toList(),
acceptedInputModes = listOf("application/json"),
acceptedOutputModes = listOf("application/json"),
configuration = null
)| Goal Property | AgentSkill Property | Transformation |
|---|---|---|
name | name | Direct copy |
name | id | Prefixed: ${namespace}_goal_${name} |
description | description | Direct copy |
tags | tags | Converted to List |
examples | examples | Converted to List |
| N/A | acceptedInputModes | Fixed: ["application/json"] |
| N/A | acceptedOutputModes | Fixed: ["application/json"] |
| N/A | configuration | Fixed: null |
val goals = setOf(
Goal(
name = "findNews",
description = "Find news based on a person's star sign",
tags = setOf("news", "astrology"),
examples = setOf("Find news for Scorpios", "What news is relevant for Aries?")
),
Goal(
name = "researchTopic",
description = "Research a topic using web tools",
tags = setOf("research", "web"),
examples = setOf("Research Australian elections", "Find information about climate change")
)
)
val factory = FromGoalsAgentSkillFactory(goals)
val skills = factory.skills("my_agent")
// Results:
// - ID: "my_agent_goal_findNews"
// Name: "findNews"
// Description: "Find news based on a person's star sign"
// Tags: ["news", "astrology"]
//
// - ID: "my_agent_goal_researchTopic"
// Name: "researchTopic"
// Description: "Research a topic using web tools"
// Tags: ["research", "web"]Typically used within EmbabelServerGoalsAgentCardHandler:
class EmbabelServerGoalsAgentCardHandler(
private val agentPlatform: AgentPlatform,
private val goalFilter: GoalFilter,
/* ... */
) {
override fun agentCard(scheme: String, host: String, port: Int): AgentCard {
return AgentCard.Builder()
.skills(
FromGoalsAgentSkillFactory(
goals = agentPlatform.goals.filter { goalFilter.invoke(it) }.toSet()
).skills(agentPlatform.name)
)
.build()
}
}class CustomSkillFactory : AgentSkillFactory {
override fun skills(namespace: String): List<AgentSkill> {
return listOf(
AgentSkill(
id = "${namespace}_custom_search",
name = "customSearch",
description = "Perform a custom search operation",
tags = listOf("search", "custom"),
examples = listOf("Search for X", "Find Y"),
acceptedInputModes = listOf("application/json", "text/plain"),
acceptedOutputModes = listOf("application/json"),
configuration = mapOf("maxResults" to 10)
),
AgentSkill(
id = "${namespace}_data_analysis",
name = "dataAnalysis",
description = "Analyze data and generate insights",
tags = listOf("analysis", "data"),
examples = listOf("Analyze sales data", "Generate report"),
acceptedInputModes = listOf("application/json"),
acceptedOutputModes = listOf("application/json", "text/html"),
configuration = null
)
)
}
}Good:
Goal(
name = "researchTopic",
description = "Research a topic using web tools and summarize findings",
tags = setOf("research", "web", "summarization"),
examples = setOf(
"Research the recent Australian federal election",
"Find information about renewable energy trends",
"What are the latest developments in quantum computing?"
)
)Poor:
Goal(
name = "doResearch",
description = "Does research", // Too vague
tags = setOf("RESEARCH", "Web"), // Inconsistent casing
examples = setOf("research") // Not specific
)FromGoalsAgentSkillFactory is immutable and thread-safe:
tessl i tessl/maven-com-embabel-agent--embabel-agent-a2a@0.3.3