Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up ContextItem<->ContextMessage conversion, remove duplicate wrapping & unused code #3307

Merged
merged 7 commits into from
Mar 5, 2024

Conversation

sqs
Copy link
Member

@sqs sqs commented Mar 5, 2024

I noticed in the conversion ContextItem <-> ContextMessage there are several possible places where we were wrapping context files with multiple layers of preamble, like:

Context from file path foo/bar.ts:
Context from file path foo/bar.ts: 
(actual contents of file)

There was a stripContextWrapper to try to undo that in some places, but it's not applied everywhere it's needed. Examples (from the agent recordings):

dupe2
dupecontext

This PR cleans up code related to this to remove the multiple layers of preamble, and deletes other related unused code.

Cleanups:

  • clean up use of ContextMessage
  • clean up codebase context
  • remove unused task contextMessages
  • fillInContextItemContent
  • remove unused fullContext field
  • fix usage of VS Code ranges

Test plan

CI

@sqs sqs changed the title WIP remove more unused code remove more unused code Mar 5, 2024
@sqs sqs changed the title remove more unused code clean up ContextItem<->ContextMessage conversion, remove duplicate wrapping & unused code Mar 5, 2024
@sqs sqs requested a review from a team March 5, 2024 08:31
@sqs sqs marked this pull request as ready for review March 5, 2024 08:31
@sqs
Copy link
Member Author

sqs commented Mar 5, 2024

Note: most of the diff is the agent recordings. The rest is a major deletion:

 28 files changed, 175 insertions(+), 780 deletions(-)

Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Awesome

@sqs sqs force-pushed the sqs/rm-legacy-transcript branch from a3c7cab to 04c0526 Compare March 5, 2024 17:19
@sqs sqs merged commit ca9424e into main Mar 5, 2024
15 of 16 checks passed
@sqs sqs deleted the sqs/rm-legacy-transcript branch March 5, 2024 17:44
Comment on lines -169 to -176
for (const file of userContextFiles) {
if (file.uri) {
const content = await editor.getTextEditorContentForFile(file.uri, file.range)
if (content) {
const message = createContextMessageByFile(file, content)
userProvidedContextMessages.push(...message)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll need to use fillInContextItemContent here like we do for chat, otherwise the user context files won't actually have any content and will be ignored as context.

quick fix here: #3318

steveyegge pushed a commit that referenced this pull request Mar 13, 2024
}

return extractContextItemsFromContextMessages([
Copy link
Member

Choose a reason for hiding this comment

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

Based on this diff and behavior before this PR, my best guess is that we should preserve the contextMessage to contextItem conversion until we properly remove the duplication between these types. Fixing it here: #4432

valerybugakov added a commit that referenced this pull request Jun 3, 2024
- #3307 removed `extractContextItemsFromContextMessages` and replaced it with `isContextItem(value) ? value : value.file` which removes context items content from the final prompt.
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.

None yet

4 participants