Your theory is exactly right. The issue is on line 24 of main.py:
@click.option(
"--session-id", metavar="<ID>", default=load_session_id(), help=f"Override the default session ID (default {load_session_id()})"
)
load_session_id() is called at module import time — when the @click.option decorator executes. The return value (a string) is baked into the Click Option object as its default attribute. In a normal CLI invocation this is fine because the process exits after each run. But in Pyodide, modules are cached, so machine.main is imported once, the decorator runs once, and every subsequent invocation reuses that same stale default string.
The fix is to make Click call the function lazily, at invocation time rather than import time. Click supports this directly: if you pass a callable as default, it calls it each time the command is invoked. The only caveat is that Click won't display the dynamic default in --help unless you also set show_default with a static string.
Here's the fix: