# Defining Context

### **A. Using Workspace Scope**

Tabnine defines a scope of context for your prompts with 1) designated files, 2) recent chat, 3) the open project, and more. This makes for higher-quality, context-aware completions. Used carelessly though, it can introduce noise or confusion.

This allows you to use to make:

1. Code-specific suggestions
2. Direct references to specific files
3. Implement project-specific changes

**Example Prompt:**

"Update the `validate_user()` function in this file to use the `is_email_valid()` method from `utils/validators.py`."

#### **1. When to Turn Off or Broaden Scope**

There are times you would want to be less narrow with scope so as not to limit the possibilities prompts elicit from the model:

1. Isolated examples or very specific code snippets might not benefit from the overly specific context of your project materials.
2. When restarting a conversation with the model, as in you might think a clean slate is necessary to prompt new material
3. You need to debug an issue and want to do this independent of “context interference.”

**Example Scenario:**

If you prompt:

“Write a Python function that sorts a list of tuples,” but you have an *unrelated* file open that uses `namedtuple`, Tabnine might introduce concepts that weren’t intended for this task.

#### **2. Known Limitations**

Keep these limits in mind so you can be strategic with your prompt writing:

* **Only two recently opened files** are loaded into Tabnine’s context window.
* **Large or unrelated files** may crowd out more relevant content.
* Tabnine doesn’t infer relationships beyond what’s open—**module-level understanding is shallow**.
* **Implicit dependencies** (e.g., database connections, environment variables) won’t be loaded unless referenced directly.
* **Non-code files** (e.g., config files, markdown) are usually excluded unless explicitly referenced in a prompt.

### **B. Starting a Fresh Conversation**

During a thread/conversation Tabnine Chat contextualizes prior messages and local code context between prompts. This can help with continuity, but over time, *context drift* might interfere with making relevant responses. Given that, you should know when to give up on the thread and start a new one.

#### **1. Signs Context Has Drifted**

* The assistant misinterprets repeated prompts.
* It includes functions, files, or examples that you haven't recently referenced.
* Follow-ups degrade in relevance or quality.
* You find yourself saying, "Forget what I said before..." too often.
* Tabnine keeps pulling in old variable names, functions, or logic.
* It re-references things several prompts after you had successfully commanded it to ignore them

#### **2. How to Reset Focus Cleanly**

* Click "New Conversation" above the chat window or hit the cycling symbol in the upper right-hand corner.
* Close unrelated or noisy files in your IDE.
* Clearly reintroduce what you want in your new prompt.

**Example:**

"Let's start with a blank slate. Write a standalone function to normalize an array of numbers."

Tabnine will drop prior context and base its reply solely on this new input and current file state.

### **Navigating Chat History & Memory**

While Tabnine retains a short-term working memory of your session, it [*does not retain long-term history*](https://docs.tabnine.com/main/welcome/readme/privacy). However, recent interactions prior to the current conversation *can* strongly bias outputs, sometimes in ways that are unhelpful.

{% hint style="info" %}
**Agent vs. Pure Chat**

\
When you use Tabnine in your IDE, you’re not just chatting — you’re guiding an agent that operates over your project. Chat history shapes how it reasons. Additionally, remember that open files and repos shape what it can inspect and change. With that in mind, write prompts as if you’re giving standing instructions to a collaborator who’s working inside your repo.
{% endhint %}

#### **A. When Forgetting Fails**

Even though you explicitly told Tabnine to forget something, the model might see it as a strong suggestion or weigh that previous moment in the thread less in considering later responses in the conversation.

* You've explicitly told it to ignore previous input, but it still references earlier code or examples.
* Tabnine generates conflicting or contradictory code.
* It uses outdated context (e.g., old versions of functions).

#### **B. Prompting Defensively**

* Avoid ambiguous pronouns like "that" or "it." Instead, use "this function" or "the method in "`utils.py`." Be extremely deliberate and leave little to nothing unsaid. This also applies to specific code, specific open files, and other resources.
* Occasionally reintroduce your assumptions: e.g., "Assume we are working with a Flask app."

{% hint style="info" %}
*Note: Think about teaching a person the same topic. If you overload someone with information, they are more likely to forget minor points. Despite expecting an LLM to be more efficient, assume it is not and you can fall back on typical human-to-human conversational interactions.*
{% endhint %}

#### **C. RE-Iterate**

* Reiterate what you’re trying to achieve. In other words, reinforce your intent: e.g., "Only show the SQL query. Don't explain it."
* Use "New Conversation" liberally when switching tasks or codebases.

{% hint style="info" %}
*Note: Think of this in the way you would think about containers in cloud apps. Instead of introducing everything in a single monolith, you would break up an app’s functions into contained modules where code is easier to manage and change later.*
{% endhint %}

By managing memory expectations and explicitly controlling context, you reduce noise and get more reliable completions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tabnine.com/main/getting-started/tabnines-prompting-guide/defining-context.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
