Skip to content

chore: increase context and tool output buffer sizes#4

Open
let5sne wants to merge 1 commit into
mainfrom
pr/buffer-size-fixes
Open

chore: increase context and tool output buffer sizes#4
let5sne wants to merge 1 commit into
mainfrom
pr/buffer-size-fixes

Conversation

@let5sne

@let5sne let5sne commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Summary

Two one-line buffer size increases to prevent silent truncation:

1. Context Buffer: 16KB → 24KB

  • File: main/mimi_config.h
  • Change: MIMI_CONTEXT_BUF_SIZE from (16 * 1024) to (24 * 1024)
  • Impact: Prevents silent context truncation when loading:
    • 6 bootstrap files (AGENTS.md, SOUL.md, USER.md, TOOLS.md, SKILLS.md, IDENTITY.md)
    • MEMORY.md (can easily exceed 4KB for active users)
    • 3-5 days of daily notes
    • Skills summary

Current 16KB limit causes append_file() to silently read 0 bytes when full, leaving dangling headers with no content.

2. Tool Output Buffer: 8KB → 12KB

  • File: main/agent/agent_loop.c
  • Change: TOOL_OUTPUT_SIZE from (8 * 1024) to (12 * 1024)
  • Impact: Prevents JSON truncation on verbose web_search results
    • Brave Search API responses with 5+ results can exceed 8KB
    • Truncated JSON causes cJSON_Parse() failures in LLM response handler
    • Silent failure = agent thinks search succeeded but gets no results

Testing

Both changes are backward-compatible buffer size increases:

  • No API changes
  • No behavior changes beyond preventing truncation
  • Both buffers are already allocated from PSRAM (not internal RAM)

Related Issues

Part of the ongoing memory safety improvements tracked in the mimiclaw-improve analysis.


Generated by OpenClaw Agent

- MIMI_CONTEXT_BUF_SIZE: 16KB → 24KB
  Prevents silent truncation when loading bootstrap files + MEMORY.md + daily notes

- TOOL_OUTPUT_SIZE: 8KB → 12KB
  Prevents JSON truncation on verbose web_search results (Brave API can exceed 8KB)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 630fc8ba7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread main/mimi_config.h
#define MIMI_FILE_WRITE_ALLOW_SESSION_DIR 0
#endif
#define MIMI_CONTEXT_BUF_SIZE (16 * 1024)
#define MIMI_CONTEXT_BUF_SIZE (24 * 1024)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep context buffer below total context budget

Raising MIMI_CONTEXT_BUF_SIZE to 24KB makes the system prompt eligible to consume the entire MIMI_AGENT_MAX_CONTEXT_BYTES budget (also 24KB), but the agent enforces budget on system_prompt + messages in agent_loop.c (get_context_bytes check at line 919). In sessions with large bootstrap/memory content, any non-empty message history now pushes total context over budget and the turn aborts with the context-too-long error instead of answering; with the previous 16KB prompt cap there was headroom for messages. This is a functional regression for users with larger stored memory.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant