Summary
The Code Interpreter API reports output files it detected but could not include in files[] through a top-level artifact_truncation object (LibreChat-AI/code-interpreter#198, shipped in #199). createCodeExecutionTool in src/tools/CodeExecutor.ts never reads it. When the sandbox drops generated files, the model is told nothing, the "Generated files" summary appended to the tool output undercounts, and the host application cannot surface the omission because the artifact does not carry the field either.
Server contract
type ArtifactTruncationReason = 'max_files' | 'depth' | 'size' | 'path' | 'unreadable';
interface ArtifactTruncation {
code: 'artifact_truncated';
reasons: Partial<Record<ArtifactTruncationReason, number>>;
skipped: string[]; // up to 20 relative paths
skipped_count: number;
}
// POST /exec response
{ session_id, files, artifact_truncation?, stdout, stderr, code, signal, message, status, wall_time }
Example response from an execution that carried 120 input files with the default SANDBOX_MAX_OUTPUT_FILES=50:
{
"files": [ /* 50 entries */ ],
"artifact_truncation": {
"code": "artifact_truncated",
"reasons": { "max_files": 70 },
"skipped": ["report_070.csv", "report_068.csv", "..."],
"skipped_count": 70
}
}
Current behaviour
CodeExecutor.ts handles the sibling field artifact_delivery: it is normalized with normalizeArtifactDeliveryFailure, a warning is appended to the tool output with appendArtifactDeliveryWarning, and the normalized object is echoed in the artifact in both the with-files and no-files branches. There is no equivalent for artifact_truncation; the string does not appear anywhere in the repository. The response above produces a tool message and artifact describing 50 files with no indication that 70 more were written and dropped.
Per code-interpreter#198, generated outputs fill the cap first and inherited refs only take leftover slots, so in a conversation that already carries many files it is the newly generated outputs that get cut.
Impact
- The model believes every file it wrote was delivered and tells the user so. It has no signal to write fewer files or bundle them.
- The host cannot warn the user or log the omission.
Proposed change
Mirror the artifact_delivery handling:
-
Add normalizeArtifactTruncation(value) alongside normalizeArtifactDeliveryFailure: require code === 'artifact_truncated', a non-negative integer skipped_count, a reasons map of non-negative integers keyed by the known reasons, and a skipped string array of at most 20 entries. Return undefined otherwise so a malformed marker cannot alter the tool output.
-
Append a warning to the tool output ahead of the file summary, for example:
Note: 70 output file(s) were written but not delivered (max_files: 70). Not delivered: report_070.csv, ... (20 of 70 shown). Write fewer files per execution or combine them into an archive.
-
Echo the normalized object in the artifact as artifact_truncation in both branches so the host can render or log it.
-
Add the optional field to the response types and cover: marker with and without files, unknown reason keys, malformed marker ignored, skipped longer than 20 entries.
Reproduction
- Upload more than 50 small files to one session via
POST /upload/batch.
- Invoke
execute_code with all of them in _injected_files and code that only lists /mnt/data.
- Compare the raw
POST /exec response with the tool's content and artifact: the response carries artifact_truncation; the tool output and artifact do not.
Versions: @librechat/agents 3.9.1 (main at 7bb25ae shows the same), Code Interpreter API with #199 applied.
Summary
The Code Interpreter API reports output files it detected but could not include in
files[]through a top-levelartifact_truncationobject (LibreChat-AI/code-interpreter#198, shipped in #199).createCodeExecutionToolinsrc/tools/CodeExecutor.tsnever reads it. When the sandbox drops generated files, the model is told nothing, the "Generated files" summary appended to the tool output undercounts, and the host application cannot surface the omission because the artifact does not carry the field either.Server contract
Example response from an execution that carried 120 input files with the default
SANDBOX_MAX_OUTPUT_FILES=50:{ "files": [ /* 50 entries */ ], "artifact_truncation": { "code": "artifact_truncated", "reasons": { "max_files": 70 }, "skipped": ["report_070.csv", "report_068.csv", "..."], "skipped_count": 70 } }Current behaviour
CodeExecutor.tshandles the sibling fieldartifact_delivery: it is normalized withnormalizeArtifactDeliveryFailure, a warning is appended to the tool output withappendArtifactDeliveryWarning, and the normalized object is echoed in the artifact in both the with-files and no-files branches. There is no equivalent forartifact_truncation; the string does not appear anywhere in the repository. The response above produces a tool message and artifact describing 50 files with no indication that 70 more were written and dropped.Per code-interpreter#198, generated outputs fill the cap first and inherited refs only take leftover slots, so in a conversation that already carries many files it is the newly generated outputs that get cut.
Impact
Proposed change
Mirror the
artifact_deliveryhandling:Add
normalizeArtifactTruncation(value)alongsidenormalizeArtifactDeliveryFailure: requirecode === 'artifact_truncated', a non-negative integerskipped_count, areasonsmap of non-negative integers keyed by the known reasons, and askippedstring array of at most 20 entries. Returnundefinedotherwise so a malformed marker cannot alter the tool output.Append a warning to the tool output ahead of the file summary, for example:
Echo the normalized object in the artifact as
artifact_truncationin both branches so the host can render or log it.Add the optional field to the response types and cover: marker with and without files, unknown reason keys, malformed marker ignored,
skippedlonger than 20 entries.Reproduction
POST /upload/batch.execute_codewith all of them in_injected_filesand code that only lists/mnt/data.POST /execresponse with the tool's content and artifact: the response carriesartifact_truncation; the tool output and artifact do not.Versions:
@librechat/agents3.9.1 (main at 7bb25ae shows the same), Code Interpreter API with #199 applied.