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

Add new CommitWriterAgent to auto-generate commit messages from staged diffs #1484

Merged
merged 5 commits into from May 2, 2024

Conversation

li-boxuan
Copy link
Collaborator

@li-boxuan li-boxuan commented May 1, 2024

This commit introduces the CommitWriterAgent along with its configuration and detailed task description. The agent is designed to analyze git diffs staged for commit and automatically generate succinct and relevant commit messages.

--------THE ABOVE COMMIT MESSAGE (INCLUDING PR TITLE) IS GENERATED BY COMMITWRITERAGENT---------

I couldn't have written a better commit message than OpenDevin. So yeah, above is my commit message. If you are looking at this PR simply because you want to learn how to build a new micro-agent, you could stop reading.

Other things I would like to discuss (oops, seems I still know more than the agent):

I added a new field called devnote in agent.yaml. This field is not rendered as part of prompt. My intention is that micro-agents sometimes need short explanation/justification/mini design doc. Developers could use this field to document them, rather than create a new README under every micro-agent. Hey, I don't know, maybe it's a better idea to create a README instead? I rethink about it and I now feel we should use README instead of a dedicated field in yaml for documentation purpose.

As you can see, I leave two TODOs:

  1. We should allow users or other agents to give feedback on how the commit message could be improved. This can be easily done by adding a field to the inputs, but it would require some work to set up coordination between agents and between agent-human (I know there's some great ongoing work for this: feat(CodeActAgent): Support Agent-User Interaction during Task Execution and the Full Integration of CodeActAgent #1290). We probably also need a way to allow customers to pass that information directly as a command line arg (so that one doesn't need to worry about coordination, when developing an agent like this).
  2. Currently, we don't have a way to let the agent bail out (or escalate): Micro-agent: Support task rejection #1482. If the working directory is not even a git repo, the agent will be trapped in an endless loop and run git diff --cached forever. A workaround would be to let the agent finish with "NO" message (verified it worked), but ideally we should make it as an action.

How to run this agent?

WORKSPACE_MOUNT_PATH="`pwd`" SANDBOX_TYPE="exec" \
  poetry run python opendevin/main.py -t "dummy task: we do not need this but currently OpenDevin requires a task" -c CommitWriterAgent -d ./

Somehow, ssh sandbox doesn't work - it gets stuck when running git diff --cached command.

What about tests? I am still thinking what would be the best way to write an integration test for this... Currently, tests/integration/test_agent.py is mostly for general tasks that can be completed by multiple agents. We have a matrix in CI that can run those tests against different sandboxes AND different agents. How shall we organize the tests & CI for specialized agents?

…d diffs

This commit introduces the CommitWriterAgent along with its configuration and detailed task description. The agent is designed to analyze git diffs staged for commit and automatically generate succinct and relevant commit messages.
@li-boxuan li-boxuan added enhancement New feature or request agent framework strategies for prompting, agent, etc labels May 1, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@0d77f49). Click here to learn what that means.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1484   +/-   ##
=======================================
  Coverage        ?   60.91%           
=======================================
  Files           ?       84           
  Lines           ?     3628           
  Branches        ?        0           
=======================================
  Hits            ?     2210           
  Misses          ?     1418           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@li-boxuan li-boxuan removed the agent framework strategies for prompting, agent, etc label May 1, 2024
@li-boxuan li-boxuan added the micro agent add or update a micro-agent label May 2, 2024
Copy link
Collaborator

@rbren rbren left a comment

Choose a reason for hiding this comment

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

Love this!

@rbren rbren merged commit 11d8253 into OpenDevin:main May 2, 2024
23 checks passed
@li-boxuan li-boxuan deleted the micro/commit-writer-agent branch May 2, 2024 17:03
yimothysu pushed a commit to yimothysu/OpenDevin that referenced this pull request May 3, 2024
…d diffs (OpenDevin#1484)

* Add new CommitWriterAgent to auto-generate commit messages from staged diffs

This commit introduces the CommitWriterAgent along with its configuration and detailed task description. The agent is designed to analyze git diffs staged for commit and automatically generate succinct and relevant commit messages.

* Remove devnote section from yaml and add README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request micro agent add or update a micro-agent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants