ConversationLearner: add non-interactive CLI entrypoint#126
Merged
weiyilong-1 merged 1 commit intoJun 20, 2026
Merged
Conversation
Add a flag-based CLI (cli.py + __main__.py) so the agent can run non-interactively alongside `adk run` and the Agent Engine deployment. Two input styles: - Deterministic flags (--reasoning_engine_id / --conversation_id + a time window) call generate_learnings() directly — no LLM front-end, so it is reproducible for cron/CI. - --prompt routes a natural-language request through the existing root_agent one-shot via ADK InMemoryRunner. --output controls where proposal.json is written; it works in both modes via a module-level default, so generate_learnings()'s ADK tool signature is unchanged. Adds tests/test_cli.py plus output-path coverage in test_agent.py, and documents the CLI in the README. No new dependencies (argparse/asyncio are stdlib).
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.
What
Adds a non-interactive CLI to
agents/conversation_learner, alongside the existingadk runREPL and the Agent Engine deployment (deploy.py), so the agent can run from scripts / cron / CI.Two input styles:
--reasoning_engine_id/--conversation_id+ a time window (--days_agoor--start_time/--end_time), plus--include_ids. Callsgenerate_learnings()directly (no LLM front-end), so it is fast and reproducible.--prompt— routes a natural-language request through the existingroot_agentone-shot via ADKInMemoryRunner(mirrorsadk run).--outputcontrols whereproposal.jsonis written (a directory is allowed). It works in both modes via a module-level default, sogenerate_learnings()'s ADK tool signature is left unchanged.Why
The agent could previously only be driven interactively (
adk run .) or deployed to Agent Engine. There was no scriptable entrypoint for automation/pipelines.Files
cli.py(new) — argparse CLI:build_parser(),_run_flags(),_run_prompt(),main().__main__.py(new) — enablespython -m conversation_learner.agent.py—set_default_output_path()+ anoutput_pathfallback insave_trajectory_analysis_result(~6 lines;generate_learningsuntouched).tests/test_cli.py(new) + output-path coverage added totests/test_agent.py.README.md— "Running via CLI (non-interactive)" section.No new dependencies (
argparse/asyncioare stdlib).Usage
Testing
python -m unittest conversation_learner.tests.test_cli conversation_learner.tests.test_agent— 104 tests pass.adk run, CLI + flags, CLI +--prompt) against a live reasoning engine: each exits 0 and writes a validproposal.json.