> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lindy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Context

> Manage your agent memory by adding important information to context or clearing it to focus on what matters most

<div style={{ display: 'flex', justifyContent: 'center', margin: '2rem 0' }}>
  <div className="video-card">
    <video src="https://lindy-docs-content.nyc3.digitaloceanspaces.com/Human%20in%20Loop.mp4" width="600" autoPlay muted loop playsInline style={{ display: 'block', width: '100%', borderRadius: '16px' }} />
  </div>
</div>

## Overview

Context management in Lindy gives you direct control over your agent's memory and attention. Perfect for:

* **Prioritizing important information** — anything you add to context gets favored in future decisions
* **Managing token costs** — clear context when it gets too large or expensive
* **Focusing agent attention** — remove distractions and highlight what matters
* **Advanced memory control** — combine with variables for sophisticated patterns

Context accrual happens automatically behind the scenes, but these actions give you more control.

## Add Context Action

* **What it does**: Explicitly adds important information to your agent's working memory, ensuring it's prioritized in all future decisions.

<Frame>
  <img src="https://mintcdn.com/lindyai/D9TqHMLRoGnnvrcz/lindy-brand-assets/add-context.png?fit=max&auto=format&n=D9TqHMLRoGnnvrcz&q=85&s=03d441786d1d1643fd47ef459f288322" alt="Adding important information to context" width="1722" height="836" data-path="lindy-brand-assets/add-context.png" />
</Frame>

### Inputs

* **Contextt**: The information you want to add to context

### Outputs

* **Context Reference**: Can be referenced as an output in other actions
* **Updated Context**: The agent's context is updated behind the scenes

<Tip>
  Lindy automatically manages context accrual for all actions. Anything you explicitly add to context gets prioritized and placed at the top — making it highly favored in the agent's decision-making process.
</Tip>

## Clear Task Context Action

* **What it does**: Removes all or selected context to reduce token usage and refocus your agent's attention on what matters most.

<Frame>
  <img src="https://mintcdn.com/lindyai/VHBHJwXMXFd-cbnu/lindy-brand-assets/clear-context.png?fit=max&auto=format&n=VHBHJwXMXFd-cbnu&q=85&s=59e75449e2d75981533cce53f10db3e9" alt="Clearing context to manage memory" width="1712" height="816" data-path="lindy-brand-assets/clear-context.png" />
</Frame>

### Inputs

* **Message**: Instructions for what to preserve — like "preserve customer contacts or important information that will stay after the context is cleared"

### Outputs

* **Cleared Status**: Confirmation of what was removed
* **Remaining Context**: What context (if any) was preserved

<Tip>
  Advanced Pattern: Before clearing context, save important information to variables. After clearing, add only the essential context back using those variables.
</Tip>

## When to Use Context Actions

### Add Context

Use when you need to prioritize information:

* Customer details when a call or conversation starts
* Critical findings that should influence all future decisions
* Process state that other actions need to know about
* Error conditions that need to be tracked

### Clear Context

Use to manage costs and focus:

* When context gets large and expensive
* Switching between different workflow phases
* Processing multiple independent items
* Need to eliminate distractions

## Best Practices

<AccordionGroup>
  <Accordion title="Advanced Context Management">
    * Use variables to preserve essential data before clearing
    * Clear context at natural workflow breakpoints
    * Add context immediately after discovering critical information
    * Monitor context size in complex workflows
    * Use descriptive source labels for tracking
  </Accordion>

  <Accordion title="Token Cost Optimization">
    * Clear context when processing multiple similar items
    * Add only truly essential information to context
    * Use variables for temporary data that doesn't need global access
    * Monitor context accumulation in loops
    * Clear context before major workflow transitions
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Set Variables" icon="database" href="/skills/lindy-utilities/set-variables">
    Learn how to store temporary data that doesn't need to be in global context
  </Card>

  <Card title="Memories" icon="database" href="/skills/lindy-utilities/memories">
    Understand persistent memory that survives across different task executions
  </Card>

  <Card title="Observability" icon="magnifying-glass" href="/skills/lindy-utilities/observability">
    Access advanced monitoring and observability features
  </Card>

  <Card title="LLM Call" icon="database" href="/skills/lindy-utilities/llm-call">
    Make direct AI requests with controlled context
  </Card>
</CardGroup>
