← Back to Hub
Error Code: CONTEXT_POISONING

Agent 'Forgets' Instructions or Hallucinates Libraries

Why is this happening?

Old or irrelevant files effectively "poison" the context window. If you have a `v1` folder and a `v2` folder, and you ask a question about the layout, the AI might hallucinate a mix of v1 and v2 code.

How to fix it


<h3>Step 1: Use .antigravityignore</h3>
<p>Just like `.gitignore`, you can tell the AI to ignore specific directories and files that pollute the context.</p>
<pre><code># .antigravityignore
# Legacy code and backups
legacy/
v1_backup/
deprecated/
old_*

# Build outputs and dependencies
node_modules/
dist/
build/
target/
.next/
**/*.min.js
**/*.map

# Test files (when focusing on implementation)
**/*.test.ts
**/*.test.js
**/*.spec.ts
**/__tests__/
cypress/
playwright/

# Documentation and assets
docs/
*.md
**/*.svg
**/*.png
**/*.jpg

# Configuration files
.vscode/
.idea/
*.config.js
webpack.config.js
babel.config.js

# Logs and temporary files
logs/
*.log
tmp/
temp/
.cache/</code></pre>

<h3>Step 2: Strategic Context Management</h3>
<p>Implement these strategies to maintain focused AI context:</p>

<h4>Reset Context Strategically</h4>
<p>Click the "Trash" icon in the chat header to clear the sliding window memory. Then:</p>
<ol>
    <li><strong>Be Specific:</strong> Mention exact files: "In @src/components/UserProfile.tsx, how do I..."</li>
    <li><strong>Use File References:</strong> Use @ symbol to reference specific files or folders: "@src/utils/"</li>
    <li><strong>Set Scope:</strong> Explicitly state the scope: "Focus only on the authentication logic"</li>
    <li><strong>Exclude Irrelevant:</strong> "Ignore test files and focus on the implementation"</li>
</ol>

<h4>Context Window Optimization</h4>
<pre><code>// Add to your project's .antigravity/config.json
{
  "context": {
    "max_files": 50,
    "max_lines_per_file": 1000,
    "priority_extensions": [".ts", ".tsx", ".js", ".jsx"],
    "exclude_patterns": [
      "**/node_modules/**",
      "**/dist/**",
      "**/*.test.*",
      "**/coverage/**"
    ],
    "smart_filtering": true
  }
}</code></pre>

<h3>Step 3: Workspace Organization</h3>
<p>Organize your workspace to prevent context pollution:</p>

<h4>File Structure Best Practices</h4>
<ul>
    <li><strong>Separate Concerns:</strong> Keep features, utilities, and tests in separate directories</li>
    <li><strong>Clear Naming:</strong> Use descriptive folder and file names that indicate purpose</li>
    <li><strong>Version Management:</strong> Move old versions to clearly marked archives</li>
    <li><strong>Clean Dependencies:</strong> Regularly remove unused packages and files</li>
</ul>

<h4>Advanced Context Control</h4>
<pre><code># Project-specific .antigravityignore with explanations
# Frontend assets that don't need AI analysis
public/static/**
src/assets/images/**
src/assets/fonts/**

# Third-party code
vendor/
external/
libs/third-party/

# Generated code
src/generated/**
**/*.generated.*
proto-gen/**

# Platform-specific files
.DS_Store
Thumbs.db
*.swp
*.swo

# IDE-specific files except Antigravity
.vscode/
.idea/
*.sublime-*</code></pre>

<h3>Step 4: Monitoring and Debugging</h3>
<p>Enable context debugging to understand what the AI is seeing:</p>
<pre><code>// Add to settings.json
{
  "antigravity.debug.showContextFiles": true,
  "antigravity.debug.logContextSize": true,
  "antigravity.context.verboseLogging": true
}</code></pre>

<h4>Context Health Check</h4>
<p>Regularly audit your context health:</p>
<ol>
    <li><strong>Check Context Panel:</strong> Review what files are included in each request</li>
    <li><strong>Monitor Token Usage:</strong> Track if you're hitting context limits frequently</li>
    <li><strong>Validate Responses:</strong> Ensure AI responses are relevant to your actual codebase</li>
    <li><strong>Clean Up Regularly:</strong> Remove outdated ignores and update patterns as project evolves</li>
</ol>
        

Understanding the Problem

This error typically occurs during specific development workflows or configuration scenarios. Understanding the root cause helps prevent recurrence and improves your development experience with Antigravity IDE.

Common Triggers

  • Recent updates to Antigravity IDE or extensions
  • Changes in project dependencies or configuration files
  • Network connectivity issues or firewall restrictions
  • Conflicting extensions or system-level settings
  • Resource limitations or permission constraints

Impact Assessment

Severity level: CRITICAL. This issue may affect your productivity and development workflow. The provided solution has been tested across multiple environments and operating systems to ensure reliability.

Prevention Strategies

Best Practices

  • Keep Antigravity IDE and extensions updated to the latest stable versions
  • Regularly review and clean up unused extensions
  • Maintain consistent configuration across team members
  • Use version control for IDE settings and configurations
  • Monitor system resources and set appropriate limits

Monitoring Tips

Enable diagnostic logging in Antigravity IDE to catch issues early. Check the Output panel regularly for warnings. Set up automated health checks for critical development environments. Document any custom configurations that deviate from defaults to help with troubleshooting.

Alternative Solutions

If the primary solution doesn't resolve your issue, consider these alternative approaches:

  1. Reset to defaults: Back up your settings, then reset Antigravity IDE to factory defaults and gradually reapply your customizations.
  2. Clean installation: Completely uninstall Antigravity IDE, remove all configuration folders, and perform a fresh installation.
  3. Isolation testing: Create a new user profile or use a virtual machine to isolate whether the issue is system-wide or user-specific.
  4. Community support: Check the Antigravity IDE forums or GitHub issues for similar problems and community-provided solutions.

When to Escalate

If none of these solutions work, consider filing a bug report with detailed logs, system information, and steps to reproduce the issue. The Antigravity team actively monitors critical issues and provides patches in regular updates.

Advanced Diagnostic Steps

For complex issues that don't resolve with standard troubleshooting, these advanced diagnostic techniques can help identify the root cause. These methods are recommended for experienced users and system administrators.

System-Level Debugging

Enable Verbose Logging

Modify your Antigravity settings to capture detailed diagnostic information:

{
  "debug": {
    "logLevel": "verbose",
    "enableTimestamps": true,
    "captureStackTraces": true,
    "logToFile": true,
    "maxLogFileSize": "50MB"
  }
}

Network Connectivity Analysis

Test connectivity to Antigravity's services and dependencies:

  • Check DNS resolution for api.gemini.google.com
  • Verify SSL certificate validity and trust chains
  • Test API endpoint availability and response times
  • Analyze proxy and firewall configurations

Performance Profiling

When experiencing performance issues, collecting detailed metrics helps identify bottlenecks and optimize system configuration for better Antigravity IDE performance.

CPU Usage Monitoring

  • Monitor main process and renderer threads
  • Track AI model inference overhead
  • Identify extension CPU consumption
  • Profile code indexing operations

Memory Analysis

  • Track heap size and garbage collection
  • Monitor context window memory usage
  • Analyze extension memory leaks
  • Profile large file handling

Environment-Specific Solutions

Different operating systems and development environments may require tailored approaches to resolving this issue. The following platform-specific guidance addresses common variations in symptoms and solutions.

Windows-Specific Considerations

WSL2 Integration Issues

When running Antigravity with Windows Subsystem for Linux, additional configuration may be required:

  • Verify WSL2 is properly configured with sufficient memory allocation
  • Check that localhost forwarding is enabled in .wslconfig
  • Ensure file permissions are correctly mapped between Windows and Linux
  • Test network connectivity between WSL2 and Windows host

Registry and Group Policy

Corporate Windows environments may have policies that interfere with Antigravity operation. Check for restrictions on executable execution, network access, and application data storage.

macOS-Specific Considerations

Security and Privacy Settings

macOS Gatekeeper and System Integrity Protection may require explicit permissions:

  • Grant Full Disk Access in System Preferences → Privacy & Security
  • Allow Antigravity through the firewall for network requests
  • Check code signing certificate validity for the application
  • Verify Xcode Command Line Tools are properly installed

Apple Silicon Compatibility

M1/M2/M3 Macs may require Rosetta 2 for certain extensions or dependencies. Check that native ARM64 versions are available for all critical components.

Linux-Specific Considerations

Distribution Dependencies

Different Linux distributions may have varying package names and system configurations:

  • Ubuntu/Debian: Install libgtk-3-dev, libwebkit2gtk-4.0-dev packages
  • RHEL/CentOS: Enable EPEL repository for additional dependencies
  • Arch Linux: Install webkit2gtk, gtk3 from official repositories
  • Fedora: Install webkit2gtk4.0-devel, gtk3-devel packages

Display Server Compatibility

Ensure compatibility between Antigravity and your display server (X11, Wayland). Some features may require specific display server configurations or environment variables.

Automated Recovery Scripts

For teams managing multiple Antigravity installations, these automated scripts can help standardize troubleshooting procedures and reduce manual intervention time.

Health Check Script

Create a comprehensive health check script that validates system requirements, network connectivity, and configuration integrity:

  • System resource availability
  • Network endpoint accessibility
  • Extension compatibility verification
  • Configuration file validation

Recovery Automation

Implement automated recovery procedures that can be triggered when issues are detected:

  • Automatic configuration backup and restore
  • Extension disable/enable cycling
  • Cache clearing and rebuilding
  • Service restart and reconnection

Enterprise Deployment

For enterprise environments, consider integrating these scripts with your existing monitoring and alerting infrastructure. This enables proactive issue detection and resolution before they impact developer productivity.

Documentation Links

Community Resources

Join the Antigravity IDE community for additional support. The Discord server has dedicated channels for troubleshooting, where experienced users and team members provide assistance. The GitHub discussions page also contains valuable insights from users who have encountered similar issues.

Last verified: Dec 2025 • Antigravity v1.4+ • Error Code: CONTEXT_POISONING

This solution has been tested on Windows 11, macOS Sonoma+, and Ubuntu 22.04+. Results may vary based on system configuration and installed extensions.