Skip to content

feat(orch): enforce pending todo completion before task finish#2841

Open
amitksingh1490 wants to merge 20 commits intomainfrom
todo-enforcer
Open

feat(orch): enforce pending todo completion before task finish#2841
amitksingh1490 wants to merge 20 commits intomainfrom
todo-enforcer

Conversation

@amitksingh1490
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 4, 2026
if !pending_todos.is_empty() {
let reminder = format!(
"You have {} pending todo items. Please complete them before finishing the task.",
pending_todos.len()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

instead of items send the formated pending list

is_complete = false;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move this logic outside of orch and expose as a hook.


Ok(())
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we move the prompt from string literals to templates, and use the template engine to render.

Comment on lines +51 to +62
// Check if a reminder was already added to avoid duplicates
if let Some(context) = &conversation.context {
let has_existing_reminder = context.messages.iter().any(|entry| {
entry
.message
.content()
.is_some_and(|content| content.contains("pending todo items"))
});
if has_existing_reminder {
return Ok(());
}
}
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.

Critical bug: The duplicate reminder check prevents enforcement of todo completion after the first reminder. Once a reminder message exists in the context, subsequent End hook invocations will return early without adding messages (line 60), causing the orchestrator to complete the task even though todos remain pending.

What breaks: Tasks will complete with incomplete todos after a single reminder injection.

Fix: Remove the duplicate check entirely, or change the logic to always block completion when pending todos exist:

if !pending_todos.is_empty() {
    // Always block completion by returning an error or adding a message
    return Err(anyhow::anyhow!("Cannot complete task with pending todos"));
}

Alternatively, the duplicate check should verify whether todos were completed since the last reminder, not just whether a reminder exists.

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants