Skip to content

[BUG] File attachments cause massive token bloat — file data resent with every API call #1864

Description

@MinaMan01

System details / 系统信息

Environment - DeepChat version: v1.0.7 (AppImage) - Model: deepseek-v4-flash - OS: Linux Mint 22.3 (Zena) — kernel 6.17.0-35-generic - Desktop: X-Cinnamon - CPU: Intel Core i3-1115G4 - RAM: 15 GB - GPU: Intel UHD Graphics G4 (Tiger Lake)

What's wrong? / 出了什么问题?

Describe the bug

When a file (image, PDF, document) is uploaded via DeepChat's message input box, the file's content is embedded inline in the message history. Every subsequent API call resends the entire message history — including the full file data from every previous message. This causes:

  • 500KB+ per request for a single image (base64-encoded)
  • Cache misses balloon because file content changes the context hash
  • Token consumption spikes even when the file is no longer being discussed
  • Chats become "heavy" and slow after just a few file attachments

To Reproduce

  1. Upload an image (e.g., 500KB PNG) to a new chat
  2. Ask a question about it → ~500KB cache miss tokens
  3. Ask an unrelated follow-up → 500KB file data is resent AGAIN as cache miss
  4. Repeat → every request burns the file data as uncacheable context

Expected behavior

File content should either:

  • Be stripped from old messages after the model has processed it, OR
  • Be stored externally (referenced by path/ID) rather than embedded inline, OR
  • Old messages with large file attachments should be eligible for compaction

Workaround

Instead of uploading files to the chat UI, provide the file path directly:

"Read /home/user/Downloads/image.jpg"
"Process /home/user/Documents/report.pdf"

The assistant reads the file directly from disk via its tools. The file data never enters the message history, keeping token usage lean.

Environment

  • DeepChat version: v1.0.7 (AppImage)
  • Model: deepseek-v4-flash
  • OS: Linux Mint 22.3 (Zena) — kernel 6.17.0-35-generic
  • Desktop: X-Cinnamon
  • CPU: Intel Core i3-1115G4
  • RAM: 15 GB
  • GPU: Intel UHD Graphics G4 (Tiger Lake)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions