Skip to content

Manual context clearing for tool results #45503

@tbertran

Description

@tbertran

Currently, tool results are only pruned from context via automatic TTL (e.g., 1h with cache-ttl mode). This creates inefficiency when large tool results (emails, search results, etc.) are only needed momentarily.

Use case:

  1. User asks: "Find my first iPhone purchase in Gmail"
  2. Agent fetches 25 emails (80k+ tokens of results)
  3. Agent answers the question immediately
  4. Those 80k tokens sit in context for the next hour despite being useless

Requested feature:
A way to manually purge tool results from context once they're no longer needed.

Possible implementations:

  • CLI command: openclaw context clear --tool-result <id>
  • Agent-accessible function: context_clear(tool_result_id)
  • Auto-clear flag on tool calls: {clearAfterUse: true}

Benefits:

  • Reduces context bloat
  • Extends session lifespan before compaction
  • Improves performance for search-heavy workflows

Current workaround: Wait for TTL expiration (wasteful)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions