Understanding Context
Context is the foundation of how Large Language Models (LLMs) work and directly affects the quality and relevance of the Gamecraft Agent's responses.Context is the foundation of how Large Language Mod
This guide explains how context works, how to interpret the context information shown in the UI, and how to optimize context for better performance.
What is Context?
Context in Large Language Models
Context refers to all the information that the AI model can "see" and remember during a conversation. Think of it as the AI's working memory - everything it knows about your current task, conversation history, and project state.
Unlike humans who can remember things indefinitely, LLMs have a fixed context window - a limit to how much information they can process at once. This is measured in tokens, which are roughly equivalent to words (though technical terms and code may use more tokens).
Context Components in Gamecraft Agent
When you interact with the Gamecraft Agent, your context includes:
System Prompt: Instructions that define the agent's personality and capabilities
Conversation History: Your messages and the agent's responses
Project Information: File contents, directory structure, terminal output
Environment Details: Operating system, tools available, workspace settings
Task Context: Current mode, previous actions, and ongoing objectives
Context Window Visualization
Understanding the Progress Bar
The Gamecraft Agent displays your context usage through a visual progress bar in the task header:
Context Window: [████████████▓▓▓░░░] 12.5K / 128K tokens
^Current ^Reserved ^AvailableColor-Coded Sections
Dark Gray: Tokens currently used by your conversation and project data
Medium Gray: Tokens reserved for the model's response
Light Gray: Available space for additional context
Hover Information
Hover over different sections of the progress bar to see:
Current Section: "12,500 tokens used of 128,000 total"
Reserved Section: "Reserved for model response: 25,600 tokens"
Available Section: "Available space: 89,900 tokens"
Token Count Display
Below the progress bar, you'll see detailed token metrics:
↑ Input Tokens: What you've sent to the AI (your messages + project context)
↓ Output Tokens: What the AI has generated in responses
Cache Writes/Reads: For models supporting prompt caching (faster, cheaper processing)
Context Management Strategies
Auto-Context Condensing
When your context window fills up, Gamecraft Agent can automatically manage it:
How It Works
Threshold Detection: When context usage exceeds your configured percentage (default: 100%)
Intelligent Summarization: The AI creates a concise summary of older conversation parts
Context Replacement: Older messages are replaced with the summary, freeing up space
Continuation: Your task continues with full context awareness
Configuration Options
In Settings → Context Management:
Auto Condense Context: Enable/disable automatic condensing
Trigger Percentage: When to start condensing (50-100% of context window)
Condensing API: Which AI model to use for summarization
Custom Prompt: Personalize how summaries are created
Manual Context Management
Condense Context Button
Click the Fold button (🗜️) in the task header to manually trigger context condensing:
Useful before starting complex operations
Helps prevent mid-task interruptions
Preserves all important information while reducing token usage
Starting Fresh
When context becomes unwieldy:
Export Current Task: Save your progress before starting over
Close Task: End the current conversation
New Task: Begin with clean context, referencing exported work if needed
Context Optimization Techniques
Effective Context Usage
Be Selective with File Mentions
Instead of including entire directories:
# Less Efficient
@src/ @tests/ @docs/# More Efficient
@src/components/UserAuth.tsx @tests/auth.test.tsUse Specific References
Target exactly what you need:
# Vague
"Look at my authentication system"# Specific
"Review @src/auth/loginHandler.ts for the JWT validation logic"Strategic Information Sequencing
Start with the most important context:
Core Problem: What you're trying to solve
Relevant Files: Specific code that needs attention
Error Messages: If debugging
Additional Context: Background information if space allows
Context-Aware Prompt Writing
Front-Load Important Information
# Good Structure
Fix the authentication bug in @src/auth.ts where users can't log in
with special characters in passwords. The error occurs in the
validatePassword function around line 45.
[Additional details if context allows...]Break Down Complex Tasks
Instead of one massive prompt:
# Large Task (may exceed context)
"Refactor the entire user management system to use microservices,
update all authentication flows, migrate the database schema,
update tests, and deploy to staging"Break it into focused steps:
# Step 1
"Plan the microservices architecture for user management.
Identify the core services needed and their responsibilities."
# Step 2 (new task after completing step 1)
"Implement the user authentication service based on the
architecture we planned."Context Limits and Performance
Model Context Windows
Different AI models have varying context capacities:
GPT-4
32K - 128K tokens
GPT-4o
128K tokens
Claude 3.5 Sonnet
200K tokens
Gemini 2.5 Pro
1M - 2M tokens
Local Models
4K - 32K tokens
Performance Considerations
Larger Context ≠ Always Better
Cost: More tokens = higher API costs
Speed: Larger contexts take longer to process
Focus: Too much information can dilute the AI's attention
Quality: Relevant context beats comprehensive context
Sweet Spot Guidelines
For optimal performance:
Keep conversations focused on specific problems or features
Use 50-70% of available context for best balance of information and performance
Condense regularly for long-running tasks
Start fresh for significantly different problems
Troubleshooting Context Issues
Common Problems
"Context Window Full" Errors
Symptoms: Task stops mid-conversation, context condensing messages Solutions:
Enable auto-condensing with lower threshold (70-80%)
Manually condense before starting complex operations
Start a new task for unrelated work
Poor Response Quality
Symptoms: Agent seems confused, references irrelevant information Solutions:
Check if important context was condensed away
Provide fresh context for the current problem
Use more specific file references
Slow Response Times
Symptoms: Long delays before agent responds Solutions:
Reduce context by condensing or starting fresh
Use smaller, more focused prompts
Consider switching to a model with larger context window
High API Costs
Symptoms: Unexpected billing from AI provider Solutions:
Enable aggressive auto-condensing (50-60% threshold)
Break large tasks into smaller, focused sessions
Use models with lower per-token costs for routine tasks
Optimization Settings
In Settings → Context Management, configure:
File Context Limits
Max Open Tabs: Limit files automatically included (default: 20)
Max Workspace Files: Limit files in project context (default: 200)
Max File Lines: Truncate very large files
Concurrent File Reads: Balance speed vs. resource usage
Auto-Condensing
Enable Auto Condense: Automatic context management
Condense Threshold: When to trigger (recommend 70-80%)
Condensing Model: Separate API for cost optimization
Custom Condensing Prompt: Tailor summarization style
Best Practices Summary
For New Users
Monitor the context bar - Watch how your usage grows
Enable auto-condensing at 80% threshold to start
Use specific file mentions rather than broad directory includes
Start new tasks for different features or problems
For Power Users
Customize condensing prompts for your workflow
Use different models for condensing vs. main tasks
Export task history before major context changes
Batch similar operations to maximize context efficiency
For Teams
Establish context guidelines for shared projects
Document important decisions outside of context-dependent conversations
Use consistent file organization to improve context relevance
Share effective prompt patterns that work well with your codebase
Context and Output Quality
How Context Affects Agent Performance
Relevant Context = Better Results
The agent performs best when context includes:
Directly related code to the task at hand
Recent conversation history about the current problem
Error messages and debugging information
Project structure and conventions
Information Overload
Too much context can lead to:
Confused responses mixing unrelated concepts
Generic solutions instead of project-specific ones
Missed details as important information gets lost
Higher costs without proportional quality gains
Context Quality Over Quantity
Focus on including:
Precise problem descriptions
Relevant code sections with proper context
Expected behavior vs. actual behavior
Previous attempted solutions to avoid repetition
Understanding and optimizing context usage will significantly improve your experience with the Gamecraft Agent, leading to more accurate responses, lower costs, and faster development cycles.
Next Steps
Now that you understand the context window, feel free to check out more resources for optimizing prompts and agent context
Prompt Engineering Guide - Targeted guide for improving prompts passed to Gamecraft Agent
Avoid Context Poisoning - Guidance to keep the agent's context tied to reality
Last updated