Skip to content

Fix: document the service URI schemes, the DATABASE_URL fall-back and the memory:// defaults in adk --help - #385

Open
AmaadMartin wants to merge 3 commits into
mainfrom
fix/cli-service-uri-help-text-schemes
Open

Fix: document the service URI schemes, the DATABASE_URL fall-back and the memory:// defaults in adk --help#385
AmaadMartin wants to merge 3 commits into
mainfrom
fix/cli-service-uri-help-text-schemes

Conversation

@AmaadMartin

@AmaadMartin AmaadMartin commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

  1. Link to an existing issue (if applicable):
    No existing issue.
  2. Or, if no issue exists, describe the change:

Problem: adk --help named one URI scheme per service flag, while the registries route seven session schemes and three artifact schemes. The help also never said what an unset flag does. getSessionServiceFromOptions reads the DATABASE_URL environment variable and then falls back to memory://, so a user who exported DATABASE_URL for another tool writes agent sessions into that database without knowing. DATABASE_URL appeared in exactly one line of the repository and in no help string.

Solution: Both descriptions now name every scheme their registry accepts and state what an unset flag does. The session text also names sqlite://:memory:, which getConnectionOptionsFromUri special-cases into MikroORM's in-memory database. The fall-back belongs to the process that serves the agent: web, api_server and run apply it locally, and the two deploy commands omit the flag when it is unset, so the deployed container applies the same chain against its own environment. No dispatch logic changed — the source diff is two string literals.

Both options are single shared Option instances, so one edit corrects web, api_server, run, deploy cloud_run and deploy agent_engine.

Deliberate omission: vertexai:// stays undocumented. getSessionServiceFromUri matches it but discards the URI and builds VertexAiSessionService({}), which throws Project ID and Location are required., so the path cannot work from the CLI today. PR #331 makes the registry parse the URI; documenting the scheme belongs there.

Collision check: gh pr list --repo AmaadMartin/adk-js --state open --limit 1000, then gh pr diff --name-only on every adjacent PR. #433, #693, #587 and #358 also edit dev/src/cli/cli.ts, but none touch these two descriptions. #348 scrubs an ambient DATABASE_URL in the shared beforeEach of the same test file. To avoid duplicating it, the new tests stub DATABASE_URL per test instead of changing beforeEach; the only shared-hook edit here is vi.unstubAllEnvs() in afterEach.

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.

npx vitest run --project unit:dev dev/test/cli/cli_test.ts — 32 passed. No existing test was modified or deleted.

Two tests read the descriptions off the shared Option and feed a sample URI for every named scheme back through the real registry factory. Six cases were added on top: two pin the new wording, and four pin the fall-back chain, which nothing covered before.

Every test was mutation-proven. Each mutation failed exactly one test:

Mutation in dev/src/cli/cli.ts Test that failed Message
Delete || process.env.DATABASE_URL uses DATABASE_URL when --session_service_uri is omitted expected InMemorySessionService to be an instance of DatabaseSessionService
Default memory:// -> sqlite://:memory: falls back to an in-memory session service when neither is set expected DatabaseSessionService to be an instance of InMemorySessionService
Read DATABASE_URL before the flag prefers --session_service_uri over DATABASE_URL expected DatabaseSessionService to be an instance of InMemorySessionService
Delete the DATABASE_URL sentence documents the DATABASE_URL fall-back and the memory:// default expected description to contain 'DATABASE_URL'
Delete (or sqlite://:memory:) names only session service URI schemes the registry accepts expected description to contain 'sqlite://:memory:'
Delete If unset, memory://. documents the memory:// default for artifacts expected description to contain 'If unset, memory://'
Artifact default memory:// -> file:///tmp/adk falls back to an in-memory artifact service when the flag is omitted expected { Object (rootDir) } to be an instance of InMemoryArtifactService

npm run lint, npm run format:check and tsc --noEmit report nothing on either changed file. dev/test/cli/cli_create_test.ts fails on this machine with and without the change, because it reads an ambient GOOGLE_CLOUD_PROJECT; PR #569 fixes that.

Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.

npm run build --workspace dev
node dev/dist/esm/cli_entrypoint.js web --help
node dev/dist/esm/cli_entrypoint.js deploy cloud_run --help

All five commands render both sentences:

--session_service_uri <string>   Optional. The URI of the session service. Supported URIs:
                                 memory:// for the in-memory session service; postgres://,
                                 postgresql://, mysql://, mariadb://, mssql:// and
                                 sqlite://<path_to_sqlite_file> (or sqlite://:memory:) for the
                                 database session service. If unset, the serving process uses the
                                 DATABASE_URL environment variable; if that is unset too, memory://.
--artifact_service_uri <string>  Optional. The URI of the artifact service. Supported URIs:
                                 gs://<bucket_name> for the GCS artifact service; memory:// for the
                                 in-memory artifact service; file://<path> for the local file
                                 artifact service. If unset, memory://.

A no-mocks run of the real server proved the documented chain, with no flag passed:

DATABASE_URL=sqlite://$PWD/adk_sessions.db node dev/dist/esm/cli_entrypoint.js api_server --port 8917 ./agents
curl -X POST localhost:8917/apps/echo_agent/users/u1/sessions/s1 -H 'Content-Type: application/json' -d '{"state":{"seen":true}}'
  • The 45 KB adk_sessions.db appeared, and a restart against the same DATABASE_URL returned the session.
  • A restart with DATABASE_URL unset returned 404 Session not found: s1, which is the memory:// default.
  • A restart with DATABASE_URL set and --session_service_uri memory:// also returned Session not found, which is the documented precedence.

An earlier run booted the same server with explicit --session_service_uri sqlite://... and --artifact_service_uri file://... and round-tripped a session and an artifact.

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.

Amaad Martin added 2 commits July 31, 2026 05:30
… in adk --help

The --session_service_uri help advertised only memory:// and
--artifact_service_uri only gs://, so the persistent backends the CLI
already dispatches to were invisible unless a user read the registry
source. getSessionServiceFromUri also routes postgres://, postgresql://,
mysql://, mariadb://, mssql:// and sqlite:// to DatabaseSessionService,
and getArtifactServiceFromUri also routes memory:// and file://.

Both descriptions now name every scheme their registry accepts. This is a
documentation fix: no dispatch logic changes. Because the two Option
instances are shared, the corrected text renders for web, api_server, run,
deploy cloud_run and deploy agent_engine.

Two unit tests pin the "documented is a subset of accepted" invariant by
reading the descriptions off the shared Options and feeding each named
scheme back through the real registry factories, so the help text cannot
silently drift from the registries again.
The tests assert "documented is a subset of accepted", but the names
("documents every session service URI scheme the registry accepts") and the
session table's doc comment claimed the reverse direction too. The registry
also routes vertexai://, which the table deliberately omits, so adding a
scheme to isDatabaseConnectionString without touching the help text would
still pass despite what the test name promised. Rename both tests to "names
only ... schemes the registry accepts" and record why vertexai:// is excluded
on the table itself.

Also assert not.toThrow() rather than toBeDefined(): both registry factories
return non-nullable types, so toBeDefined() could never fail. Throwing on an
unroutable URI is the actual failure mode being pinned.
…efaults

`--session_service_uri` and `--artifact_service_uri` named their schemes but
never said what happens when they are unset. `getSessionServiceFromOptions`
falls back to the DATABASE_URL environment variable and then to `memory://`;
`getArtifactServiceFromOptions` falls back to `memory://` only. Both help
strings now state that. The session string also names `sqlite://:memory:`,
which `getConnectionOptionsFromUri` special-cases into MikroORM's in-memory
database.

The fall-back belongs to the process that serves the agent. `web`,
`api_server` and `run` apply it locally; the two `deploy` commands forward the
raw flag and omit it when unset, so the deployed container applies the same
chain against its own environment.

No behaviour changed. Four new tests pin the fall-back chain, which nothing
covered before, and two pin the new wording.
@AmaadMartin AmaadMartin changed the title Fix: enumerate all supported session and artifact service URI schemes in adk --help Fix: document the service URI schemes, the DATABASE_URL fall-back and the memory:// defaults in adk --help Aug 6, 2026
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