Skip to content

Context Management

When working with AI, context matters. Vibe provides fine-grained control over what information the AI sees.

Keep all context from every iteration:

for item in items {
let result = do "Process {item}"
} verbose // or just omit - verbose is default

The AI sees the full history of all previous iterations. Good for:

  • Building up knowledge across iterations
  • Tasks where previous results inform next steps

Discard all context when the loop exits:

for item in items {
let analysis = do "Analyze {item}"
results.push(analysis)
} forget

The analysis variable and its history are discarded. Good for:

  • Processing many independent items
  • Reducing context size
  • Avoiding context overflow on large datasets

Summarize context using AI:

for article in articles {
let summary = do "Summarize: {article}"
} compress

At loop exit, the AI summarizes what happened. Good for:

  • Long-running loops where you need key insights
  • Reducing context while preserving important information
for item in items {
// processing...
} compress("List the key findings from all iterations")
model summarizer = {
name: "claude-haiku-4-5-20251001",
provider: "anthropic",
apiKey: env("ANTHROPIC_API_KEY")
}
for item in items {
// processing...
} compress(summarizer)
for item in items {
// processing...
} compress("Extract action items", summarizer)

Context modes work with while loops too:

let count = 0
while count < 100 {
do "Process iteration {count}"
count = count + 1
} forget // Don't keep 100 iterations of context

Hide specific variables from AI context:

private let apiSecret = "sk-secret-key"
private let internalState = { counter: 0 }
let publicData = "This is visible to AI"
// AI only sees publicData, not apiSecret or internalState
do "Analyze the available data"
let { private apiKey: text, endpoint: text } = config
// AI sees endpoint but not apiKey
do "Connect to the service"
ModeBehaviorUse Case
verboseKeep everythingBuilding knowledge
forgetDiscard allIndependent processing
compressAI summaryLong loops, key insights
let files = glob("**/*.md")
let insights: text[] = []
for file in files {
let content = readFile(file)
let insight = do "Extract key points from: {content}"
insights.push(insight)
} forget // Don't keep all file contents in context
// Now summarize the collected insights
let report = do "Create a report from these insights: {insights}"
let draft = do "Write initial draft about {topic}"
for i in 1..3 {
draft = do "Improve this draft: {draft}"
} verbose // Keep history so AI knows what changed
for url in urls {
let page = fetch(url)
let analysis = do "Analyze this page"
saveResult(url, analysis)
} forget // Each page is independent
for customer in customers {
let feedback = do "Analyze customer feedback: {customer.comments}"
let sentiment = do "Rate sentiment 1-10"
results.push({ customer: customer.id, sentiment })
} compress("What are the overall sentiment trends?")
// Continue with compressed summary in context
let recommendations = do "Based on the analysis, what should we improve?"