Skip to content

feat: add MaxPromptBlockChars to MemoryConfig and plumb it through MemoryStore #30

@fuseraft

Description

@fuseraft

MemoryStore.BuildPromptBlock* hard-codes a 8,000-character cap on how much memory is injected into the system prompt. The value is never exposed to the user.

CompactionConfig.MaxCharsPerHistoryMessage is the direct precedent: same default, same rationale (token budget), already documented and user-facing. MemoryConfig (src/Core/Models/MemoryConfig.cs) exists but only covers Provider and Webhook — it has no tuning knobs.

Suggested change:

  1. Add a property to MemoryConfig:

    /// <summary>
    /// Maximum characters injected into the system prompt from the memory store.
    /// Default: <c>8000</c> (~2 000 tokens). Raise for large-context models; lower for small ones.
    /// </summary>
    public int MaxPromptBlockChars { get; init; } = 8_000;
  2. Update MemoryStore.BuildPromptBlock and BuildPromptBlockAsync to accept an optional int maxChars = 8_000 parameter.

  3. Pass the config value at the two call sites:

    • src/Infrastructure/AgentFactory.cs:124MemoryStore.ForAgent(config.Name).BuildPromptBlock()
    • src/Cli/Commands/Repl/ReplCommand.cs:167memoryStore.BuildPromptBlockAsync(cwd)

    Both callers have access to a MemoryConfig or can reach it via OrchestrationConfig — check how CompactionConfig.MaxCharsPerHistoryMessage is accessed at its call sites for the right pattern.

  4. Add a test case to tests/FuseraftCli.Tests/MemoryStoreTests.cs verifying that the block is truncated at the configured limit.

Files to touch:

  • src/Core/Models/MemoryConfig.cs
  • src/Infrastructure/MemoryStore.cs
  • src/Infrastructure/AgentFactory.cs
  • src/Cli/Commands/Repl/ReplCommand.cs
  • tests/FuseraftCli.Tests/MemoryStoreTests.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions