-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added attempt_complete tool, giving agent ability to signal com…
…pletion
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from .base import ToolSpec | ||
|
||
|
||
class Completed: | ||
"""Signal that the task has been completed.""" | ||
|
||
def __init__(self, message: str, value: str | None) -> None: | ||
self.message = message | ||
self.value = value | ||
|
||
|
||
def attempt_complete(value: str | None) -> Completed | None: | ||
"""Attempt to complete the current task given by user.""" | ||
print("Attempting to complete the current task.") | ||
if not check_completion(): | ||
print("Task not completed.") | ||
# TODO: ask assistant "are you sure you want to complete the task?" to give it a chance to think some more | ||
# TODO: ask assistant "was the task completed successfully?" to get feedback | ||
|
||
# raise Completed to signal task finished, will gracefully exit | ||
return Completed("Task completed successfully", value) | ||
|
||
|
||
def check_completion() -> bool: | ||
"""Check if the current task has been completed.""" | ||
# TODO: run actual completion checks, like pre-commit hooks, tests, etc. | ||
return True | ||
|
||
|
||
tool = ToolSpec( | ||
"attempt_complete", | ||
desc="Completes the request. Used as part of autonomous operation to let the assistant signal that the request has completed.", | ||
instructions="Call this to attempt to complete the current task, after running final checks. Must ALWAYS be called to signal completion when done with all tasks.", | ||
functions=[attempt_complete], | ||
disabled_by_default=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters