-
Notifications
You must be signed in to change notification settings - Fork 241
feat(delegate): File-based agent definitions with markdown + YAML frontmatter #2183
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
Merged
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ba87b4e
first version MD agents
VascoSch92 ce6b225
update
VascoSch92 475881c
update
VascoSch92 6d892f7
update after discussion
VascoSch92 e0fb41b
all-hands bot feedback
VascoSch92 455c8ff
roasted-review feedback
VascoSch92 0754db0
docstrings
VascoSch92 ea1863e
add example
VascoSch92 36fdf3e
change number of example
VascoSch92 d38a9e5
Apply suggestion from @enyst
enyst b1495ad
comments and feedback
VascoSch92 6fe32d4
Merge branch 'main' into vasco/issue-2049
VascoSch92 03e4cda
fix after rebase and discussion
VascoSch92 b33defb
nit
VascoSch92 1aace23
fix tests
VascoSch92 d40971b
Merge branch 'main' into vasco/issue-2049
VascoSch92 38acb66
fix after rebase
VascoSch92 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from openhands.sdk.subagent.builtins import get_default_agent | ||
| from openhands.sdk.subagent.load import ( | ||
| load_project_agents, | ||
| load_user_agents, | ||
| ) | ||
| from openhands.sdk.subagent.registry import ( | ||
| get_agent_factory, | ||
| get_factory_info, | ||
| register_agent, | ||
| register_agent_if_absent, | ||
| register_file_agents, | ||
| register_plugin_agents, | ||
| ) | ||
| from openhands.sdk.subagent.schema import AgentDefinition | ||
|
|
||
|
|
||
| __all__ = [ | ||
| # loading | ||
| "load_user_agents", | ||
| "load_project_agents", | ||
| # agent registration | ||
| "register_agent", | ||
| "register_file_agents", | ||
| "register_plugin_agents", | ||
| "register_agent_if_absent", | ||
| "get_factory_info", | ||
| "get_agent_factory", | ||
| # Agent classes | ||
| "AgentDefinition", | ||
| # builtin agents | ||
| "get_default_agent", | ||
| ] |
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,4 @@ | ||
| from openhands.sdk.subagent.builtins.default import get_default_agent | ||
|
|
||
|
|
||
| __all__ = ["get_default_agent"] |
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,37 @@ | ||
| from functools import cache | ||
|
|
||
| from openhands.sdk.subagent.registry import AgentFactory, _agent_definition_to_factory | ||
| from openhands.sdk.subagent.schema import AgentDefinition | ||
|
|
||
|
|
||
| @cache | ||
| def _build_default_agent_factory( | ||
| enable_browser: bool = True, | ||
| ) -> AgentFactory: | ||
| """Return an AgentFactory class describing for the default agent. | ||
|
|
||
| Args: | ||
| enable_browser: Whether to include browser tools. | ||
|
|
||
| Returns: | ||
| An AgentFactory class describing the default agent. | ||
| """ | ||
|
|
||
| tool_names = ["terminal", "file_editor", "task_tracker"] | ||
| if enable_browser: | ||
| tool_names.append("browser_tool_set") | ||
|
|
||
| agent_def = AgentDefinition( | ||
| name="default", | ||
| description="Default general-purpose agent", | ||
| model="inherit", | ||
| tools=tool_names, | ||
| ) | ||
| return AgentFactory( | ||
| factory_func=_agent_definition_to_factory(agent_def), | ||
| description=agent_def.description or "Default general-purpose agent", | ||
| ) | ||
|
|
||
|
|
||
| def get_default_agent(enable_browser: bool = False) -> AgentFactory: | ||
|
VascoSch92 marked this conversation as resolved.
Outdated
|
||
| return _build_default_agent_factory(enable_browser=enable_browser) | ||
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.