-
Notifications
You must be signed in to change notification settings - Fork 351
Support listing and deleting recorded agent actions #6571
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
Open
ayoubdiourin7
wants to merge
14
commits into
mozilla:master
Choose a base branch
from
ayoubdiourin7:feature/manage-agent-actions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+333
−57
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
202320c
Support listing and deleting recorded agent actions
ayoubdiourin7 c582040
Disable recorded action tools for agents
ayoubdiourin7 8a5bef1
Merge branch 'master' into feature/manage-agent-actions
ayoubdiourin7 adf58b9
resolve conflicts
ayoubdiourin7 962b684
Simplify the recorded action removal response
ayoubdiourin7 0f6dd27
Use stable action IDs in Try Server confirmations
ayoubdiourin7 c99c465
Use opaque action IDs and return them atomically
ayoubdiourin7 de9fab7
Format recorded actions as a Markdown table
ayoubdiourin7 83547bc
Simplify recorded action tool descriptions
ayoubdiourin7 0da937d
Use action IDs for attachment paths
ayoubdiourin7 9afe860
Clarify remove_action docstring
ayoubdiourin7 051c813
Return a clear action removal confirmation
ayoubdiourin7 8b6387b
Merge master and resolve TestRail action conflict
ayoubdiourin7 a744bc4
Merge branch 'master' into feature/manage-agent-actions
ayoubdiourin7 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
53 changes: 53 additions & 0 deletions
53
libs/hackbot-runtime/hackbot_runtime/actions/recorded_actions.py
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,53 @@ | ||
| """Agent-facing tools for inspecting and retracting recorded actions.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Annotated | ||
|
|
||
| from agent_tools.registry import tool, tools_in | ||
| from pydantic import Field | ||
|
|
||
| from hackbot_runtime.actions.recorder import ActionsRecorder | ||
|
|
||
|
|
||
| def _table_cell(value: str | None) -> str: | ||
| """Format one value for a Markdown table cell.""" | ||
| if value is None: | ||
| return "" | ||
| return "<br>".join(value.splitlines()).replace("|", r"\|") | ||
|
|
||
|
|
||
| @tool | ||
| async def list_actions(recorder: ActionsRecorder) -> str: | ||
| """List the actions currently proposed by this agent run. | ||
|
|
||
| Returns a Markdown table with each action's ID, type, and reasoning. | ||
| """ | ||
| actions = recorder.list_actions() | ||
| if not actions: | ||
| return "No recorded actions." | ||
|
|
||
| rows = ["| ID | Action | Reasoning |", "| --- | --- | --- |"] | ||
| rows.extend( | ||
| f"| {_table_cell(action['action_id'])} " | ||
| f"| {_table_cell(action['type'])} " | ||
| f"| {_table_cell(action.get('reasoning'))} |" | ||
| for action in actions | ||
| ) | ||
| return "\n".join(rows) | ||
|
|
||
|
|
||
| @tool | ||
| async def remove_action( | ||
| recorder: ActionsRecorder, | ||
| action_id: Annotated[ | ||
| str, | ||
| Field(description="ID of the action to remove."), | ||
| ], | ||
| ) -> str: | ||
| """Remove the recorded action with the given ID.""" | ||
| recorder.remove_action(action_id) | ||
| return f"Removed recorded action {action_id}." | ||
|
|
||
|
|
||
| TOOLS = tools_in(__name__) |
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 |
|---|---|---|
|
|
@@ -70,8 +70,8 @@ async def post_message( | |
|
|
||
| Recorded into the run summary for human review -- does not post to Slack. | ||
| """ | ||
| recorder.record(ACTION_TYPE, _params(channel, text), reasoning=reasoning) | ||
| return f"Recorded {ACTION_TYPE} (#{len(recorder.actions) - 1})." | ||
| action = recorder.record(ACTION_TYPE, _params(channel, text), reasoning=reasoning) | ||
| return f"Recorded {ACTION_TYPE} (ID: {action['action_id']})." | ||
|
Comment on lines
+73
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should file a follow-up issue to centralize the confirmation message.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filed #6697 |
||
|
|
||
|
|
||
| def record_message( | ||
|
|
||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we call it
actions_manageror something related instead ofrecorded_actions? WDYT?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actions_managerfeels a little generic. What aboutrecorded_actions_manageroraction_records? However, I’m also fine withactions_manager.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Let's go with
action_records.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, the file name should match to keep things consistent.