Agent
Sweep automatically implements unit tests, boilerplate code, prototypes, and well-specified features. This is in real time! We haven't sped anything up.
Sweep found and edited three files in just under 15 seconds to refactor issue to use dataclasses
.
Using Agent
Press ⌘/ctrl J
or click the Sweep icon to open our Agent sidebar.
When you first open a project, Sweep starts indexing your codebase.
This allows Sweep to automatically pull in relevant files as you code. You can begin using Sweep in Manual mode.
After a few moments, Sweep will finish indexing and automatically switch to Agent mode, which automatically searches your codebase and edits multiple files. (this is our recommended mode)
Accept/Reject changes
In each Agent chat, Sweep automatically applies changes to the files. You can click "Accept/Reject" on each change, or click "Accept All/Reject All".
Checkpoints
One of the core features of Agent is the ability to "checkpoint" and rollback to previous states. This gives you the freedom to experiment without losing your progress.
To do this, you can click "Restore Checkpoint", and either revert changes in bulk or one at a time. We track all changes since the chat was sent.
Chat Mode / Manual Mode
- Chat Mode: This searches the codebase for context, and doesn't automatically edit your code. Use this if you're asking questions or don't know the exact implementation you want yet.
- Manual Mode: This does not search the codebase, and doesn't automatically edit your code. Use this if the task you're working on needs very specific context, and you want to tailor it heavily.
You can toggle between modes using ⌘ .
or ctrl .
.
Tips & best practices
Sweep won't always get what you want. If you're not getting good results, here are things you can do:
One chat per task
It's best to keep the conversation focused on one task at a time. Otherwise, the previous messages in the thread can hurt the intelligence of the model.
To create a new chat you can press (⌘/ctrl N) or click "+ New Chat".
Describe the current and expected state
- Start by describing the current state:
currently, our app does xyz. I believe this happens in foo.py and it uses utils from bar.py. please confirm you understand
. - Ask Sweep to confirm it sees all relevant files for this. If not, work with Sweep to give it the relevant files using
@
-mentions. - Finally, ask it to implement what you want.
if the user clicks submit, we should save their data to disk. if this fails i want you to show an error screen, similar to the error screen from in auth.tsx
.
Use Manual mode with selected context
If your task is very challenging, having over 10 files or files that are over 2k lines of code can hurt performance.
You can avoid this by switching to manual mode and specify exactly the files you want the agent to look at.
You can also select specific lines of code by highlighting them and pressing ⌘/ctrl j
. This will help the AI make the change in the exact location you want.
Aggressively checkpoint and retry
Sometimes it's hard to know what will work. If your code change can be tested fairly quickly, just have the AI try one of your ideas and click "restore checkpoint" if it's not working.
After each attempt, you can edit your previous message or follow up to tell Sweep to try something else.
Keyboard Shortcuts
You can open Sweep using ⌘ J
or Ctrl J
or by clicking the Sweep icon in the sidebar.
Action | Mac | Windows/Linux |
---|---|---|
Add Code to Context | ⌘ Shift J | Ctrl Shift J |
Open/Close Chat | ⌘ J | Ctrl J |
New Chat | ⌘ N | Ctrl N |
Toggle Normal/Search | ⌘ . | Ctrl . |