feat(media): make text file size limit configurable via [media] max_text_file_kb#1343
Open
slps970093 wants to merge 2 commits into
Open
feat(media): make text file size limit configurable via [media] max_text_file_kb#1343slps970093 wants to merge 2 commits into
slps970093 wants to merge 2 commits into
Conversation
…ext_file_kb Previously the 512 KB per-file limit for text attachments was hardcoded in download_and_read_text_file(). Files between 512 KB and 1 MB were silently dropped, causing users to unknowingly lose file context (e.g. chisato test-results.txt at 535-563 KB, 9 occurrences on 2026-07-10). Changes: - config.rs: add MediaConfig struct with max_text_file_kb field (default 512) - media.rs: replace const MAX_SIZE with max_bytes parameter - discord.rs: read media_config from Handler, pass max_bytes to download fn - slack.rs: thread media_config through run_slack_adapter and handle_message - main.rs: wire cfg.media into both Discord Handler and Slack adapter Deployments that do not set [media] are unaffected (backward-compatible). To raise the limit for a bot, add to config.toml: [media] max_text_file_kb = 1024 # or any value up to TEXT_TOTAL_CAP (1 MB)
Verify that download_and_read_text_file rejects files when the reported size exceeds max_bytes (pre-download fast path), and that the gate uses strict greater-than so a file at exactly the limit is not rejected.
Contributor
|
Caution This PR is missing a Discord Discussion URL in the body. All PRs must reference a prior Discord discussion to ensure community alignment before implementation. Please edit the PR description to include a link like: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this solve?
Text file attachments larger than 512 KB are silently dropped before being passed to the agent. Users have no indication this is happening — the file uploads successfully, the bot receives the message, but the agent simply never sees the file content.
Observed on chisato-bot (2026-07-10): 9 occurrences of \ est-results.txt\ (535–563 KB) being discarded in under 40 minutes, causing the user to repeatedly re-upload the same file.
Discord Discussion URL: https://discordapp.com/channels/1491295327620169908/1491365158868619404/1525027437086380042
At a Glance
\
User uploads test-results.txt (535 KB)
↓
Discord/Slack reports attachment size to OpenAB
↓
download_and_read_text_file(size, max_bytes)
↓
size > max_bytes? ──yes──> return None (silent drop ← bug)
↓ no
HTTP download → inline into prompt → agent sees file
\\
After this change, \max_bytes\ comes from [media] max_text_file_kb\ in config.toml (default: 512, backward-compatible).
Prior Art & Industry Research
Not applicable — this is a local prompt-assembly parameter with no cross-system protocol implications.
Proposed Solution
Why this approach?
Keeps the change minimal and targeted. The \TEXT_TOTAL_CAP\ (1 MB aggregate) remains a hard ceiling, so raising the per-file limit cannot cause prompt bloat beyond what was already allowed. All other adapters (Google Chat, Feishu, etc.) have their own download logic and are unaffected.
Alternatives Considered
Validation