Skip to content

Conversation

GoodluckH
Copy link
Contributor

#1254

demo-context-file-exceeded-limit.mp4

@GoodluckH GoodluckH self-assigned this Apr 23, 2025
@GoodluckH GoodluckH requested a review from a team April 23, 2025 20:41
@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.75%. Comparing base (dd6ca31) to head (b1ac450).
⚠️ Report is 416 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1331   +/-   ##
=======================================
  Coverage   16.75%   16.75%           
=======================================
  Files         213      213           
  Lines       20704    20704           
  Branches      871      871           
=======================================
  Hits         3468     3468           
  Misses      17236    17236           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GoodluckH GoodluckH force-pushed the 1254-bug-amazon-q-cli-fails-for-all-model-calls-when-a-really-large-file-is-added-to-context branch 4 times, most recently from 9c96cc4 to a49095c Compare April 24, 2025 17:10
@GoodluckH GoodluckH force-pushed the 1254-bug-amazon-q-cli-fails-for-all-model-calls-when-a-really-large-file-is-added-to-context branch 4 times, most recently from caa85e5 to c2e6d65 Compare April 29, 2025 21:58
@GoodluckH GoodluckH force-pushed the 1254-bug-amazon-q-cli-fails-for-all-model-calls-when-a-really-large-file-is-added-to-context branch 2 times, most recently from 2b18018 to 43f9b4e Compare May 6, 2025 19:11
@GoodluckH GoodluckH requested a review from brandonskiser May 6, 2025 19:12
///
/// # Returns
/// A Result containing a vector of (filename, content) pairs or an error
pub async fn get_context_files(&self, force: bool) -> Result<Vec<(String, String)>> {
pub async fn get_context_files(&self) -> Result<Vec<(String, String)>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

also a note - from checking process_path it seems like it's never invoked with force == true so it would be nice to just remove that altogether

Copy link
Contributor

Choose a reason for hiding this comment

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

Also a major TODO here is to limit the total size of files loaded. This whole context loading logic loads everything into memory before dropping, so it's super trivial to just run into OOM with a glob that matches a ton of large files.

/// sorted but the content will not be changed.
///
/// Returns the dropped files
pub fn drop_matched_context_files(files: &mut [(String, String)], limit: usize) -> Result<Vec<(String, String)>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

An API that doesn't require copying potentially very large files would also be nice, just for memory performance (not like it matters even)

I would rather this func maybe take an iterator over files, and return a vec of dropped file names instead. Then, your files could be e.g. a HashMap of file name to file content

@GoodluckH GoodluckH force-pushed the 1254-bug-amazon-q-cli-fails-for-all-model-calls-when-a-really-large-file-is-added-to-context branch from 43f9b4e to ead8f6a Compare May 7, 2025 19:11
@GoodluckH GoodluckH force-pushed the 1254-bug-amazon-q-cli-fails-for-all-model-calls-when-a-really-large-file-is-added-to-context branch from ead8f6a to b1ac450 Compare May 7, 2025 20:16
@GoodluckH GoodluckH merged commit 3220d81 into main May 7, 2025
17 of 21 checks passed
@GoodluckH GoodluckH deleted the 1254-bug-amazon-q-cli-fails-for-all-model-calls-when-a-really-large-file-is-added-to-context branch May 7, 2025 22:31
mangaohua pushed a commit to mangaohua/amazon-q-developer-cli that referenced this pull request Jun 17, 2025
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.

bug: Amazon Q CLI fails for all model calls when a really large file is added to context
3 participants