Fix: remove the dead AgentLoader.listApps() and getAppFile() pair - #731
Open
AmaadMartin wants to merge 2 commits into
Open
Fix: remove the dead AgentLoader.listApps() and getAppFile() pair#731AmaadMartin wants to merge 2 commits into
AmaadMartin wants to merge 2 commits into
Conversation
added 2 commits
August 6, 2026 10:01
The two tests that called AgentLoader.listApps() and getAgentFile() also cover live behaviour: app.* entrypoint discovery in a directory, and App classification of the discovered files. Restate that coverage through the API the dev server and the deploy CLI actually use, so the next commit can delete the dead pair without losing the regression signal. The integration assertion is now a sorted toEqual over the full app set, which is stronger than the previous toHaveLength(2) plus two toContain checks.
Nothing in dev/src calls either method. getAppFile() only forwards to getAgentFile(), and listApps() loads every discovered candidate a second time just to run an isApp() test on the result. The dev server answers GET /list-apps with listAgents(), which this change does not touch, so the response is unchanged. AgentLoader is internal to @google/adk-devtools: dev/src/index.ts exports only AdkApiClient and AdkApiServer, so this is not a public API break.
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Link to an existing issue (if applicable):
N/A
Or, if no issue exists, describe the change:
Problem:
AgentLoaderindev/src/utils/agent_loader.tscarries two methods that nothing indev/srccalls:listApps()andgetAppFile().getAppFile()only forwards togetAgentFile().listApps()loads every discovered candidate a second time throughagentFile.load()only to run anisApp()test, which makes the dead method the most expensive one on the class.Solution: I chose option (a) and deleted both methods. Four facts support that choice: no caller exists in
dev/src;AgentLoaderis not exported fromdev/src/index.ts, which exports onlyAdkApiClientandAdkApiServer;getAppFile()was a pure alias forgetAgentFile(); and the Python referenceAgentLoaderhas nolist_apps(), while itslist_agents_detailed()flattens anAppto its root agent instead of reporting an App/agent distinction. I rejected option (b), wiring up a consumer, because it needs a newGET /list-appsresponse shape and a UI consumer that neither this repository nor the Python reference asks for.Notes for the reviewer:
GET /list-appsis unchanged. The route atdev/src/server/adk_api_server.ts:244callslistAgents(), and this change does not editlistAgents()orgetAgentFile().AdkApiClient.listApps()indev/src/server/adk_api_client.tsis a different class with a live caller. I did not touch it.dev/test/utils/agent_loader_test.tsstill asserts that a directory whose entrypoint isapp.jsis discovered, and that the loaded export is anAppnamedtest_app. Only thelistApps()/getAppFile()calls changed, tolistAgents()/getAgentFile().tests/integration/app_loader/app_loader_test.tskeeps all fourlistAgents()assertions verbatim and now classifies each discovered name throughgetAgentFile()+isApp(). The newexpect(appNames.sort()).toEqual(['service_alpha', 'standalone_app'])is stronger than thetoHaveLength(2)plus twotoContainassertions it replaces. The other two cases changedgetAppFiletogetAgentFileand nothing else.feat/lazy-agent-discovery(Feat: split agent discovery from agent loading in the dev AgentLoader #633), which left both methods alone. This branch is cut frommain, not stacked on it.listAppsandgetAppFile. No pull request removes either method. The pull requests that mention them (Feat: split agent discovery from agent loading in the dev AgentLoader #633, Fix: bound AgentLoader bundle imports so app_loader discovery test stops timing out on Windows/macOS CI #247, Perf: scope the agent-loader esbuild plugin filter and skip node_modules during discovery #264, Test: drop the npm install from the AgentLoader discovery integration fixture #276, Fix: stop the app_loader discovery test billing its fixture setup to the first it() (Part 1/2) #506) only touch the same test files or add tests that calllistApps(). None of them is a duplicate of this change.AgentFile.loadApp()andAgentFile.loadAgent()on the sibling class are also caller-free indev/src.loadApp()has real App-synthesis behaviour, so removing it is a behaviour change and not a deletion. It is filed as a separate task and is out of scope here.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
npm run ts:checkreports 280 errors. All of them are pre-existing incore/test/**; the error set is byte-identical before and after this change, and none of them names a file in this diff.Mutation tests. Both rewritten assertions were run against mutated source and both failed.
Unit test. I deleted the
app.*entrypoint preference inloadAgentFromDirectory(), so onlyagent.*is discovered:- subFiles.find((f) => f.isFile && f.name === 'app' && isJsFile(f.ext)) ?? subFiles.find((f) => f.isFile && f.name === 'agent' && isJsFile(f.ext));discovers app entrypoint files (e.g. app.js) in directoriesFAILED:AssertionError: expected [ 'agent1', 'agent2', 'agent3' ] to include 'my_service'.Integration test. I stopped
AgentFile.load()caching theAppfor a module that exportsapp, so it returns the root agent instead:if (isApp(jsModule.app)) { - this.app = jsModule.app; this.agent = jsModule.app.rootAgent; - return this.app!; + return this.agent!; }should discover apps vs agents across directories and standalone filesFAILED:expected [] to deeply equal [ 'service_alpha', 'standalone_app' ].This mutation also fails the pre-existing
should load App from directory entrypointcase, so the new assertion is not the only detector, but it does carry signal.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
Result:
["service_alpha","service_beta","standalone_agent","standalone_app"], the expected sorted array.One environment note: the integration suite runs
npm installin its fixture directory, and that install fails on my machine against a private registry mirror. I ran it withnpm_config_registry=https://registry.npmjs.org. The failure is local and unrelated to this change, so I did not weaken the test.Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.