Skip to content

stop hard-coding "root" as the default agent name#2576

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/refactor-default-agent-handling-in-codeb-1852dbe0
Apr 28, 2026
Merged

stop hard-coding "root" as the default agent name#2576
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/refactor-default-agent-handling-in-codeb-1852dbe0

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Apr 28, 2026

Removes the remaining places that hard-coded "root" as the default/initial agent name and routes every "default agent" lookup through a single helper.

What changed

  • New team.Team.AgentOrDefault(name) method: returns the agent identified by name, falling back to team.DefaultAgent() when name is empty. Centralizes the "empty means default" pattern that was being open-coded in many places.
  • All CLI commands with an --agent flag now default to "" (the empty string) instead of "root". The flag is resolved against the team via AgentOrDefault, so any agent name works.
  • Every hard-coded t.Agent("root") / WithCurrentAgent("root") call site replaced with a resolved name (AgentOrDefault / DefaultAgent) — cmd/root/run.go, pkg/a2a/adapter.go, pkg/acp/agent.go, pkg/server/server.go, pkg/server/session_manager.go.
  • pkg/runtime/remote_runtime.go: currentAgent now defaults to "" (server-side resolves), RunStream no longer special-cases the literal "root", and a sync.Once-cached resolvedAgent(ctx) helper keeps CurrentAgentName() cheap on hot paths.
  • cmd/root/completion.go: shell completion now mirrors team.DefaultAgent() (prefer "root" if present, otherwise the first agent declared) so completion stays in sync with what the runtime would actually run.
  • Comments and the LLM-creator instructions wording updated to match the new reality.
  • Added unit tests for Team.DefaultAgent and Team.AgentOrDefault covering the empty-team / has-root / no-root / explicit-name / unknown-name paths.

Backwards compatibility

team.DefaultAgent() keeps preferring an agent literally named "root" when one exists, so any existing config / API consumer that relied on that name continues to behave identically. Configs without a root agent now resolve to the first declared agent instead of failing.

@dgageot dgageot requested a review from a team as a code owner April 28, 2026 14:04
@dgageot dgageot merged commit a38a194 into docker:main Apr 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants