Managing Context

LatchLoop’s Instant Context™ system is designed to make sure the AI agent always has the right code and file context to generate high-quality, relevant code changes for your tasks. This article explains how context management works in LatchLoop, how you can control which files are included, and how context is handled during the build and PR feedback process.


What is “Context” in LatchLoop?

Context refers to all the information the AI coding agent uses to understand your task and generate code. This includes:

  • Your task description
  • The project type and settings
  • The content of relevant files from your codebase
  • Recent changes and message history
  • Any additional files or code snippets you select

Instant Context™: How LatchLoop Selects Files

When you work on a task, LatchLoop automatically analyzes your task description and the project’s file structure to suggest the most relevant files. This is called Instant Context™.

  • Automatic Suggestions: LatchLoop uses AI to scan your task description and the project’s file tree, then suggests up to three files that are likely to be important for your task.
  • File Tray: These suggestions appear in the file tray, where you can review, add, or remove files before the AI uses them.

Managing Files in the File Tray

You have full control over which files are included as context for the AI:

1. Toggling File Inclusion

  • Enable/Disable File Tray: Use the “File Contents” toggle to turn on or off the inclusion of file contents in your task context.
  • Select/Deselect Files: Click on files in the tray to include or exclude them. Selected files will be sent to the AI agent as part of the context.

2. Searching and Adding Files

  • Search Bar: Use the search bar (press / as a shortcut) to quickly find files by name or path.
  • AI Suggestions: When searching, you’ll see both your search results and AI-suggested files. Suggested files are labeled as “Suggested” and are based on your task description.
  • Add Files: Click on any file in the search results or suggestions to add it to your context.

3. Keyboard Shortcuts

  • Toggle File Tray: Press A to quickly toggle the file tray.
  • Select Files: Press 1-9 to toggle the first nine files in the tray.
  • Open File Search: Press / to open the file search dialog.

What Happens If You Don’t Select Files?

If you don’t manually select any files, LatchLoop’s Build action will automatically gather the most relevant files for you:

  • When you click “Build,” the agent will analyze your task and automatically pull in file contents based on its analysis and suggestions.
  • This ensures the AI always has enough context, even if you haven’t manually chosen files.

Context in the PR Feedback Process

When you’re reviewing a Pull Request (PR) and providing feedback or asking questions, LatchLoop uses a rich set of context to give accurate and relevant responses:

  • Recent Changes: LatchLoop can see all recent changes it made, as well as changes you made.
  • Task Description: The most up-to-date task description is always included.
  • Message History: The full conversation and feedback history is available to the agent.
  • Tools: LatchLoop can look up additional information, search code, and read files as needed to answer your questions or make further changes.

This means your feedback and questions are always considered in the context of the latest code and discussion.


Prompt Input Token Counter

At the top of your task, you’ll see a token counter. This shows how much information (in “tokens”) will be sent to the AI model for your current task.

  • What’s Included: The token count includes your task description, all included file contents, and any other base context.
  • Why It Matters: Staying within token limits ensures the AI can process your request efficiently and accurately.

Summary: Best Practices

  • Let LatchLoop Suggest: Rely on Instant Context™ for automatic file suggestions, especially if you’re unsure which files are needed.
  • Fine-Tune as Needed: Use the file tray and search to add or remove files for more precise control.
  • Don’t Worry About Forgetting Files: The Build action will always ensure enough context is included, even if you don’t select files yourself.
  • Use Shortcuts: Speed up your workflow with keyboard shortcuts for toggling, searching, and selecting files.

If you have more questions about context management or need help troubleshooting, please contact our support team or check out the in-app shortcut help (Shift + ?).