Skip to content

Simplify the launcher framework#637

Open
ahmedtd wants to merge 1 commit intogoogle:mainfrom
ahmedtd:simplify-launcher
Open

Simplify the launcher framework#637
ahmedtd wants to merge 1 commit intogoogle:mainfrom
ahmedtd:simplify-launcher

Conversation

@ahmedtd
Copy link
Copy Markdown

@ahmedtd ahmedtd commented Mar 10, 2026

Right now, the launcher framework has some deficiencies:

  • If the user defines any of their own flags (to configure APIs or tools), then the launcher immediately fails with a "flag provided but not defined" error.
  • It has a config named prod that is unsuitable for prod (no authentication).
  • It is written to be extremely flexible, but only provides four concrete capabilities (console, api, a2a, webui), and is unlikely to be the framework that a productionized ADK deployment uses.

The first problem is the most serious; I've seen more than one engineer immediately assume that adk-go is deeply broken and switch to adk-python.

The built-in Go flag package does not provide any capability for safely parsing partial sets of flags out of a single set of command-line arguments, so what the launcher framework is currently trying to do is ill-defined.

This change refactors the launcher framework to be a little bit more idiomatic for the way a Go binary typically handles flags. The user will need to declare the ADK flags in their own main file, but we provide a utility function adk.DefineFlags to make this painless.

Most of the unnecessary flexibility is removed.

The prod config is removed.

Closes #606

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the ADK launcher framework to improve its usability and align with standard Go practices for command-line flag handling. This change addresses critical issues such as conflicts with user-defined flags and the unsuitability of the previous "prod" configuration. By simplifying the framework and providing a dedicated utility for flag definition, it aims to make the ADK more robust and easier for developers to integrate and extend, particularly for custom deployments.

Highlights

  • Simplified Flag Handling: The launcher framework has been refactored to use a more idiomatic Go approach for command-line flags, resolving issues where user-defined flags caused immediate failures. A new utility function, adk.DefineFlags, is provided to make flag declaration painless for users.
  • Removed 'prod' Configuration: The prod configuration, previously deemed unsuitable for production due to a lack of authentication, has been entirely removed from the framework.
  • Streamlined Launcher Architecture: The universal launcher and the Launcher/SubLauncher interfaces have been removed, leading to a more direct and less flexible, but more robust, structure for defining and running ADK applications. Sub-launchers (console, web, api, a2a, webui) are now configured directly within their respective parent launchers using dedicated DefineFlags functions and conditional enabling.
  • Consolidated Web Sub-Launchers: The a2a, api, and webui sub-launchers have been consolidated directly into the cmd/launcher/web package, simplifying their integration and configuration within the web server.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/launcher/console/console.go
    • Refactored consoleConfig and consoleLauncher types to Config and Launcher respectively.
    • Introduced DefineFlags function for external flag definition.
    • Removed internal flag parsing logic and related methods (Parse, CommandLineSyntax, Execute).
  • cmd/launcher/full/full.go
    • Replaced the universal.NewLauncher approach with a direct Run function.
    • Introduced FlagConfig and DefineFlags to manage combined flags for console and web modes.
    • Simplified imports by removing direct references to sub-launchers.
  • cmd/launcher/launcher.go
    • Removed the Launcher and SubLauncher interfaces, streamlining the launcher API.
  • cmd/launcher/prod/prod.go
    • Removed the prod launcher package entirely.
    • Renamed to cmd/launcher/full/full_example_test.go and added a test example demonstrating the new full.Run and full.DefineFlags usage.
  • cmd/launcher/universal/universal.go
    • Deleted the universal launcher package.
  • cmd/launcher/web/a2a/a2a.go
    • Moved A2A launcher logic into the web package.
    • Introduced DefineA2AFlags for external flag definition.
    • Removed internal flag parsing and descriptive methods.
  • cmd/launcher/web/a2a/a2a_test.go
    • Updated test to use the new web.Config and web.NewLauncher for A2A setup.
  • cmd/launcher/web/api.go
    • Introduced APIConfig and DefineAPIFlags for configuring the REST API.
    • Added APISubLauncher to encapsulate API setup and routing.
  • cmd/launcher/web/api/api.go
    • Deleted the api sub-launcher package.
  • cmd/launcher/web/web.go
    • Consolidated web launcher configuration into a single Config struct.
    • Introduced DefineFlags for external flag definition, including nested sub-launcher flags.
    • Removed the Sublauncher interface and the dynamic sub-launcher parsing mechanism.
    • Simplified Run logic to conditionally enable sub-launchers based on configuration flags.
  • cmd/launcher/web/webui.go
    • Introduced WebUIConfig and DefineWebUIFlags for configuring the Web UI.
    • Added WebUISubLauncher to encapsulate Web UI setup and routing, utilizing embedded assets.
  • cmd/launcher/web/webui/distr/adk_favicon.svg
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/assets/ADK-512-color.svg
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/assets/audio-processor.js
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/chunk-2WH2EVR6.js
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/chunk-XMJNYD32.js
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/index.html
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/polyfills-B6TNHZQ6.js
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/distr/styles-SCBTF4PF.css
    • Relocated WebUI distribution assets.
  • cmd/launcher/web/webui/webui.go
    • Deleted the webui sub-launcher package.
  • examples/a2a/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/mcp/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/quickstart/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/telemetry/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/tools/multipletools/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/vertexai/agent.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/vertexai/imagegenerator/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/web/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/workflowagents/loop/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/workflowagents/parallel/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/workflowagents/sequential/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
  • examples/workflowagents/sequentialCode/main.go
    • Updated example application to use the new full.DefineFlags() and full.Run() functions.
    • Integrated flag.Parse() into example main function.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly simplifies the launcher framework by refactoring the command-line flag handling to be more idiomatic for Go applications. The removal of the universal and prod launchers, along with the consolidation of web-related sub-launchers, greatly improves the clarity and maintainability of the code. The changes are well-aligned with the stated goals in the description. I've identified one critical bug and a couple of areas for minor improvement to enhance clarity.

if err := l.SetupSubrouters(router, config); err != nil {
return fmt.Errorf("%s subrouter setup failed: %v", l.Keyword(), err)
if w.config.EnableA2A {
if err := w.apiSubLauncher.SetupSubrouters(router, config); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This appears to be a copy-paste error. The A2A subrouter setup is using w.apiSubLauncher instead of w.a2aSubLauncher. This will cause the A2A functionality to be incorrectly configured or to fail entirely when enabled.

Suggested change
if err := w.apiSubLauncher.SetupSubrouters(router, config); err != nil {
if err := w.a2aSubLauncher.SetupSubrouters(router, config); err != nil {

Comment on lines +34 to +36
if err := full.Run(ctx, adkFlags, config); err != nil {

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this is valid for an example, the empty if block can be confusing. It would be beneficial to add a comment to indicate that error handling should be present in a real application, guiding users towards best practices.

if err := full.Run(ctx, adkFlags, config); err != nil {
		// In a real application, you would handle this error, e.g., by logging.
		// log.Fatalf("Run failed: %v", err)
	}

}

func DefineAPIFlags(cfg *APIConfig) {
flag.StringVar(&cfg.FrontendAddress, "adk_webui_address", "localhost:8080", "ADK WebUI address as seen from the user browser. It's used to allow CORS requests. Please specify only hostname and (optionally) port.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The flag name adk_webui_address is a bit confusing here, as this file configures the API, not the WebUI. This flag is used to set the Access-Control-Allow-Origin CORS header for the API. Renaming it to something like adk_webapi_cors_origin would make its purpose clearer and avoid potential confusion with the adk_webapi_address flag defined in webui.go.

Suggested change
flag.StringVar(&cfg.FrontendAddress, "adk_webui_address", "localhost:8080", "ADK WebUI address as seen from the user browser. It's used to allow CORS requests. Please specify only hostname and (optionally) port.")
flag.StringVar(&cfg.FrontendAddress, "adk_webapi_cors_origin", "localhost:8080", "The origin to allow for CORS requests to the API (e.g., the address of the ADK WebUI). Please specify only hostname and (optionally) port.")

Right now, the launcher framework has some deficiencies:
* If the user defines any of their own flags (to configure APIs or
  tools), then the launcher immediately fails with a "flag provided but
  not defined" error.
* It has a config named `prod` that is unsuitable for prod (no
  authentication).
* It is written to be extremely flexible, but only provides four
  concrete capabilities (console, api, a2a, webui), and is unlikely to
  be the framework that a productionized ADK deployment uses.

The first problem is the most serious; I've seen more than one engineer
immediately assume that adk-go is deeply broken and switch to
adk-python.

The built-in Go flag package does not provide *any* capability for
safely parsing partial sets of flags out of a single set of command-line
arguments.

This change refactors the launcher framework to be a little bit more
idiomatic for the way a Go binary typically handles flags.  The user
will need to declare the ADK flags in their own main file, but we
provide a utility function `adk.DefineFlags` to make this painless.

Most of the unnecessary flexibility is removed.

The prod config is removed.
@ahmedtd ahmedtd force-pushed the simplify-launcher branch from 555f01a to ab5b094 Compare March 11, 2026 04:51
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.

Using any custom flags in application's main file causes launchers to fail to parse their flags

1 participant