Skip to content

Add batch cancel, terminate and delete operators for standalone activities#1100

Draft
ks-temporal wants to merge 6 commits into
temporalio:mainfrom
ks-temporal:ks/saa-batch-cmds
Draft

Add batch cancel, terminate and delete operators for standalone activities#1100
ks-temporal wants to merge 6 commits into
temporalio:mainfrom
ks-temporal:ks/saa-batch-cmds

Conversation

@ks-temporal

@ks-temporal ks-temporal commented Jun 25, 2026

Copy link
Copy Markdown

What changed?

Add new activity delete subcommand for deleting a standalone activity, and
add support for --query and related flags for batch operations in activity
cancel, terminate and delete for standalone activities. These are marked
experimental. Exactly one of --activity-id or --query is required for these
activity operators.

Checklist

Stability

  • (N/A) Breaking changes are marked with 💥 in the PR title and release notes
  • (N/A) Changes to JSON output (-o json / -o jsonl) are treated as breaking changes

Design

  • (N/A) This feature does not depend on Cloud-only APIs or behavior (it works against an OSS server)
  • (N/A) New commands follow temporal <noun> <verb> structure (e.g. temporal workflow start)
  • New flags are named after the API concept, not the implementation mechanism (good: --search-attribute, bad: --index-field)
  • New flags don't duplicate an existing flag that serves the same purpose
  • New flags do not have short aliases without strong justification (Justification for -q and -y: consistency)
  • Experimental features are marked with (Experimental) in commands.yaml

Help text (see style guide at the top of commands.yaml)

  • All flags shown in help text and examples are implemented and functional
  • Summaries use sentence case and have no trailing period
  • Long descriptions end with a period and include at least one example invocation
  • Examples use long flags (--namespace, not -n), one flag per line
  • Placeholder values use YourXxx form (YourWorkflowId, YourNamespace)

Behavior

  • Results go to stdout; errors and warnings go to stderr
  • Error messages are lowercase with no trailing punctuation

Tests

  • Added functional test(s) (SharedServerSuite)
  • Added unit test(s) (func TestXxx) where applicable

Manual tests

Setup
Start N=5 activities replacing {N} with 1, 2, ... and so on.

temporal server start-dev --headless
temporal activity start \
    --start-to-close-timeout 60s \
    --type YourActivityType \
    --task-queue YourTaskQueue \
    --activity-id YourActivityId{N}

Start a worker with type YourActivityType to listen to task queue of YourTaskQueue,
that either sleeps for 2 minutes, or returns activity pending error.

Repeat the setup step for each of the tests below.

Happy path
First, test batch cancellation, as follows, and enter y when prompted.

$ temporal activity cancel \
    --query 'ActivityType = "YourActivityType"'
Start batch against approximately 5 standalone activities(s)? y/N y
Started batch for job ID: ...

Check the RunState of these activities using describe, replacing {N} with 1,2,... and so on.

$ temporal activity describe \
    --activity-id YourActivityId{N}
...
Status                 Running
RunState            CancelRequested
...

Also check the status in the list as follows.

$ temporal activity list \
    --query 'ActivityType = "YourActivityType"'
...

Next, test batch deletion, as follows, and enter y when prompted.

$ temporal activity delete \
    --query  'ActivityType = "YourActivityType"'
Start batch against approximately 5 standalone activities(s)? y/N y
Started batch for job ID: ...

Now, listing the activities should not show any.

$ temporal activity list \
    --query 'ActivityType = "YourActivityType"'

To test, batch termination, start the activities again using the setup step
mentioned above. Then test batch termination as follows. Here --yes is
used to avoid the prompt.

$ temporal activity terminate \
    --query  'ActivityType = "YourActivityType"' \
    --yes
Start batch against standalone activities matching query "ActivityType=\"YourActivityType\""? y/N yes
Started batch for job ID: ...

Now, listing the activities should show Status of Terminated for all.

$ temporal activity list \
    --query 'ActivityType = "YourActivityType"'
    Status ...
  Terminated ...
  ...

Delete the activities to cleanup.

$ temporal activity delete \
    --query  'ActivityType = "YourActivityType"' \
    --yes
...

Error case
The following can be repeated by replacing cancel with terminate or delete.

$ temporal activity cancel \
    --activity-id YourActivityId1 \
    --query 'ActivityType="YourActivityType"'
Error: cannot set query when activity ID is set
$ echo $?
1

The following can be repeated by replacing cancel with terminate or delete.

$ temporal activity cancel \
    --run-id <RunID from setup for YourActivityId1> \
    --query 'ActivityType="YourActivityType"'
Error: cannot set query when activity ID is set
$ echo $?
1

Composition

Add a new --query and related flags for cancel, terminate and delete.
Add a new delete subcommand for standalone activity.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds experimental standalone Activity operators to the Temporal CLI, including a new temporal activity delete command and batch-mode support (--query, confirmation/rate limiting flags) for activity cancel, activity terminate, and activity delete.

Changes:

  • Introduces temporal activity delete for deleting standalone activity executions (single and batch via --query).
  • Extends activity cancel/terminate to support batch operations driven by a visibility query, including confirmation prompts and --rps.
  • Adds SharedServerSuite functional tests covering single delete and batch cancel/terminate/delete behaviors.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/temporalcli/commands.yaml Updates help text and adds the new delete command + shared option-set for activity single-or-batch flags
internal/temporalcli/commands.workflow.go Extends override struct used by single-or-batch option handling
internal/temporalcli/commands.gen.go Adds generated flag struct for activity single-or-batch mode and wires in the new delete command
internal/temporalcli/commands.activity.go Implements single vs batch execution logic for activity cancel/terminate/delete
internal/temporalcli/commands.activity_test.go Adds functional tests for delete and batch cancel/terminate/delete
go.mod Updates Go/tooling/module requirements and adds local replace directives
go.sum Updates dependency checksums consistent with the module changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/temporalcli/commands.activity.go
Comment thread go.mod
Comment on lines +5 to +9
replace (
go.temporal.io/api => ../api-go-saa-batch-cmds
go.temporal.io/sdk => ../sdk-go
go.temporal.io/server => ../orig-temporal
)
Comment thread internal/temporalcli/commands.yaml Outdated
Comment thread internal/temporalcli/commands.activity.go
Comment thread internal/temporalcli/commands.activity_test.go
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