Skip to content

feat(scenarios): add scenarios.replay() and the scenarios_replay tool - #80

Open
matejmichnak wants to merge 1 commit into
mainfrom
feat/scenarios-replay
Open

feat(scenarios): add scenarios.replay() and the scenarios_replay tool#80
matejmichnak wants to merge 1 commit into
mainfrom
feat/scenarios-replay

Conversation

@matejmichnak

@matejmichnak matejmichnak commented Aug 13, 2026

Copy link
Copy Markdown

https://make.atlassian.net/browse/BAR-3726

feat(scenarios): add scenarios.replay() and the scenarios_replay tool

Summary

Adds support for POST /scenarios/{scenarioId}/replay — replaying a past scenario execution with the trigger data the original execution received. The endpoint is documented in the public API but had no SDK coverage.

  • make.scenarios.replay(scenarioId, executionIds)Promise<ReplayScenarioResponse>
  • scenarios_replay tool definition, sitting alongside scenarios_run
  • ReplayScenarioResponse exported from src/index.ts
const { executionId } = await make.scenarios.replay(925, ['509f0457d2804ba7b115faf1637beea6']);

The response carries the new execution ID

replay() returns { executionId } — the ID of the new execution the replay created, not the one being replayed. That mirrors scenarios_run and is what makes the tool composable: an agent can hand the returned ID straight to executions_get-detail to inspect how the replay went.

Tool description

Replay has two failure modes a caller can't predict from the inputs alone:

  • 404 — unknown execution ID
  • 422 Execution is not replayable — the execution exists, but its input data has expired or was never stored

Neither is recoverable by retrying the same ID, and there is no public endpoint that tells you up front which executions are replayable. The tool description therefore states where to source candidate IDs (executions_list) and that "not replayable" means try a more recent execution rather than retry. Without that, a model reads 422 as a transient failure and retries the same ID.

The description also flags the two easy-to-miss contract details: only the first ID in executionIds is replayed, and the scenario must be active.

annotations match scenarios_run (destructiveHint: true, openWorldHint: true) — a replay starts a real execution and consumes operations exactly like a run.

Testing

  • Unit test in test/scenarios.spec.ts asserting the request path, the { executionIds } body shape, and the JSON content type, against a new test/mocks/scenarios/replay.json
  • npm run lint (tsc + eslint) clean
  • npm test — 327 tests / 46 suites passing

No integration-test case: replay needs a live execution whose input data is still stored, which can't be provisioned from the test setup. Worth adding by hand against a zone that has one.

Notes

  • No src/tools.ts change needed — scenarios.tools.ts is already spread into MakeTools, so the new entry is live on merge.
  • No README.md change — it lists tool categories, not individual tools, and scenarios is already covered.

🤖 Generated with Claude Code

Adds SDK coverage for POST /scenarios/{scenarioId}/replay, which re-runs a
past execution with the trigger data the original execution received.

The method returns the ID of the NEW execution created by the replay, so a
caller can hand it straight to executions_get-detail — mirroring how
scenarios_run composes.

The tool description carries the recovery path for the two failure modes a
caller cannot predict from the inputs: 404 for an unknown execution, and
422 "Execution is not replayable" when the execution's input data has
expired or was never stored. Neither is fixed by retrying the same ID, and
no public endpoint reports replayability up front, so the description
points at executions_list for candidates and says to try a more recent
execution instead of retrying.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@matejmichnak
matejmichnak marked this pull request as ready for review August 13, 2026 12:36
@matejmichnak
matejmichnak requested a review from a team as a code owner August 13, 2026 12:36
Copilot AI lite review requested due to automatic review settings August 13, 2026 12:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class SDK + tool support for replaying a past scenario execution via POST /scenarios/{scenarioId}/replay, returning the new execution ID so it can be inspected like a normal run.

Changes:

  • Added Scenarios.replay(scenarioId, executionIds) and the exported ReplayScenarioResponse type.
  • Added the scenarios_replay tool definition (mirroring scenarios_run annotations/scope).
  • Added a unit test and mock fixture covering the request path/body and JSON content type.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/scenarios.spec.ts Adds a unit test for make.scenarios.replay() request shape and headers.
test/mocks/scenarios/replay.json Adds a mock response fixture { executionId } for replay.
src/index.ts Exports ReplayScenarioResponse from the public SDK entrypoint.
src/endpoints/scenarios.ts Implements Scenarios.replay() and introduces the response type.
src/endpoints/scenarios.tools.ts Registers the new scenarios_replay tool with schema/metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +459 to +464
executionIds: {
type: 'array',
items: { type: 'string' },
description:
'Execution IDs to replay, as returned by executions_list. Currently only the first one is replayed.',
},
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