Skip to content

[Platform] Make memory.md context read cap configurable per agent (currently hardcoded to 2,000 chars) #809

Description

@up-guillaume

Problem

In agent_context.py, the memory.md content injected into agent context is truncated at 2,000 characters. This is hardcoded and applies uniformly to all agents.

2,000 characters is insufficient for agents with rich operational context:

  • DevOps Moiria needs infrastructure mappings, container IDs, delegation rules
  • Platform Moiria needs DB schema references, migration paths
  • Curator needs the full 12-dimension monitoring framework

Agents are forced to choose between: (a) keeping memory.md under 2,000 chars (losing critical context), or (b) letting it grow and having the platform silently truncate it (agents don't know what context they're missing).

Root Cause

In the Clawith platform code (agent_context.py or similar), memory.md is read and truncated:

# Current (hardcoded)
memory_content = read_file(memory_path)[:2000]

The 2,000-char cap was likely set as a safe default to control token usage, but it's too aggressive for operational agents.

Proposed Solution

Make the cap configurable per agent, with a sane default:

# Proposed: per-agent configuration
DEFAULT_MEMORY_CAP = 5000  # chars

memory_cap = agent_config.get("memory_char_limit", DEFAULT_MEMORY_CAP)
memory_content = read_file(memory_path)[:memory_cap]

Configuration options:

  1. Agent-level config (preferred): Add a memory_char_limit field to the agent profile in the database
  2. Soul.md directive: Parse # memory_char_limit: 5000 from soul.md frontmatter
  3. Environment variable: CLAWITH_MEMORY_CHAR_LIMIT as a global override

Recommended values:

Tier Chars Use case
Minimal 2,000 Simple agents with little context
Standard 5,000 Default for new agents
Extended 10,000 Operational agents (DevOps, Platform)
Maximum 20,000 Agents with large reference needs

Acceptance Criteria

  • Identify the code path where memory.md is read and truncated in agent_context.py
  • Add a configurable parameter (agent-level or global) with default of 5,000
  • Log a warning when truncation occurs so agents know context was cut
  • Document the configuration option
  • Backward compatible: existing agents without the config field use the new default (5,000)

Context

Priority

P2 — Agents are losing context silently. Not breaking, but degrading agent effectiveness.

Labels

enhancement, agent-context, configurability

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions