Skip to content

Prompt memory budget indicators — show agents how full their context injection is #689

Closed as not planned

Description

@bm-clawd

Idea

Hermes renders memory with a usage indicator: MEMORY (your personal notes) [67% — 1,474/2,200 chars]. This gives the agent a clear signal about how much budget remains, encouraging curation over accumulation.

Problem

Agents using BM notes in their prompts have no visibility into how much context they're consuming. This leads to:

  • Memory files growing unbounded until they cause problems
  • No pressure to curate — agents append but rarely prune
  • Surprise context window issues when notes get too large

Proposal

When BM notes are loaded into agent context (via MCP tools or context file injection), include a budget indicator:

══════════════════════════════════════════════
KNOWLEDGE CONTEXT [3,200/8,000 tokens — 40%]
══════════════════════════════════════════════

This could be:

  1. A config option — agents or users set a token budget for BM context
  2. Returned in tool responses — search/read results include a running total
  3. A standalone tool — context_budget returns current usage stats

The key insight: making the budget visible creates natural pressure to curate. The agent sees it's at 90% and starts pruning instead of appending.

References

Activity

  1. claude commented on Mar 21, 2026

    @claude
    Contributor

    Claude finished @bm-clawd's task in 1m 18s —— View job


    Issue Triage

    • Gather context and analyze issue
    • Explore codebase for relevant components
    • Check for duplicate issues
    • Apply labels
    • Post triage analysis

    Analysis

    Type: Feature Request — Enhancement to existing MCP tools
    Priority: Medium
    Component: MCP tools (build_context, search_notes, read_note, recent_activity)
    Complexity: Medium

    No duplicates found. The related issue #686 (Progressive loading) is complementary as mentioned in the issue body.


    Triage Notes

    This is a well-scoped idea that addresses a real problem: agents have no visibility into how much context budget their BM notes are consuming, which leads to unbounded growth and surprise context window issues.

    Codebase observations:

    • build_context already returns a footer with metadata: *N primary, M related | depth=D | project: P*
    • _format_context_markdown() in build_context.py is the natural place to add a char/token indicator for output_format="text"
    • The JSON response path (graph.model_dump()) could include a char_count or token_estimate field in the metadata
    • search_notes and read_note have similar response shaping points

    Recommended approach (Option 2 from the issue — returned in tool responses):
    Adding budget indicators directly to tool responses is the lowest-friction path. No new config required, no new tool required — just augment the existing footer/metadata in build_context, search_notes, read_note, and recent_activity text output with a char count and optional token estimate.

    Example for build_context text output:

    *3 primary, 7 related | depth=1 | project: research*
    *Context size: 3,200 chars (~800 tokens)*
    

    A configurable context_budget (Option 1) could be a follow-on: if set in config, the indicator becomes 3,200/8,000 chars (40%) — creating the explicit pressure to curate described in the issue.

    Labels applied: enhancement

  2. TeaShaman-cyber commented on Aug 2, 2026

    @TeaShaman-cyber

    For agent workflows, a context budget indicator would be most useful if it also identified:

    • what was loaded;
    • from which project;
    • at which detail level;
    • whether content was truncated;
    • whether the result came from search or exact read;
    • whether the budget applies to one tool response or the whole injected context.

    A raw percentage alone may be misleading if several tools or memory surfaces contribute to the same prompt.

    This feedback was prepared collaboratively by Semyon Poklad and the AI agent Lad. It is based on a small multi-agent family-research MVP and is offered as a user-side observation, not a claim about Basic Memory's internal architecture. The final text was reviewed and manually approved by Semyon before posting.

  3. phernandez commented on Aug 11, 2026

    @phernandez
    Member

    this is a job for the harness. declining

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions