feat: add --reload_agents flag to watch agent files for changes#304
Open
nuthalapativarun wants to merge 4 commits into
Open
feat: add --reload_agents flag to watch agent files for changes#304nuthalapativarun wants to merge 4 commits into
nuthalapativarun wants to merge 4 commits into
Conversation
When --reload_agents is passed to 'npx adk web' or 'npx adk api_server', AgentLoader watches the agents directory for file changes using the Node.js built-in fs.watch API. When a JS/TS agent file is modified, the in-memory agent cache is invalidated so that the next HTTP request triggers a fresh load from disk. This matches the --reload_agents behaviour in adk-python and removes the need to restart the dev server after editing an agent file. Closes google#196
kalenkevich
reviewed
Apr 28, 2026
kalenkevich
reviewed
Apr 28, 2026
- Replace console.log/warn with AdkLogger in AgentLoader.startWatching - Update RELOAD_AGENTS_OPTION description to note new run required - Add --reload_agents option to the run command - Add onAgentFileReloaded callback to runInteractively so agent hot-reload preserves the existing session when triggered from the run command
Contributor
Author
|
Hi @kalenkevich — I've addressed all the review comments (replaced |
kalenkevich
approved these changes
May 11, 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
Testing Plan
Unit Tests:
Manual End-to-End (E2E) Tests:
npx adk web --reload_agents my-agents/instructionstring)[AgentLoader] Detected change in agent.ts, reloading agents...Without
--reload_agents(defaultfalse), behaviour is unchanged — agents are loaded once at startup and cached for the process lifetime.Checklist
Additional context
Adds
--reload_agents [boolean]option to bothnpx adk webandnpx adk api_server, matching the--reload_agentsflag in adk-python.Implementation:
AgentLoaderaccepts a newwatchForChangesconstructor parameter (defaultfalse).preloadAgents()call, ifwatchForChangesistrue, afs.watchwatcher is started on the agents directory using the Node.js built-infsmodule (no new dependencies).invalidateAll()disposes all cachedAgentFileinstances and resetsagentsAlreadyPreloaded = false, so the next request triggers a fresh scan.disposeAll()closes the watcher to prevent resource leaks on shutdown.AdkApiServerforwards thereloadAgentsoption from server config toAgentLoader.