Skip to content

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

Merged
tusharmath merged 33 commits intomainfrom
todo-enforcer
Apr 8, 2026
Merged

feat(orch): enforce pending todo completion before task finish#2841
tusharmath merged 33 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.


// Build the on_end hook, conditionally adding PendingTodosHandler based on
// config
let on_end_hook = if forge_config.pending_todos_hook {
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.

Suggest a better name that's consistent with out existing flags - Should signal: Verification, Hook, Enable/Disable kind of functionality.

/// Enables the pending todos hook that checks for incomplete todo items
/// when a task ends and reminds the LLM about them.
#[serde(default)]
pub verify_todos: bool,
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.

Update .forge.toml to set the flag to true by default.

self.hook
.handle(&response_event, &mut self.conversation)
.await?;

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.

Why do we need to remove this?

@tusharmath tusharmath enabled auto-merge (squash) April 8, 2026 10:59
@tusharmath tusharmath merged commit 725a423 into main Apr 8, 2026
9 checks passed
@tusharmath tusharmath deleted the todo-enforcer branch April 8, 2026 11:01
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