Commit e8025fa
feat(cli): add --app_name to decouple session/artifact storage from folder name
When agents are served via `adk web` / `adk api_server` by passing a
directory, the app_name used to key sessions and artifacts is derived from
the agent's folder name. Two servers that load an identically-named agent
folder against a shared session/artifact backend therefore write to the same
app_name and unintentionally share each other's sessions. There was no
supported way to override the app_name on the directory-launch path.
This adds an optional app_name override:
- `get_fast_api_app(app_name=...)`
- `--app_name` CLI flag on `adk web` and `adk api_server`
- `ADK_APP_NAME` environment variable (fallback)
When set, the session and artifact services are wrapped so their `app_name`
is pinned to the override, while the agent loader, REST routes and web UI keep
using the folder name. Servers loading the same folder can thus be given
distinct app_names to isolate their persisted data (or the same app_name to
share it, on purpose) without renaming the folder.
The change is opt-in: when no override is supplied the services are returned
unchanged, so existing deployments on any backend are unaffected. The wrapper
operates at the BaseSessionService/BaseArtifactService abstraction (it only
rewrites the app_name string), so it is storage-agnostic. Tests cover the
wrapper logic, the get_fast_api_app wiring, and a backend matrix
(in-memory, DatabaseSessionService via sqlite+aiosqlite -- the same class
Postgres/MySQL use -- and SqliteSessionService).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 40cf97b commit e8025fa
4 files changed
Lines changed: 429 additions & 0 deletions
File tree
- src/google/adk/cli
- utils
- tests/unittests/cli/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1714 | 1714 | | |
1715 | 1715 | | |
1716 | 1716 | | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
1717 | 1731 | | |
1718 | 1732 | | |
1719 | 1733 | | |
| |||
1788 | 1802 | | |
1789 | 1803 | | |
1790 | 1804 | | |
| 1805 | + | |
1791 | 1806 | | |
1792 | 1807 | | |
1793 | 1808 | | |
| |||
1828 | 1843 | | |
1829 | 1844 | | |
1830 | 1845 | | |
| 1846 | + | |
1831 | 1847 | | |
1832 | 1848 | | |
1833 | 1849 | | |
| |||
1929 | 1945 | | |
1930 | 1946 | | |
1931 | 1947 | | |
| 1948 | + | |
1932 | 1949 | | |
1933 | 1950 | | |
1934 | 1951 | | |
| |||
1954 | 1971 | | |
1955 | 1972 | | |
1956 | 1973 | | |
| 1974 | + | |
1957 | 1975 | | |
1958 | 1976 | | |
1959 | 1977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
407 | 408 | | |
408 | 409 | | |
409 | 410 | | |
| |||
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
446 | 454 | | |
447 | 455 | | |
448 | 456 | | |
| |||
562 | 570 | | |
563 | 571 | | |
564 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
565 | 587 | | |
566 | 588 | | |
567 | 589 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
0 commit comments