Skip to content

Build, deploy and invoke Python components with the CLI - #4529

Draft
noise64 wants to merge 30 commits into
python-sdk-wheelfrom
python-cli
Draft

noise64 wants to merge 30 commits into
python-sdk-wheelfrom
python-cli

Conversation

@noise64

@noise64 noise64 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of GOL-1853. Stacked on #4519 (PY-04), which is stacked on #4518 (PY-03) and #4516 (PY-02).

This PR lets the Golem CLI create, build, deploy and invoke Python components. The CLI links golem-python-assembler and builds a component from the application's modules and the golem-py-sdk wheel. It runs no Python, uv or C compiler on the host.

  • python (alias py) is a new guest language. It has no tool requirements. Bridges are not generated for Python, so BridgeSdkTargetKind::supports is false for it, and manifest validation rejects a Python component that declares agent or tool dependencies. A Python component would otherwise fail later in bridge generation, with an error that does not name the cause.
  • The new assemblePython build step names the source directory, the entry modules, the pyproject.toml and the output. The step reads the wheel that GOLEM_PYTHON_SDK_WHEEL names. The wheel is not published, so the step fails with a repair hint when the variable is not set or names a missing file. A relative path in .golem-sdk-overrides resolves against the file's directory. The test layer of the SDK overrides points it at the workspace wheel, which cargo make python-sdk-wheel builds.
  • project.dependencies may list only the exact golem-py-sdk==<version> of the CLI, compared with PEP 503 names. Third-party packages are not assembled into components yet, so the step fails instead of building a component that cannot import them.
  • The step writes the component to a .partial file and renames it after the build succeeds, so a failed build keeps the last valid component. The up-to-date check covers the source file times, the list of source files, the pyproject.toml, the step and the BLAKE3 hash of the wheel. The wheel contains the prepared assets, so its hash also covers them. The file times alone do not show a removed or renamed module, so the task marker hashes the list of files. The marker id is the build directory and the output path, not the full step, because builds with other entry modules or wheels write the same output; with an id from the full step, switching from configuration A to B and back to A found A's old marker and kept B's component. This follows the existing external-command marker.
  • The step rejects an into path inside the source directory, also when the path reaches it through a symbolic link or a .. after one. fs::resolve_path resolves both paths as the filesystem does, also for directories that do not exist yet; a symbolic link to a missing target fails the build. Such a component would be an input of the next build: it would change the build entropy and the source list, and its own time would count as a source time, so even an unchanged build would assemble again.
  • The step also rejects package sources in pyproject.toml (tool.uv.sources entries and uv index or find-links settings) before any application code runs. The error names each setting but not its value, because a source URL can contain credentials. A rejected requirement with a direct reference shows name @ <URL omitted> for the same reason. The SDK always comes from the wheel of the CLI, so a project source would otherwise be ignored silently. GOLEM_PYTHON_SDK_WHEEL stays the way to build with a local wheel.
  • The python template has one component with a CounterAgent. The Python templates are built-in only in dev mode, because the SDK is not published. In public mode, golem new and a manifest that names the python built-in template fail with an error that names the global --dev-mode flag, instead of No templates are available. The name python is reserved only in dev mode, so in public mode a manifest may still declare and use its own python template. The template AGENTS.md guide uses golem --dev-mode in its examples, and the golem-new-project and golem-edit-manifest skills list Python as available in dev mode. The schema, the template layout upgrade, the template AGENTS.md guide, sdks/python/README.md (getting started), the learn app-manifest reference, the golem-build and golem-edit-manifest skills and the CLI output schema name the new language and step. The template AGENTS.md also says that package sources fail the build.
  • tests/app/python_agents.rs scaffolds the template with the real CLI. One test deploys it, checks unequal updates on two agents, kills and restarts the server, and checks the recovered state. It then checks that an unchanged build skips the assembly and keeps the bytes, and that a changed module rebuilds and redeploys. The other test checks that an unsupported type hint, an import error, a third-party dependency and path or Git sources for the SDK each fail with their cause and keep the last component. Two more tests check that removing an imported module fails the next build and keeps the last component, and that switching the entry modules from A to B and back to A assembles A again. The last test checks that an into inside the source directory fails without writing there, also through a directory alias on Unix, and that with the default output two unchanged builds skip the assembly and an edited module assembles again.

CI: no CI job builds the wheel or the prepared assets. The Python tests therefore have their own python tag and are in no it-cli shard. cargo make cli-integration-tests-python builds the wheel first and runs them locally. cargo make cli-integration-tests skips the python tag, because it does not build the wheel. This does not satisfy the behavioral CI gate; where the SDK CI belongs is not decided yet.

Limits: the wheel is not published. Build errors reach the CLI as text; the structured, bounded diagnostic channel follows in GOL-2256, as Dávid decided. Methods are synchronous and support only the scalar types of #4518. Python guest bridges and third-party packages are not supported.

Tests

The changed shared contracts are the CLI commands and output for the new language and build step, and the Python WIT of #4516. The caller tests are the python_agents CLI integration tests, which cargo make cli-integration-tests-python runs after it prepares the assets and builds the wheel, and the app_new CLI integration tests. One of them checks that public mode lists every language except Python and that dev mode lists every language. The golem-cli library tests check the template sets in both modes and the --dev-mode errors.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

📖 Docs preview: https://docs-73963rk63-golem-cloud.vercel.app

Built from commit dc4a56f6690fa402e0bd617b1bdd3816f1151cd0 by docs.yaml.

- A rejected requirement with a direct reference shows
  `name @ <URL omitted>`, because the URL can contain credentials.
- The CLI output schema and its generator include `assemblePython`.
- GOLEM_PYTHON_SDK_WHEEL in .golem-sdk-overrides resolves against the
  file's directory.
- A missing SDK wheel error tells how to build it.
- `cargo make cli-integration-tests` skips the python tag, which needs
  a built wheel.
- The golem-build skill lists `assemblePython:`, and the Python
  template AGENTS.md says that package sources fail the build.
# Conflicts:
#	cli/golem-cli/src/model/cli_output/tests.rs

This branch has not been deployed

No deployments
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