read_file slurps and splits entire files before applying line limits, risking memory exhaustion and stale running calls

Ouverte
#695 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@prudhvirajkonda8-bot y travaille déjà.

Depuis le 15/11/2026.

  • #704 par @prudhvirajkonda8-bot — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
15/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
clojure
Domaine
backend, tooling

Piste de recherche

Start with the text-read path in src/eca/features/tools/filesystem.clj around lines 178-206, where the whole file is slurped and split before line_offset and limit apply. Then check the batch execution path in src/eca/features/chat/tool_calls.clj and the native handler boundary in src/eca/features/tools.clj, which the issue links for the lifecycle concern. Done means a five-line prefix read uses bounded memory regardless of file size, oversized single lines are rejected, and every executing call gets a terminal notification.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Source finding

In ECA 0.170.5 (commit 4a65f8241b2a671fb03230fa4d7de9066e7d8b2f), read_file runs (string/split-lines (slurp ...)) before applying line_offset/limit.

Measured by source inspection, not a runtime benchmark: filesystem.clj:178–206, especially line 193, reads and splits the entire input before selecting the excerpt, and counts all lines for the truncation footer. The text-read path has no file-size guard or deadline.

Inferred consequence: requesting five lines still attempts whole-file allocation. Neither the line limit nor downstream output truncation bounds input allocation. A ~2.5 GB growing JSONL file motivated this report. No controlled large-file runtime reproduction or latency/RSS benchmark has been performed for this report; OOM, GC pressure, exact concurrency, and the cause of any stale running entries have not been established.

Reproduction to run in isolation

Invoke read_file with line_offset: 0 and limit: 5 against a large synthetic text file in a disposable process with external time and memory limits. Source inspection shows that the current handler still reads/splits the whole input; this proposed runtime reproduction has not been run for this report.

Expected behavior

Bounded streaming prefix reads with an enforced byte/line budget and a safe error for oversized single lines; no full scan just to report total lines. Consider an unknown-total truncation footer.

Related lifecycle hardening (source-inferred, not reproduced)

The inspected batch execution path starts batch futures before untimed joins. The native handler boundary catches Exception, while the join catches Throwable. An exceptional future exit before execution-end may omit the normal terminal notification. This is a code-path inference, not an observed allocation failure. Please add lifecycle regression coverage alongside bounded-read tests; this does not imply fatal VM errors are safe to recover from.

The optional agent timeout requests a stop, rather than enforcing a native-read memory budget; see also the timeout wait path.

Suggested acceptance checks

  • A five-line prefix read has comparable memory use with 200 MB and 500 MB unused suffixes.
  • An oversized single line cannot bypass the budget.
  • Cancellation closes resources.
  • Every executing call obtains a terminal notification or explicit session failure.
Langage dominant
Clojure
Étoiles
1k
Forks
82
Merge moyen
1 j 20 h
PR mergées (30 j)
22

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de editor-code-assistant/eca

Toutes les issues de editor-code-assistant/eca

Issues similaires

Plus d'issues Clojure

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.