Skip to content

feat: add optional run_id to get_workflow_history - #54

Merged
GethosTheWalrus merged 4 commits into
GethosTheWalrus:mainfrom
zaman28:feat/get-workflow-history-run-id
Jul 29, 2026
Merged

feat: add optional run_id to get_workflow_history#54
GethosTheWalrus merged 4 commits into
GethosTheWalrus:mainfrom
zaman28:feat/get-workflow-history-run-id

Conversation

@zaman28

@zaman28 zaman28 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds optional run_id to get_workflow_history, mirroring the pattern already established in get_workflow_event (Add workflow event payload tool #39).
  • Response now always includes a run_id key (matching get_workflow_event's response shape).

Closes #50.

Motivation

client.get_workflow_handle(workflow_id) returns a handle bound to the latest run when run_id is omitted, so get_workflow_history today can only walk the newest run's history. For workflows with multiple runs (workflow-level retries, continue-as-new chains, resets), older runs are unreachable — even though the sibling get_workflow_event tool already accepts run_id and correctly scopes to a specific run.

This closes that asymmetry: same field on the same handler, same SDK plumbing, same shape.

Test plan

  • pytest -q — 89 pass. Two new tests under TestGetWorkflowHistory:
    • test_get_workflow_history_passes_run_id_when_provided
    • test_get_workflow_history_defaults_run_id_to_none
  • black --check temporal_mcp/ tests/ — clean.
  • flake8 temporal_mcp/ — clean.
  • mypy temporal_mcp/ — clean.

Backward-compat

Additive. Callers that don't pass run_id:

  • Get run_id=None passed to client.get_workflow_handle(...) — identical server behavior to the previous positional-only call (latest run).
  • See "run_id": null in the response dict — matches the shape get_workflow_event already returns when run_id is omitted.

Mirrors the run_id pattern already established in get_workflow_event
(GethosTheWalrus#39). Allows callers to target a specific run's history when a
workflow has been retried; previously only the latest run was
reachable. Additive — response now always includes a run_id key
(matching get_workflow_event's shape).

Closes GethosTheWalrus#50.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zaman28

zaman28 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Friendly ping — happy to iterate if any changes are wanted here.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

Security Scan Results

Updated for commit 62941d5 after a security scan completed.

Scanner Check Result
OSV dependency scan success (details) OSV PR check completed; open details for vulnerability status.
CodeQL success (details) No open CodeQL alerts reported for this PR ref.
Docker Scout success (details) No open critical/high fixable container CVEs reported for this PR ref.

This comment is updated automatically as OSV, CodeQL, and Docker Scout finish for the PR.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@GethosTheWalrus GethosTheWalrus left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@zaman28 Looks good overall. Two suggestions:

  • Consider making the new tests self-contained by also asserting
  • Consider clarifying the tool schema description to say omitted uses the latest run.

@GethosTheWalrus GethosTheWalrus left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ping me again once done

Clarify tool schema that omitted run_id targets the latest run, and
extend the new tests to assert the full response shape (workflow_id,
events, count) alongside run_id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zaman28

zaman28 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@GethosTheWalrus Done — pushed 62941d5:

  • Clarified the schema description: run_id now says "omit to target the latest run".
  • Extended the two new tests to also assert workflow_id, events, and count on the response, matching the shape assertions in the get_workflow_event tests below.

Ready for another look.

@GethosTheWalrus
GethosTheWalrus merged commit d3aebdf into GethosTheWalrus:main Jul 29, 2026
19 checks 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.

get_workflow_history: optional run_id to target a specific run

3 participants