Sub topic 3
Reviewing Agent Changes and Managing Limits
Assume you know Git commits, diffs, branches, and how to run a project’s tests. This chapter focuses on controlling an agent after it proposes work.
Review, accept, and undo changes
Treat agent output like a pull request from a fast collaborator. Inspect the diff before accepting it. Check that:
- The change matches the requested scope.
- Existing behavior and public interfaces remain intact.
- Tests cover the new behavior.
- No secrets, generated files, or unrelated formatting changes appear.
- The agent actually ran the relevant build or test command.
Accept changes in small groups when your editor supports it. This makes review easier and limits the effect of a mistake. Create a Git checkpoint before a broad task. If a change is wrong, use the editor’s undo or discard action for unaccepted edits, or restore the checkpoint with Git. Do not undo changes you did not verify first.
Adding tools with MCP servers
The Model Context Protocol (MCP) lets an agent connect to external tool servers. A server might provide access to a database, documentation system, or workspace filesystem. Configure only the servers the task needs, and restrict filesystem access to the project directory when possible.
Review a server’s command, arguments, permissions, and data flow before enabling it. An MCP tool can read sensitive data or perform external actions just like a terminal command.
Safety, permissions, and data handling
Approve commands deliberately. Deny commands that delete data, publish code, change permissions, or send information outside the workspace unless you intended that action. Keep credentials in environment variables or a secret manager. Never paste tokens into prompts or commit them to source control.
Agent mode beyond VS Code
JetBrains IDEs, Cursor, and similar editors expose comparable features: chat, file context, edits, terminal access, and review controls. Names and approval flows differ, so check which actions are automatic and which require confirmation.
Choosing a model
Use a faster, cheaper model for small edits and explanations. Choose a stronger model for unfamiliar code, multi-file changes, debugging, or tasks requiring careful planning. Validate either choice with tests and a diff.
Troubleshooting and known limits
Lost context often causes incomplete edits. Attach the relevant files and state acceptance criteria. Runaway edits usually indicate an overly broad prompt, so narrow the scope and work in checkpoints. For failing tool calls, inspect the command, permissions, working directory, and server status. If the agent repeats an error, stop the loop and investigate the first failure directly.
Exercise
What should you do before accepting a multi-file agent change?
Show answer
Inspect the diff, confirm the scope, check for secrets or unrelated edits, and run the relevant tests or build commands.