Skip to content

Add tags support for activities, sub-orchestrations, and client APIs#89

Merged
YunchuWang merged 6 commits intomainfrom
torosent/add-tags
Feb 3, 2026
Merged

Add tags support for activities, sub-orchestrations, and client APIs#89
YunchuWang merged 6 commits intomainfrom
torosent/add-tags

Conversation

@torosent
Copy link
Member

@torosent torosent commented Feb 3, 2026

Summary

What changed?

  • Added tags property (key-value metadata) to OrchestrationState for reading tags from orchestration state
  • Added StartOrchestrationOptions interface with tags support for scheduling new orchestrations
  • Added tags to TaskOptions for activities and SubOrchestrationOptions for sub-orchestrations
  • Extended client scheduleNewOrchestration with an overload accepting StartOrchestrationOptions
  • Extended proto helper functions newScheduleTaskAction and newCreateSubOrchestrationAction to accept tags
  • Added tag preservation during activity/sub-orchestration retry scheduling
  • Created shared mapToRecord utility in tags.util.ts for converting proto tag maps to TypeScript records
  • Added comprehensive unit tests for tag round-trip in orchestration state, activities, and sub-orchestrations
  • Added DTS e2e test for tag persistence

Why is this change needed?

  • Tags provide a way to attach custom key-value metadata to orchestrations, activities, and sub-orchestrations
  • This enables better organization, filtering, and tracking of workflow instances
  • The proto already supports tags on CreateInstanceRequest, OrchestrationState, ScheduleTaskAction, CreateSubOrchestrationAction, and SubOrchestrationInstanceCreatedEvent

Issues / work items

  • N/A

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to CHANGELOG.md
  • Backport is not required
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • If yes:
      • Impact:
      • Migration guidance:

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): GitHub Copilot (Claude)
  • AI-assisted areas/files:
    • packages/durabletask-js/src/utils/tags.util.ts (new file)
    • packages/durabletask-js/src/task/options/task-options.ts
    • packages/durabletask-js/src/task/options/index.ts
    • packages/durabletask-js/src/index.ts
    • packages/durabletask-js/src/orchestration/orchestration-state.ts
    • packages/durabletask-js/src/orchestration/index.ts
    • packages/durabletask-js/src/client/client.ts
    • packages/durabletask-js/src/utils/pb-helper.util.ts
    • packages/durabletask-js/src/worker/runtime-orchestration-context.ts
    • packages/durabletask-js/test/query-apis.spec.ts
    • packages/durabletask-js/test/orchestration_executor.spec.ts
    • test/e2e-azuremanaged/orchestration.spec.ts
  • What you changed after AI output: Reviewed and refined tag handling, consolidated duplicate mapToRecord functions, strengthened test assertions

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Passed (132 unit tests pass)

Manual validation (only if runtime/behavior changed)

  • Environment (OS, Node.js version, components): N/A
  • Steps + observed results: N/A
  • Evidence (optional):

Notes for reviewers

  • Tags are only supported in DTS (Durable Task Scheduler), not in local sidecar - the sidecar e2e tests were intentionally not added
  • The mapToRecord utility handles undefined proto maps gracefully
  • Tag preservation during retries ensures consistency when activities/sub-orchestrations fail and are rescheduled

Copilot AI review requested due to automatic review settings February 3, 2026 22:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive tags support to the Durable Task JavaScript SDK, enabling key-value metadata to be attached to orchestrations, activities, and sub-orchestrations. Tags are propagated through the entire lifecycle including retries, providing better organization, filtering, and tracking capabilities.

Changes:

  • Added tags property to OrchestrationState and extended client/worker APIs to support tag reading and writing
  • Introduced StartOrchestrationOptions interface for client-side orchestration scheduling with tags
  • Extended TaskOptions and SubOrchestrationOptions with tags support for activities and sub-orchestrations
  • Implemented tag preservation during activity/sub-orchestration retry scheduling

Reviewed changes

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

Show a summary per file
File Description
packages/durabletask-js/src/utils/tags.util.ts New utility for converting proto tag maps to TypeScript records
packages/durabletask-js/src/utils/pb-helper.util.ts Added populateTagsMap helper and extended proto action creators with tags parameter
packages/durabletask-js/src/orchestration/orchestration-state.ts Added tags property to OrchestrationState class
packages/durabletask-js/src/orchestration/index.ts Extended newOrchestrationState factory to extract tags from proto state
packages/durabletask-js/src/task/options/task-options.ts Added tags to TaskOptions and introduced StartOrchestrationOptions interface
packages/durabletask-js/src/task/options/index.ts Exported new StartOrchestrationOptions interface
packages/durabletask-js/src/index.ts Exported StartOrchestrationOptions from main entry point
packages/durabletask-js/src/client/client.ts Added scheduleNewOrchestration overload accepting StartOrchestrationOptions; updated example docs
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Added tag support to callActivity/callSubOrchestrator and tag preservation during retries
packages/durabletask-js/test/query-apis.spec.ts Unit test for OrchestrationState with tags
packages/durabletask-js/test/orchestration_executor.spec.ts Unit tests for tags on activities, sub-orchestrations, and retry preservation; removed debug console.log statements
test/e2e-azuremanaged/orchestration.spec.ts E2E test for orchestration tags round-trip
tests/e2e/orchestration.spec.ts Minor formatting change (extra blank line)

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

torosent and others added 2 commits February 3, 2026 14:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Feb 3, 2026

@torosent I've opened a new pull request, #90, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 3, 2026

@torosent I've opened a new pull request, #91, to work on those changes. Once the pull request is ready, I'll request review from you.

const tags = { env: "test", owner: "durable" };
const id = await taskHubClient.scheduleNewOrchestration(orchestrator, undefined, { tags });
const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);

Copy link
Member

Choose a reason for hiding this comment

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

tests for scheduling activity and suborch with tags too? can be in this same testcase?

@YunchuWang YunchuWang merged commit 0376f94 into main Feb 3, 2026
7 checks passed
@YunchuWang YunchuWang deleted the torosent/add-tags branch February 3, 2026 23:03
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.

4 participants