-
Notifications
You must be signed in to change notification settings - Fork 185
Subtasks #851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Subtasks #851
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4000d46
subtasks commit
arikalon1 d0dc615
improvements
arikalon1 0e28090
subtasks commit
arikalon1 3b9f95f
improvements
arikalon1 5f31e18
prompt changes
arikalon1 cde0932
prompt changes
arikalon1 fc9a805
test fix
arikalon1 791b647
test fix
arikalon1 057a3c3
Merge remote-tracking branch 'origin/subtasks' into subtasks
arikalon1 86919c0
remove debug info
arikalon1 e3a637b
organize the code
arikalon1 b18329e
increase max steps default
arikalon1 2f850d3
Merge remote-tracking branch 'origin/master' into subtasks
arikalon1 749d935
increase max steps default
arikalon1 8dc43ba
fix parameter types for openai schema conversion
arikalon1 0301614
fix tests
arikalon1 633e185
cr fix
arikalon1 ba127fe
cr fix
arikalon1 2b750ee
Merge branch 'master' into subtasks
arikalon1 fecfc9e
cr fix
arikalon1 997886d
Merge branch 'master' into subtasks
arikalon1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,88 @@ | ||
| from typing import Dict, List | ||
| from threading import Lock | ||
|
|
||
| from holmes.plugins.toolsets.investigator.model import Task, TaskStatus | ||
|
|
||
|
|
||
| class TodoListManager: | ||
| """ | ||
| Session-based storage manager for investigation TodoLists. | ||
| Stores TodoLists per session and provides methods to get/update tasks. | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| self._sessions: Dict[str, List[Task]] = {} | ||
| self._lock: Lock = Lock() | ||
|
|
||
| def get_session_tasks(self, session_id: str) -> List[Task]: | ||
| with self._lock: | ||
| return self._sessions.get(session_id, []).copy() | ||
|
|
||
arikalon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def update_session_tasks(self, session_id: str, tasks: List[Task]) -> None: | ||
| with self._lock: | ||
| self._sessions[session_id] = tasks.copy() | ||
arikalon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def clear_session(self, session_id: str) -> None: | ||
| with self._lock: | ||
| if session_id in self._sessions: | ||
| del self._sessions[session_id] | ||
|
|
||
| def get_session_count(self) -> int: | ||
| with self._lock: | ||
| return len(self._sessions) | ||
|
|
||
| def format_tasks_for_prompt(self, session_id: str) -> str: | ||
| """ | ||
| Format tasks for injection into system prompt. | ||
| Returns empty string if no tasks exist. | ||
| """ | ||
| tasks = self.get_session_tasks(session_id) | ||
|
|
||
| if not tasks: | ||
| return "" | ||
|
|
||
| status_order = { | ||
| TaskStatus.PENDING: 0, | ||
| TaskStatus.IN_PROGRESS: 1, | ||
| TaskStatus.COMPLETED: 2, | ||
| } | ||
|
|
||
| sorted_tasks = sorted( | ||
| tasks, | ||
| key=lambda t: (status_order.get(t.status, 3),), | ||
| ) | ||
|
|
||
| lines = ["# CURRENT INVESTIGATION TASKS"] | ||
| lines.append("") | ||
|
|
||
| pending_count = sum(1 for t in tasks if t.status == TaskStatus.PENDING) | ||
| progress_count = sum(1 for t in tasks if t.status == TaskStatus.IN_PROGRESS) | ||
| completed_count = sum(1 for t in tasks if t.status == TaskStatus.COMPLETED) | ||
|
|
||
| lines.append( | ||
| f"**Task Status**: {completed_count} completed, {progress_count} in progress, {pending_count} pending" | ||
| ) | ||
| lines.append("") | ||
|
|
||
| for task in sorted_tasks: | ||
| status_indicator = { | ||
arikalon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| TaskStatus.PENDING: "[ ]", | ||
| TaskStatus.IN_PROGRESS: "[~]", | ||
| TaskStatus.COMPLETED: "[✓]", | ||
| }.get(task.status, "[?]") | ||
|
|
||
| lines.append(f"{status_indicator} [{task.id}] {task.content}") | ||
|
|
||
| lines.append("") | ||
| lines.append( | ||
| "**Instructions**: Use TodoWrite tool to update task status as you work. Mark tasks as 'in_progress' when starting, 'completed' when finished." | ||
| ) | ||
|
|
||
| return "\n".join(lines) | ||
|
|
||
|
|
||
| _todo_manager = TodoListManager() | ||
|
|
||
|
|
||
| def get_todo_manager() -> TodoListManager: | ||
| return _todo_manager | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.