Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix/CLI: fail fast if the provided --context-file is too large (#5191)
Previously, the CLI didn't give any hint when `--context-file` was too large to fit into the context window. The VS Code chat UI refuses to add these files as explicit context. This PR fixes the problem so that the CLI also fails fast in the same scenario. Users can pass the `--ignore-context-window-error` to skip this check. ## Test plan Manually tested with ``` > pnpm -C agent build:agent && node agent/dist/index.js chat --context-file agent/src/cli/scip-codegen/scip.ts --context-file agent/src/agent.ts -m 'list all the methods here' ✖ The provided context is too large to fit into the context window. To fix this problem, either remove the files from --context-file or edit these files so they become small enough to fit into the context window. Alternatively, set the flag --ignore-context-window-errors to skip this check. File Reason ----------------------------------------------------------------------- -------------------------------------------------------------------------- /Users/olafurpg/dev/sourcegraph/cody/agent/src/cli/scip-codegen/scip.ts user context tokens exceeded remaining user context tokens (49538 > 29970) ``` To skip the check ``` pnpm -C agent build:agent && node agent/dist/index.js chat --context-file agent/src/cli/scip-codegen/scip.ts --context-file agent/src/agent.ts -m 'list all the methods here' --ignore-context-window-errors ``` <!-- Required. See https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles. --> ## Changelog <!-- OPTIONAL; info at https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c -->
- Loading branch information