Skip to content
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

refactor: restructure microagents system #5886

Merged
merged 55 commits into from
Jan 2, 2025
Merged

Conversation

xingyaoww
Copy link
Collaborator

@xingyaoww xingyaoww commented Dec 28, 2024

This PR restructures the microagents system to provide a clearer separation between repository-specific instructions and shareable microagents.

Key Changes

  1. Two Sources for Instructions

    • Repository Instructions: .openhands/microagents/repo.md in each repository
      • Private to each repository
      • Repository-specific guidelines
      • Team practices and conventions
    • Shareable Microagents: OpenHands/microagents/
      • Available to all users
      • Reusable knowledge and workflows
      • Maintained in OpenHands repository
  2. Simplified Hub Structure

    OpenHands/microagents/
    ├── knowledge/  # Keyword-triggered expertise
    └── tasks/     # Interactive workflows
    
  3. Documentation

    • Clear separation between private and shareable content
    • Better examples and guidelines
    • Clearer contribution process
    • Loading order explanation
  4. Code Changes

    • New microagent models with validation
    • Support for both knowledge and task agents
    • Improved loading and matching system
    • Comprehensive test coverage

Migration Notes

  • Move repository-specific instructions to .openhands/microagents/repo.md in each repository
  • Convert shareable agents to new YAML format
  • Keep private content in repositories, share reusable knowledge in OpenHands

Part of #5538 and #5826


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:3b5523b-nikolaik   --name openhands-app-3b5523b   docker.all-hands.dev/all-hands-ai/openhands:3b5523b

- Move microagents to root level directory
- Convert existing agents to YAML format
- Add support for repository and keyword triggers
- Add template-based workflow support
- Remove old micro directory
- Add MicroAgentHub for centralized agent management
- Support repository and keyword triggers
- Add template-based agent support
- Update base.py to use new system
- Add tests for knowledge agent validation
- Add tests for template agent validation
- Add tests for agent loading and matching
- Add tests for template processing
- Keep legacy microagent test
- Add environment variable testing to new agents
- Add comprehensive tests for new microagent system
- Move all tests to tests/unit
- Remove repo/ directory (should be in individual repos)
- Move keyword agents to knowledge/ directly
- Update documentation to reflect new structure
- Remove official/community split
- Rename templates to tasks
- Move all agents to top-level categories
- Update documentation
- Convert all YAML files to markdown with frontmatter
- Improve readability with better formatting
- Keep YAML metadata in frontmatter
- Add better examples and documentation
- Update format guidelines to show markdown with frontmatter
- Add better examples for both agent types
- Show recommended structure for content
- Add markdown parsing with YAML frontmatter
- Update models to handle markdown content
- Rename template to task for clarity
- Add better input validation
- Update tests for new format
@neubig neubig self-assigned this Dec 30, 2024
neubig and others added 2 commits December 31, 2024 09:07
- Use os.walk() to recursively find microagent files in subdirectories
- Update CodeActAgent to use correct microagents path
- Fix prompt caching tests to work with new structure
microagents/README.md Outdated Show resolved Hide resolved
└── repo.md # Repository-specific instructions
```

## 2. Shareable Microagents (Public)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that these should be mentioned first, since they are common to all users.

microagents/README.md Outdated Show resolved Hide resolved
tests/unit/test_codeact_agent.py Outdated Show resolved Hide resolved
openhands-agent and others added 2 commits December 31, 2024 01:02
- Remove config.use_microagents = False from test fixture
- Tests now run with microagents enabled, matching real-world usage
- Add brief intro explaining what microagents are
- Reorder sections to mention shareable microagents first
- Remove vague testing section
@neubig neubig force-pushed the microagents-restructure branch from f3fa573 to d633578 Compare December 31, 2024 01:06
microagents/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @xingyaoww could you double-check for final approval and merge if everything looks good?

@neubig neubig marked this pull request as ready for review December 31, 2024 01:08
@neubig
Copy link
Contributor

neubig commented Dec 31, 2024

I think the UI related stuff can be handled in a future PR FWIW. And microagents being enabled by default is true in main now right?

@neubig neubig assigned xingyaoww and unassigned neubig Dec 31, 2024
@neubig neubig dismissed their stale review December 31, 2024 20:54

Large code changes since last review.

@xingyaoww
Copy link
Collaborator Author

I think the UI related stuff can be handled in a future PR FWIW

yep! I'll make sure our existing capability of micro-agent is intact and call it off for this PR.

And microagents being enabled by default is true in main now right?

yep! I'll send off another PR to disable it by default and only enable it for UI

@xingyaoww
Copy link
Collaborator Author

xingyaoww commented Jan 2, 2025

@neubig Actually i think this is probably ready for another look (I got failing tests passed locally) and this is working in UI as well

image

@xingyaoww xingyaoww requested a review from rbren January 2, 2025 03:46
@neubig neubig self-requested a review January 2, 2025 05:01
@neubig neubig assigned neubig and unassigned xingyaoww Jan 2, 2025
Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great to me! Just a few small comments.

microagents/README.md Outdated Show resolved Hide resolved
microagents/README.md Outdated Show resolved Hide resolved
microagents/README.md Outdated Show resolved Hide resolved
openhands/microagent/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this!

@neubig neubig merged commit c1b514e into main Jan 2, 2025
14 checks passed
neubig added a commit that referenced this pull request Jan 2, 2025
Co-authored-by: openhands <[email protected]>
Co-authored-by: Graham Neubig <[email protected]>
@neubig neubig deleted the microagents-restructure branch January 2, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants