Skip to content

Merge Dev - Add derive subcommand#141

Merged
aliroberts merged 3 commits intomainfrom
dev
Apr 23, 2026
Merged

Merge Dev - Add derive subcommand#141
aliroberts merged 3 commits intomainfrom
dev

Conversation

@aliroberts
Copy link
Copy Markdown
Contributor

Summary

Adds weco run derive <run-id> — create a new run that branches off an existing run's step, inheriting its context and continuing optimization from there.

CLI

weco run derive [--from-step best|run-best|] [-n STEPS]
[-i INSTRUCTIONS] [--api-key provider=key ...]
[--output rich|plain]

  • --from-step accepts best (lineage-best, default), run-best, or an integer step; integers resolve to a node UUID via list_nodes before the request.
  • -i/--additional-instructions takes inline text or a file path; omit to inherit the parent run's instructions.
  • --output plain emits bracket-tagged text for machine consumers; rich (default) drives the interactive panel.

Implementation notes

  • New WecoClient.derive_runPOST /runs/{run_id}/derive, plus get_lineage for resolving derived-from metadata.
  • weco/ui.py split into a package: base.py (Protocol + UIState), live.py, plain.py. OptimizationUI.on_init now takes an optional derived_from dict so the header can show the parent step and metric.
  • Heartbeat loop factored into a heartbeat(run_id, auth_headers) context manager to remove the Event/start/try/finally/join boilerplate from handlers.
  • _dispatch_run_subcommand now honours a bool return from handlers that drive an optimization loop, so derive can exit non-zero on failure without touching read-only handlers.

@aliroberts aliroberts merged commit 491dd31 into main Apr 23, 2026
1 check passed
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.

2 participants