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)
| 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. |
| 30 | func 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 |
| 49 | func runDockerAgent(ctx agent.InvocationContext, t *team.Team, agentName string, a *dagent.Agent, sessStore session.Store) iter.Seq2[*adksession.Event, error] { |