Skip to content

Commit 96bf50d

Browse files
fix: reload workflow state from disk on each request to prevent stale state
1 parent eca9900 commit 96bf50d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
5656
}));
5757

5858
// Handle tool calls
59-
server.setRequestHandler(CallToolRequestSchema, (request) =>
60-
handleToolCall({
59+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
60+
// Reload state from disk before each request to ensure consistency
61+
if (workflowState) {
62+
await workflowState.load();
63+
}
64+
return handleToolCall({
6165
request,
6266
normalizeRequestArgs,
6367
workflowState,
@@ -72,8 +76,8 @@ server.setRequestHandler(CallToolRequestSchema, (request) =>
7276
workingTreeSummary,
7377
},
7478
utils: { shellEscape, determineReleaseTypeFromCommit, createCommitMessageParts },
75-
})
76-
);
79+
});
80+
});
7781

7882
// Helper function
7983
export function getNextStep(status) {

tools/handlers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,18 @@ async function handleProjectSummaryDb(workflowState) {
781781
}
782782

783783
async function handleRerunWorkflow(workflowState) {
784+
// Capture task context BEFORE reset to avoid losing it
784785
const currentDescription = workflowState.state.taskDescription;
785786
const currentType = workflowState.state.taskType;
786787

787788
if (!currentDescription) {
788789
return textResponse("⚠️ No active task to rerun. Use 'start_task' to begin a new workflow.");
789790
}
790791

792+
// Reset all progress flags but preserve history
791793
workflowState.reset();
794+
795+
// Restore task context after reset
792796
workflowState.state.currentPhase = "coding";
793797
workflowState.state.taskDescription = currentDescription;
794798
workflowState.state.taskType = currentType;

0 commit comments

Comments
 (0)