Skip to content

Native Kotlin/Wasm SDK for Golem agents#3696

Draft
JohnSColeman wants to merge 12 commits into
golemcloud:mainfrom
JohnSColeman:kotlin-sdk-native
Draft

Native Kotlin/Wasm SDK for Golem agents#3696
JohnSColeman wants to merge 12 commits into
golemcloud:mainfrom
JohnSColeman:kotlin-sdk-native

Conversation

@JohnSColeman

Copy link
Copy Markdown
Contributor

Summary

Adds a native Kotlin SDK under sdks/kotlin/ for writing Golem agents in idiomatic
Kotlin. Agents — and the SDK itself — compile directly to a WebAssembly Component via
Kotlin/Wasm (WasmGC)
: no JavaScript, no QuickJS, no engine embedding. The SDK links the
Golem host interfaces (golem:agent, golem:api/*, golem:durability, wasi:*, …) through
the raw canonical ABI, producing a small, interpreter-free component.

What's included

  • sdk/ — core SDK module: canonical-ABI runtime/guest, host bindings, hand-rolled codecs
    (zero new runtime deps).
  • ksp/ — KSP annotation processor: reads @Agent/@Endpoint/… and generates the
    @WasmExport guest entry points + agent metadata.
  • gradle-plugin/ + wit-native/ — Gradle plugin driving the Kotlin/Wasm compile and the
    wasm-tools embed → new → validate pipeline, plus the bundled WIT.
  • example/ — a durable counter agent.
  • README.md + docs/ — programming-model docs and a capability matrix.
  • scripts/ — host-level e2e + contract-test harnesses.
  • cli/golem-cli — Kotlin language support: golem new --template kotlin and
    kotlin/snapshotting, first-class Kotlin agent-id/value rendering + parsing
    (SourceLanguage::Kotlin), and Kotlin build-tool requirements (JDK 17).
  • golem-skills/…/golem-custom-snapshot-kotlin — snapshotting skill.
  • Host WasmGC config — enable WasmGC in the wasmtime configs of golem-worker-executor,
    golem-component-compilation-service, and agent-type extraction (required to run native
    Kotlin/Wasm components).

Capabilities

Cross-referenced against the Scala reference SDK — 15 complete, 3 partial:

  • Complete: agent model, Kotlin⇄WIT type mapping, host API, oplog, retry + DSL,
    transactions, context, RPC (@RemoteAgent typed clients), RDBMS, quota, WASI, guards &
    checkpoint, secrets, snapshotting (typed Snapshotted<S> mixin, KSP-derived codec),
    utility types.
  • Partial: durability (lazy-initialized-pollable deferred), tools (streamed stdin
    deferred), middleware (request-time HTTP enforcement is host-side).
  • Not started: bridge SDK generation for Kotlin (a golem-cli code-gen gap — does not
    affect in-Golem RPC); request-time HTTP routing/enforcement (host-side).

Testing

  • Unit: 98 Kotlin SDK tests (sdk 60 / ksp 30 / gradle-plugin 8) + golem-cli suite
    green (incl. Kotlin agent-id round-trip tests).
  • Integration (real toolchain, local Golem server): scaffold→build→deploy→invoke e2e;
    15/15 ABI-boundary contract probes; and a manual snapshot-update round-trip proving typed
    agent state survives a component revision bump and a server restart.

Notes

  • Snapshotting is typed-only (Snapshotted<S>) — the codec is derived by KSP from the
    state type; there is no raw-bytes hook path. On a manual update the agent is reconstructed
    from its own agent-id inside load-snapshot.
  • WasmGC must be enabled host-side for these components to run (included in this PR).

@netlify

netlify Bot commented Jul 12, 2026

Copy link
Copy Markdown

Deploy Preview for golemcloud canceled.

Name Link
🔨 Latest commit 16d5841
🔍 Latest deploy log https://app.netlify.com/projects/golemcloud/deploys/6a5508d758813900085f6bf8

JohnSColeman and others added 2 commits July 13, 2026 01:45
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