Skip to content

[TASK] Refactor extract A2A into its own bounded context #1368

Closed

Description

@edenreich

Summary

A2A is its own domain, but its code lives inside the agent and scheduler bounded contexts:

  • internal/agent/tools/a2a_*.go: the A2A_QueryAgent, A2A_QueryTask and A2A_SubmitTask tools and the A2A polling job.
  • internal/agent/application/: the whole package is A2A (A2AAgentService, AgentSupervisor, ProbeAgents, ExternalAgents).
  • internal/agent/domain: AgentSupervisor and AgentState (A2A agent containers).
  • internal/scheduler/domain: A2ATaskTracker, TaskPollingState, TaskInfo, TaskRetentionService, BackgroundTaskService, A2AClearer, JobKindA2A, TaskRetainer, A2AStateProvider.
  • internal/scheduler: the A2ATaskTracker implementation, BackgroundTaskService and TaskRetentionService.

Extract it into internal/a2a, mirroring internal/mcp: a pure internal/a2a/domain, internal/a2a/infrastructure for the ADK client adapters, and a root package for the tools, the agent supervisor, the status probe and the background task service. The container registers a2a.NewTools(...) into the tool registry the same way it does for the browser and computer tools, and the A2A tool manifests (introduced by #1367) move to internal/a2a/tools/<Name>.yaml, so changing an A2A tool touches only internal/a2a.

Known knots

  • tools.NewRegistry takes an A2A-typed taskTracker parameter and type-asserts the non-A2A subagent tracker, job submitter, stopper and liveness reporter out of it.
  • Shared scheddomain contracts reference A2A types: BackgroundTaskRegistry embeds A2ATaskTracker, TaskRetainer returns TaskInfo, A2AStateProvider returns TaskPollingState. The depguard domain-is-pure rule forbids scheddomain importing an a2a domain, so these contracts need inverting.
  • a2a_task.go reuses web_fetch.go helpers (isTrustedAgentHost, extractFilenameFromURL), and isTrustedAgentHost reads the A2A config.
  • llm_tool_service.go special-cases the A2A_ prefix (enable gate, skipped validation).
  • agent.go holds an A2AAgentService to render the a2a_agents system prompt section.
  • The presentation layer uses adk.TaskState, agentdomain.AgentState and the scheduler A2A types.

Depends on #1367. Refs #1366.

Acceptance Criteria

  • An internal/a2a bounded context (domain/, infrastructure/, root package) following the internal/mcp layout; internal/agent/application is gone.
  • The A2A tools and their manifests live in internal/a2a, the container registers them, internal/agent/tools has no A2A code, and NewRegistry no longer takes an A2A tracker.
  • The generic job contracts in scheddomain no longer reference A2A types; A2A task tracking and retention live in the a2a context.
  • llm_tool_service.go has no A2A_ special cases; gating comes from the tools' IsEnabled and manifests.
  • depguard: github.com/inference-gateway/adk is only imported inside internal/a2a (like the playwright and robotgo rules).
  • No behavior change: the tool-definitions golden test from [TASK] Refactor built-in tool definitions into manifests (groundwork for #1366) #1367 passes unchanged, task test and task lint pass, mocks are regenerated from the new paths, and AGENTS.md is updated.

Activity

  1. added
    refactor
    on Sep 27, 2026
  2. added theissue type on Sep 27, 2026
  3. moved this from Todo to Done in 2026on Sep 28, 2026
  4. inference-gateway-releaser commented on Sep 28, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.216.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions