MCPcopy Index your code
hub / github.com/docker/docker-agent / newDockerAgentAdapter

Function newDockerAgentAdapter

pkg/a2a/adapter.go:30–46  ·  view source on GitHub ↗

newDockerAgentAdapter creates a new ADK agent adapter from a docker agent team and agent name. When agentName is empty, the team's default agent (one explicitly named "root" if it exists, otherwise the first agent declared) is used.

(t *team.Team, agentName string, sessStore session.Store)

Source from the content-addressed store, hash-verified

28// When agentName is empty, the team's default agent (one explicitly named "root" if it
29// exists, otherwise the first agent declared) is used.
30func newDockerAgentAdapter(t *team.Team, agentName string, sessStore session.Store) (agent.Agent, error) {
31 a, err := t.AgentOrDefault(agentName)
32 if err != nil {
33 return nil, fmt.Errorf("failed to get agent %s: %w", agentName, err)
34 }
35 agentName = a.Name()
36
37 desc := cmp.Or(a.Description(), "Agent "+agentName)
38
39 return agent.New(agent.Config{
40 Name: agentName,
41 Description: desc,
42 Run: func(ctx agent.InvocationContext) iter.Seq2[*adksession.Event, error] {
43 return runDockerAgent(ctx, t, agentName, a, sessStore)
44 },
45 })
46}
47
48// runDockerAgent executes a docker agent and returns ADK session events
49func runDockerAgent(ctx agent.InvocationContext, t *team.Team, agentName string, a *dagent.Agent, sessStore session.Store) iter.Seq2[*adksession.Event, error] {

Callers 3

RunFunction · 0.85

Calls 5

NewFunction · 0.92
runDockerAgentFunction · 0.85
AgentOrDefaultMethod · 0.80
NameMethod · 0.65
DescriptionMethod · 0.45

Tested by 2