Repository navigation
Report the plugin's package version in worker heartbeats (needs SDK support) - #386
Conversation
DABH
left a comment
There was a problem hiding this comment.
Review at head 8f53191 (brianstrauch's merge of main into fa67412; the merge keeps exactly the original commit's added and removed lines). On a worktree at the head: go/googleadk make sync lint test passes (237 tests and subtests, including the plugin and replayer tests, plus the ADK v2.6 MCP run); in the five Python and three TypeScript plugins make sync, make lint and the new test all pass (the TypeScript lint warnings are pre-existing, in untouched files). CI is green at this head. Contract against the three SDK drafts, read but not run: the Python draft calls plugin.version() when building the Worker and the Replayer, the TypeScript draft reads p.version ?? '', and the Go draft asserts interface{ Version() string } on client and worker plugins; each matches what this PR adds, and the released SDKs used here (temporalio 1.34.0, @temporalio/* 1.24.0, go.temporal.io/sdk v1.48.0) never read them, so the body's 'older SDKs are unaffected' holds. Probes: (a) a Go consumer built through a local module proxy serving this head as v0.9.9-probe.1: Version() returns 0.9.9-probe.1 through both a worker.Plugin and a client.Plugin value, also under go test, -trimpath and -mod=vendor, and a replace with another module version reports that version; (b) each TypeScript package packed with an injected 9.9.9-probe.1 and loaded from a separate consumer directory (only the extracted tarball, the consumer's own package.json at 7.7.7) reports 9.9.9-probe.1 through require, google-adk also through an ESM import and strands-agents also from an esbuild bundle, which inlines the JSON; (c) strands_agents built at 9.9.9 reports 9.9.9 from both the wheel and the sdist, and an empty string from a copy without dist-info. Go API: the NewPlugin signature is unchanged and the concrete type is now an unexported wrapper, so only an assertion to *temporal.SimplePlugin stops matching (true at the base, false at the head, by probe); nothing in the repo or README does that, interface assertions keep working, and the body describes the wrapper, so I don't count it as a break. Replay: no change. The accessors are read only at Worker or Replayer construction for heartbeat metadata, and no plugin code calls them. Workflow code imports the /workflow subpath in google-adk and openai-agents; in strands-agents it imports the root module, so plugin.ts and its require('../package.json') now sit in the Workflow bundle (webpack inlines the JSON), but the value is computed only when a StrandsPlugin is constructed, and the CI suites and the smoke run that bundle Workflows pass. Leaving the Java plugins out is consistent: Java SDK 1.40's WorkerPlugin exposes only getName(). Not verified: an end-to-end heartbeat against the SDK drafts, whose own CI is failing.
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Where the problems cluster: the code does what it says for the nine plugins it touches. What is left is one Go edge case (a directory replace reports (devel)), tests that don't pin the value in TypeScript and don't exist in Go, and scope: seven plugins keep an empty version while the title and the generated release notes say each plugin reports one.
Approving: the accessors match what all three SDK drafts read, do nothing on released SDKs, never reach Workflow code, CI is green, and every item below is a non-blocking P3.
Findings outside the diff
- P3 (non-blocking, scope): seven plugins with their own
SimplePluginsubclass are not covered, so with the new SDKs their heartbeat entries keep an empty version, while the title says each plugin and the body says 'Each plugin now reports its own package version'. Python: langsmithLangSmithPlugin, google_genaiGoogleGenAIPlugin, mcpMCPPlugin, typesafeTypeSafePlugin, and the newest pre-release Python plugin (tagged 0.0.1 and 0.0.2), whose plugin class has the same shape; TypeScript: langsmithLangSmithPluginand vercel-ai-sdkAiSdkPlugin(Generally Available). Each is registered as a plugin in its own right (users addMCPPlugindirectly, for example), and LangSmith is missing in both languages. Either add the same accessor and test to these seven, or narrow the title and body to the nine plugins covered here and track the rest. The Java plugins are fine to leave out (see above). - P3 (non-blocking, release notes): the squash subject becomes a line in nine plugins' generated notes.
release-noteslists the subject of every commit touching the plugin directory (release_tool.py:456-473), so 'Report each plugin's version in worker heartbeats' appears verbatim in, for example, the go/googleadk and@temporalio/strands-agentsnotes. There it overstates coverage (previous item) and doesn't say that nothing changes until an SDK release includes the three drafts, which are still drafts with failing CI. Suggest a subject such as 'Report the plugin's package version in worker heartbeats (needs SDK support)'. Also consider merging once the SDK side is approved: the contract (a method in Python, a field in TypeScript, an optionalVersion()in Go) is defined there, and a change during SDK review would need a follow-up here before the next plugin releases.
| if dep.Replace != nil { | ||
| dep = dep.Replace | ||
| } | ||
| return strings.TrimPrefix(dep.Version, "v") |
There was a problem hiding this comment.
P3 (non-blocking): a directory replace reports (devel), not the empty string the comment on line 114 and the PR body promise. For a module or replacement without a version, cmd/go writes (devel) into the build info (src/cmd/go/internal/load/pkg.go, debugModFromModinfo: if version == "" { version = "(devel)" }, present since Go 1.18 and in Go 1.26.6, this module's floor), so after line 124 dep.Version is (devel) and this line returns it. Probe: a consumer with replace go.temporal.io/googleadk => /path/to/go/googleadk prints Version() = "(devel)" through both a worker.Plugin and a client.Plugin value, and its build info shows Replace: {Path: /path/to/go/googleadk, Version: (devel)}. A directory replace is the usual way to try a local checkout or a patched fork, so those heartbeats would carry (devel), while the Python and TypeScript plugins report an empty string when they can't read a version. Either return "" when the version is (devel), which keeps the documented contract and matches the other two languages, or keep it and say so in the comment and the body.
There was a problem hiding this comment.
Fixed in 992fa67: Version() now returns "" for (devel), like Python and TypeScript when they can't read a version.
|
|
||
| // Version returns this module's version without the leading "v", or "" when | ||
| // the build has no module information for it. | ||
| func (versionedPlugin) Version() string { |
There was a problem hiding this comment.
P3 (non-blocking, tests): nothing tests Version(), and the SDK finds it only by name and signature. The Go SDK draft (temporalio/sdk-go#2843) reads it with plugin.(interface{ Version() string }) in pluginVersion, so a rename, a signature change, or a pointer receiver (line 107 stores a value) would silently drop the version with the suite still green; the build-info walk, including the replace branch and the (devel) case above, has no coverage either. The body says the module can't check this in its own tests because it is the main module there, but the parsing can be checked: move lines 117-129 into moduleVersion(info *debug.BuildInfo, ok bool) string, call it as moduleVersion(debug.ReadBuildInfo()), and table-test it with synthetic inputs (a tagged v0.2.0, a pseudo-version, a module replace, a directory replace with (devel), no entry, and ok == false). Also add var _ interface{ Version() string } = versionedPlugin{} and an assertion in plugin_test.go that the NewPlugin result satisfies interface{ Version() string } and still satisfies client.Plugin (both hold at this head, by probe).
There was a problem hiding this comment.
Done in 992fa67. The build-info walk is now moduleVersion(info, ok), with a table test in plugin_internal_test.go (tag, pseudo-version, module replace, directory replace, no entry, no build info). TestNewPluginHasVersion checks that the NewPlugin result has Version() string and is still a client.Plugin. It fails with a pointer receiver, so I left out the var _ line.
| }); | ||
|
|
||
| test('reports the package version for worker heartbeats', (t) => { | ||
| t.regex(new GoogleAdkPlugin().version, /^\d+\.\d+\.\d+/); |
There was a problem hiding this comment.
P3 (non-blocking, tests): the three TypeScript tests only match /^\d+\.\d+\.\d+/, so they pass with a hard-coded or wrong version, both in PR CI and in the release matrix. Mutation: with packageVersion() in the compiled lib/plugin.js returning '1.2.3', this test still passes; the same applies to typescript/openai-agents/src/__tests__/plugin.test.ts:76 and typescript/strands-agents/src/__tests__/test-strands.ts:1661. The release matrix injects the tag version with npm version before the tests run (_typescript-plugin.yml:85-89), so comparing with the package's own file, for example t.is(plugin.version, JSON.parse(readFileSync(path.join(__dirname, '../../package.json'), 'utf8')).version) from lib/__tests__, would catch a stale or hard-coded value there, as the Python tests already do through importlib.metadata.version(...). Optional hardening for the three packageVersion() helpers: check that name is the package's own name before trusting version. A copy of strands-agents' lib/ placed directly under an application root reported the application's version (7.7.7), because ../package.json then resolves to the application's file.
There was a problem hiding this comment.
Done in 992fa67: all five TypeScript tests now compare version with the package's own package.json. I skipped the name check: it only matters when someone copies lib/ by hand under their app root, and no install does that.
- Add the same version accessor and test to the seven other plugins: Python Claude Agent SDK, Google GenAI, LangSmith, MCP and TypeSafe, and TypeScript LangSmith and Vercel AI SDK. - Go: return "" for a directory replace, which the build info records as "(devel)". Move the build-info walk to moduleVersion and table-test it, and test that the plugin has Version() and is still a client plugin. - TypeScript: compare the reported version with the package's own package.json instead of matching a pattern.
|
Thanks @DABH. The summary items:
|
DABH
left a comment
There was a problem hiding this comment.
Re-review at head 992fa67 (one commit since my approval at 8f53191). On a worktree at the head, one plugin at a time: go/googleadk make sync lint test passes (245 tests and subtests, eight more than last round: the six TestModuleVersion cases, their parent and TestNewPluginHasVersion; plus the ADK v2.6 MCP run); in all ten Python and five TypeScript plugins make sync, make lint and the new test pass (the only lint output is pre-existing deprecation warnings in untouched google-adk and openai-agents files). CI is green at this head. I checked each earlier item by rerunning last round's reproduction or by mutation (see Previous rounds).
Contract against the SDK changes: temporalio/sdk-typescript#2637 has merged with the shape this PR relies on: SimplePlugin now declares readonly version?: string and assigns options.version in its constructor, and the worker sends p.version ?? ''. The plugins' class fields initialize after super(), so they still win: with @temporalio/plugin 1.24.0 patched at load time to make the same assignment, each of the five plugins reports its own package.json version (and 9.9.9-probe.1 from the two newly covered ones when I injected that into their package.json; a control new SimplePlugin({ name: 'control', version: '1.2.3' }) reports 1.2.3), and each type-checks against declarations with that property added to SimplePlugin and SimplePluginOptions (these tsconfigs don't enable noImplicitOverride, so no override modifier will be needed after the SDK bump). temporalio/sdk-go#2843 (approved, head 8e5a0a5) still finds Version() by interface assertion and now also adds (*SimplePlugin).Version(), which the wrapper's own method shadows. End to end: a consumer built against that draft and run on a dev server with frontend.ListWorkersEnabled=true shows go.temporal.io/googleadk with version 0.9.9-probe.2 (this head served from a local module proxy) in ListWorkers, whether the plugin is registered on the worker or on the client; the same program on the released v1.48.0 (worker registration) shows an empty version and runs normally. temporalio/sdk-python#2064 is unchanged since last round and calls plugin.version() at Worker and Replayer construction. Its open change request asks for the same version() method on the client Plugin base, which keeps the name and signature these overrides use, so this PR would not need to change if that request is adopted. No released SDK used here reads the new accessors (temporalio 1.34.0 and 1.35.0, @temporalio/* 1.24.0, go.temporal.io/sdk v1.48.0). Replay: no change. No plugin code calls the accessors, and the Workflow-side modules of the two newly covered TypeScript packages (workflow-interceptors in langsmith, /workflow in vercel-ai-sdk) don't import plugin.ts. Not verified: an end-to-end heartbeat with the Python and TypeScript SDK changes, which need a native bridge build.
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Previous rounds. All five items from my approval at 8f53191 are addressed. (1) Go (devel): last round's consumer with a directory replace now prints Version() = "" through both a worker.Plugin and a client.Plugin value, while its build info still records (devel). (2) Go tests: they catch what they should. A pointer receiver on Version fails TestNewPluginHasVersion ('googleadk.versionedPlugin must implement interface { Version() string }'), which bears out the reason for leaving out the var _ line, and deleting the (devel) check or the replace step fails the matching TestModuleVersion cases. (3) TypeScript tests: hard-coding '1.2.3' in each compiled packageVersion() now fails all five tests. The optional name check was declined because only a hand-copied lib/ resolves another package.json; I accept that. (4) Scope: the seven added plugins (Python Google GenAI, LangSmith, MCP, TypeSafe and the newest pre-release plugin; TypeScript langsmith and vercel-ai-sdk) use the same accessor as the others (the distribution name from their own pyproject.toml in Python, their own package.json in TypeScript), and a search finds no remaining SimplePlugin subclass without one in Python, TypeScript or Go. The Java plugins stay out correctly: Java SDK 1.40.0's WorkerPlugin still has only getName(). (5) Release notes: the title is now the suggested subject, and the body lists all sixteen plugins and holds the merge for the SDK reviews.
Approving again: every earlier item is fixed or reasonably declined, the seven added plugins follow the same pattern and pass lint and their new tests, the accessors match all three SDK changes (end to end in Go), CI is green, and I found no new issues.
Keep both new imports in python/openai_agents/tests/test_openai.py: functools from main and importlib.metadata from this branch.
| */ | ||
| export class AiSdkPlugin extends SimplePlugin { | ||
| /** The package version, reported in worker heartbeats. */ | ||
| readonly version = packageVersion(); |
There was a problem hiding this comment.
The current released SDKs don't read this yet, since sdk-typescript#2637 merged after 1.25.0. Shouldn't the README and the release notes say the version shows up only with the next TypeScript SDK release?
Added this to the README in #485.
…esponse metadata (#485) ### What changed? This PR fixes the points from my reviews of #162, #445 and #386. - The duplicate Activity error says where the other Activity is from and how to fix it. For two `AiSdkPlugin`s, it suggests one `modelProvider` built with `customProvider`. - The duplicate error still shows if `nativeWorker.initiateShutdown` is missing. - `AiSdkPlugin` checks its own `createActivities` result, not a cast of `options.activities`. - Two `AiSdkPlugin`s with `workflowsPath` don't fail in webpack anymore. - `doStream` drops an invalid `timestamp`. Fixes #AI-963 ### Why? The duplicate error didn't tell a user with two providers how to keep both. The rest are small gaps next to that code. The stream keeps the same parts as before, so Workflow history doesn't change. ### How did you test it? - [x] Unit tests. `make lint` and `make test` pass in `typescript/vercel-ai-sdk`.
What was changed
Each plugin now reports its own package version for worker heartbeats:
version()method that readsimportlib.metadata.version("<package>").versionfield read from the package's ownpackage.json.NewPluginreturns a small wrapper with aVersion()method that reads the module version from the build info, without the leadingv.When the version can't be read, each one returns an empty string, so the worker still starts. In Go, this includes a build that replaces the module with a local directory.
The Java plugins don't change: the Java SDK's
WorkerPluginhas no version yet.Why?
Worker heartbeats carry each plugin's name and version (
WorkerHeartbeat.plugins), and the server logs them, but the version is always empty today. temporalio/sdk-python#2064, temporalio/sdk-typescript#2637 and temporalio/sdk-go#2843 make the SDKs read it. This change also works with older SDKs, which never call the new method or field, so no plugin needs a newer minimum SDK.Merge this after those three SDK PRs are approved, in case their review changes the method or field name.
Checklist
importlib.metadatain Python and from the package'spackage.jsonin TypeScript. In Go, a table test covers reading the version from the build info (tag, pseudo-version, module replace, directory replace, no entry, no build info), and a test checks that the plugin hasVersion()and is still a client plugin. I ranmake sync,make lintand the new tests for the 10 Python and 5 TypeScript plugins, andmake lintandmake testfor the Go plugin.