Skip to content

Feature request: compress_context command #31684

@MarkRandall2019

Description

@MarkRandall2019

This is the beginning of the attached compress_context_feature_request.md file that Kimi generated for me. Full patches are included in the second attached file.

compress_context_feature_request.md

compress_context.patch

Summary

Add a compress_context tool that lets the agent proactively trigger context compression mid-conversation, rather than waiting for automatic threshold-based compression. This enables autonomous research modes where the agent can manage its own context budget and reset the turn counter before hitting the hard max_iterations limit.

Motivation

Hermes already has excellent automatic context compression (via context_compressor.py), but it only triggers when the token threshold is reached. For long-running autonomous tasks (e.g., research sweeps, multi-step experiments), the agent needs to be able to:

  1. Reset the turn counter before hitting max_iterations — critical for modes with a 200-turn budget where the agent plans its own work in chunks
  2. Preserve specific topics across compressions using the focus_topic parameter
  3. Force compression after a failed automatic attempt without waiting for a cooldown

Currently, if the agent approaches max_iterations and automatic compression hasn't triggered (e.g., because tokens are under threshold but turns are high), the conversation hard-stops with no graceful recovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt buildertype/featureNew feature or request

    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