Repository navigation
[AI-749] fix(google-adk): support @google/adk 2.1 to 2.3 - #114
Conversation
brianstrauch
left a comment
There was a problem hiding this comment.
Lint and all 187 tests pass. I reproduced two consumer failures outside the existing suite; details are inline.
| return; | ||
| } | ||
| if (ADK_ISSUER_PATTERN.test(issuer)) { | ||
| if (request === UUID_PACKAGE) { |
There was a problem hiding this comment.
[P2] Resolve ADK's undeclared uuid dependency on the Worker too
This redirect only applies during Workflow bundling. In a clean consumer with pnpm hoist=false, installing the packed plugin with @google/[email protected] and then running require('@temporalio/google-adk') throws Cannot find module 'uuid' from ADK's dist/cjs/plugins/reflect_retry_model_plugin.js. The plugin eagerly imports ADK through activities.js, so it fails before Worker creation or this webpack hook can run. Declaring uuid as this plugin's dependency does not make it accessible from ADK's directory in a strict consumer layout. Please ensure ADK can resolve it on the Worker as well, and cover this with a packed-consumer regression test; tests inside this plugin's own directory can find its root-level uuid and miss the failure.
There was a problem hiding this comment.
Good catch, and thanks for the strict-layout repro. ADK 2.1 through 2.3 require uuid from plugins/reflect_retry_model_plugin.js without declaring it (2.0 has no such import, and the web bundle inlines it), so the plugin now installs a narrow Node resolution hook when it loads, before ADK: a Module._resolveFilename wrapper that only steps in when a uuid request from inside node_modules/@google/adk/ fails with MODULE_NOT_FOUND, and answers it with the plugin's own copy. It is installed from all three entries (index, workflow, testing), only when the plugin's own uuid is in reach (otherwise ADK's failure is reported as it was), and is inert in the Workflow bundle. The regression tests pack the plugin and build pnpm's isolated hoist=false layout from the synced store (no network): ADK alone still fails to resolve uuid, and all three entries load, from CommonJS and from an ESM consumer. I also verified it in a real pnpm strict consumer. The shared smoke installs with npm, which hoists, so it cannot see this class of failure; the plugin-local test covers it. Two caveats are in the README: in a CommonJS project the plugin has to be imported before anything that loads ADK in every process (the example's import order is fixed), and the plugin does not hook Node's ES module loader, so an ES module project (its Workflow module included) needs the layout fix the README gives (packageExtensions in pnpm-workspace.yaml).
| engines: {node: '>= 18.12.0'} | ||
| '@mikro-orm/[email protected]': | ||
| resolution: {integrity: sha512-c/OHEApYBzfUtr1VoBe5hiTDEV+tHZJifdgF4RlGrmuhuNJCsgWHxdv1ZjI0zzG79B6QdxqQ8ujgGqwLhCzOPg==} | ||
| engines: {node: '>= 22.17.0'} |
There was a problem hiding this comment.
[P2] Align the declared Node minimum with the new dependency requirement
The ADK bump now pulls in @mikro-orm/[email protected], which requires Node >=22.17.0, while this plugin still advertises Node >=22.12.0. I reproduced ERR_PNPM_UNSUPPORTED_ENGINE using the committed lockfile with engine-strict=true and node-version=22.12.0: pnpm rejects MikroORM before installation completes. Consumers on the declared minimum therefore cannot install this dependency set. Please retain dependencies compatible with the supported minimum or update the runtime requirement and corresponding documentation. CI's latest Node 22.x selector does not exercise this lower bound.
There was a problem hiding this comment.
Agreed — @mikro-orm/core 7.x is a regular @google/adk dependency from 2.1.0 on and every 7.x release requires Node 22.17, so 22.12 cannot be kept. The plugin now declares engines.node >=22.17.0, the README says so, and plugin.toml lists 22.17 as the minimum runtime so the CI minimum cell runs on the floor's latest patch (the conventions check accepts an engine floor's major.minor as the first entry, with tests, and AGENTS.md documents the rule while keeping 22.12.0 as the repository minimum). Verified with engine-strict=true against the packed plugin: 22.12.0 is refused (pnpm names @mikro-orm/core while installing ADK's dependencies), 22.17.0 installs and loads the plugin, and the suite passes on 22.17.0 and 24.
…per-file common surface ADK 2.1.0 turned dist/web from per-file modules into one esbuild bundle that inlines its own @opentelemetry/api, @google/genai, zod and uuid and pre-resolves node:crypto to a stand-in that throws. The plugin served ADK a deterministic crypto by redirecting that import, so with ADK 2.1+ every Workflow failed with "randomUUID: no cryptographically secure source of randomness is available", and the inlined OpenTelemetry copy silently dropped every ADK span. - Pin the Workflow bundle to ADK's per-file dist/esm/common.js (the module set behind its web entry) so the node:crypto redirect and the single @opentelemetry/api copy apply again; fail with a clear error if a future release moves that file. - Install the deterministic shim as the sandbox crypto global (randomUUID and getRandomValues only). ADK reads the global first; both paths draw the same values from the same named random stream, so existing histories replay. - Add throwing createHash/randomBytes stand-ins for ADK 2.1+'s PKCE imports; credential flows remain unsupported in Workflows. - Silence ADK's LLMRegistry INFO log while auto-route re-registers the built-in model patterns (ADK 2.1+ logs through console). - Make release-specific test expectations version-aware: ADK 2.1 resumes run-time tool gates that 2.0.0 refused, and ADK 2.3 reports a node's input-schema rejection as a tool error. The suite passes on 2.0.0, 2.2.0 and 2.3.0.
… <2.4.0 2.2.1 and 2.3.0 were inside the two-week release-age window when this was written (2026-10-18), so the lock stops at 2.2.0; the plugin and its tests already pass on 2.3.0.
…crypto shim Review follow-ups: - ADK >= 2.1 imports uuid on its common surface without declaring it, so under a strict package layout the Workflow bundle could not resolve it. Depend on uuid and redirect ADK's request to the plugin's own CJS copy. - Also serve the crypto builtin to uuid's node builds (strict ESM, so a missing export fails the build) and add randomFillSync to the shim. - Version-aware tests for ADK 2.0 vs 2.1+ run-time tool gates and ADK 2.3 input-schema tool errors; the probe now covers randomFillSync under replay and the test describes what actually proves replay stability. - README: ADK 2.3's @google/genai floor, replay guidance for ADK minor upgrades, and the bundle-wide scope of the sandbox crypto global.
315a61e to
157037d
Compare
|
Thanks @brianstrauch for the strict-layout and Node-floor findings — both reproduced on a packed consumer and are fixed in the last commit: a narrow Worker-side resolution hook answers ADK's undeclared |
…the Node floor
Review follow-ups for two findings reproduced on a packed consumer with
pnpm `hoist=false` and @google/adk 2.2.0.
ADK 2.1 through 2.3 import `uuid` without declaring it (2.0 has no such
import; google/adk-js has no issue or fix for it). The webpack redirect
added earlier covers the Workflow bundle only: on the Worker the plugin
imports ADK as soon as it loads (`activities.ts`), and under a strict
layout `require('@temporalio/google-adk')` failed with `Cannot find
module 'uuid'` from ADK's `dist/cjs/plugins/reflect_retry_model_plugin.js`
before a Worker existed. Declaring `uuid` does not reach ADK's directory
in such a layout, so the plugin now wraps Node's CommonJS resolver
(`Module._resolveFilename`) at load, ahead of its own ADK import, from
every entry (`index`, `workflow`, `testing`): a `uuid` request Node
cannot resolve, made from inside `node_modules/@google/adk/`, resolves to
the plugin's own copy, the one the Workflow bundle already pins ADK to.
Any other request, and any request Node resolves itself, is untouched;
the wrapper installs once per process, only when the plugin's own `uuid`
is in reach (otherwise ADK's failure is reported as it was), and is inert
where the loader is absent (the Workflow bundle shims `node:module`). The
plugin's copy is resolved through a `require` made for the hook's own
file rather than a `require.resolve(...)` call, which webpack followed
when bundling the Workflow code and reported at every Worker start
(`Critical dependency: the request of a dependency is an expression`).
The ES module loader is not hooked (the API that reaches it,
`module.registerHooks`, is still experimental), so the README documents
the layout fix (`packageExtensions`) for application ES modules that
import ADK directly, names the failure text of that case, and states
the import order rule, for CommonJS modules in every process that loads
ADK; the hello-world Workflow module imports the plugin before ADK, as a
client that imports it needs, and its worker and client now run as
written (they mixed top-level await with `require.resolve`). The
contributor README names the per-plugin floor rule too.
The `crypto` global the plugin installs in the sandbox no longer yields
to one the sandbox might come to provide: the ids ADK draws, which a
human-in-the-loop answer is matched against under replay, must keep
coming from the plugin's replay-stable stream.
The ADK bump also pulls @mikro-orm/core 7, which requires Node >= 22.17.0,
while the plugin advertised >= 22.12.0: with `engine-strict` a Node 22.12
consumer is refused with ERR_PNPM_UNSUPPORTED_ENGINE. MikroORM is a
regular ADK dependency from 2.1 on, so the plugin declares the floor it
has (`engines` >= 22.17.0), the README says whose floor it is, and the CI
minimum cell now runs that floor: `[ci] runtime-versions` names 22.17,
which the conventions check accepts for the first entry when it is the
engine floor's major.minor (AGENTS.md updated, noting that such a plugin
no longer tests the latest 22.x).
Tests: unit coverage of the hook (a `uuid` request from an ADK file
resolves to the plugin's copy; other requests, and other packages, are
left to Node; a second install is a no-op; an install without `uuid`
leaves the resolver alone), and a packed-consumer test that builds pnpm's
isolated `hoist=false` layout from the plugin's synced node_modules (no
registry access, the lockfile's versions), proves `uuid` unreachable from
ADK's directory, that ADK alone cannot load when its build requires
`uuid`, and that every plugin entry loads first, from CommonJS and from
an ES module of the consumer, where ADK's own ES module build still
fails. The test removes its links as links before the workspace, so no
removal can follow one into the checkout, and quotes a destination with
a space for the Windows shell. The shared clean-consumer smoke installs
with npm, which hoists, so it cannot see this class of failure and is
left as is.
157037d to
d47a832
Compare
Dependabot's
@google/adk2.0.0 → 2.2.0 bump (dropped from #109 after this run) failed every Workflow withrandomUUID: no cryptographically secure source of randomness is available.Cause. ADK 2.1 ships
dist/webas one esbuild bundle (google/adk-js#614). It inlines its own@opentelemetry/apianduuidand pre-resolvesnode:cryptoto a throwing stand-in, so the plugin'snode:cryptoredirect had nothing to redirect, and its single-copy OpenTelemetry alias no longer reached ADK (every ADK span was silently dropped).Fix
dist/esm/common.js(the same module set as its web entry) instead ofdist/web/index_web.js.cryptoglobal, ahead of any the sandbox might come to provide; same random stream, so ids and recorded histories are unchanged.createHash/randomBytes(ADK 2.1+ PKCE imports; they throw) andrandomFillSync(uuid's node build). ADK 2.1+ importsuuidwithout declaring it, so the plugin depends on it and answers ADK's import with its own copy.>=2.0.0 <2.4.0, lock 2.2.0. Tests branch on the installed ADK where behavior changed (2.1 resumes run-time tool gates, 2.3 reports input-schema rejections as tool errors); the README now says an ADK minor upgrade needs the same care as a Workflow code change.Review follow-ups
uuidimport on the Worker: ADK 2.1 through 2.3 requireuuidfromplugins/reflect_retry_model_plugin.jswithout declaring it, so a pnpmhoist=falseconsumer could not even load the plugin. The plugin now installs a narrow Node resolution hook before it imports ADK (aModule._resolveFilenamewrapper that only answers auuidrequest from insidenode_modules/@google/adk/that failed withMODULE_NOT_FOUND, with the plugin's own copy, resolved through arequiremade for the hook's file so the Workflow bundler does not try to follow it), from all three entries, and only when its ownuuidis in reach. Regression tests pack the plugin and build pnpm's isolated layout without network:uuidis unreachable from ADK's directory, ADK alone cannot load, and every entry loads first, from CommonJS and from an ES module of the consumer. The README states the import-order rule, for CommonJS modules in every process that loads ADK (the hello-world Workflow module imports the plugin first, and its worker and client now run as written), gives thepackageExtensionslayout fix that covers ES module projects too, and names the failure of an ES module that imports ADK, which Node's ESM loader resolves without that hook.@mikro-orm/core7 (7.2.3 in the lock), a regular@google/adkdependency from 2.1.0 on, requires Node 22.17.0, so the plugin now declaresengines.node >=22.17.0, the README says whose floor it is, and CI's minimum cell runs on 22.17 (plugin.tomllists22.17; the conventions check accepts an engine floor'smajor.minoras the first runtime entry, and AGENTS.md documents that rule while keeping 22.12.0 as the repository minimum).Verified.
make lint, the full suite on ADK 2.0.0, 2.2.0 and 2.3.0 (198 tests), the packed-consumer test, the shared smoke, and the conventions and script tests all pass locally on Node 22.17.0 and 24; a real pnpm 10hoist=falseconsumer of the packed plugin fails to load ADK alone, loads it behind the plugin, and loads it from anywhere with the README'spackageExtensions; withengine-strict=true, Node 22.12.0 is refused and 22.17.0 installs and loads the plugin.Not here:
module.registerHooks(Node 22.15+, still experimental) could answer ADK'suuidimport for ES modules too, replacing theModule._resolveFilenamehook; worth doing once it is stable. ADK 2.1+ experimental-API warnings now reach the Worker console (the README notes them; routing ADK's logger to the workflow logger is a follow-up); CI runs the lock and, nightly, the latest matured ADK, so the range's floor (2.0.0) is verified locally only — a floor cell is a follow-up; the openai-agents failure in the same run is unrelated (@openai/agents0.18.0).