Skip to content

ConversationLearner: add non-interactive CLI entrypoint#126

Merged
weiyilong-1 merged 1 commit into
GoogleCloudPlatform:mainfrom
weiyilong-1:conversation-learner-cli
Jun 20, 2026
Merged

ConversationLearner: add non-interactive CLI entrypoint#126
weiyilong-1 merged 1 commit into
GoogleCloudPlatform:mainfrom
weiyilong-1:conversation-learner-cli

Conversation

@weiyilong-1

@weiyilong-1 weiyilong-1 commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a non-interactive CLI to agents/conversation_learner, alongside the existing adk run REPL and the Agent Engine deployment (deploy.py), so the agent can run from scripts / cron / CI.

Two input styles:

  • Deterministic flags--reasoning_engine_id / --conversation_id + a time window (--days_ago or --start_time/--end_time), plus --include_ids. Calls generate_learnings() directly (no LLM front-end), so it is fast and reproducible.
  • --prompt — routes a natural-language request through the existing root_agent one-shot via ADK InMemoryRunner (mirrors adk run).

--output controls where proposal.json is written (a directory is allowed). It works in both modes via a module-level default, so generate_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) — enables python -m conversation_learner.
  • agent.pyset_default_output_path() + an output_path fallback in save_trajectory_analysis_result (~6 lines; generate_learnings untouched).
  • tests/test_cli.py (new) + output-path coverage added to tests/test_agent.py.
  • README.md — "Running via CLI (non-interactive)" section.

No new dependencies (argparse / asyncio are stdlib).

Usage

# Deterministic flags (from agents/)
python -m conversation_learner \
  --reasoning_engine_id projects/<project-number>/locations/us-central1/reasoningEngines/<engine-id> \
  --days_ago 20 --include_ids

# Natural language
python -m conversation_learner --prompt "generate learnings for <reasoning-engine> in the past 20 days"

Testing

  • python -m unittest conversation_learner.tests.test_cli conversation_learner.tests.test_agent — 104 tests pass.
  • Verified all three invocation paths (adk run, CLI + flags, CLI + --prompt) against a live reasoning engine: each exits 0 and writes a valid proposal.json.

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).
@weiyilong-1 weiyilong-1 merged commit 17ec0da into GoogleCloudPlatform:main Jun 20, 2026
6 checks passed
@weiyilong-1 weiyilong-1 deleted the conversation-learner-cli branch June 20, 2026 21:14
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.

1 participant