agent: Snapshot context in user message instead of recreating it (#27967)

This makes context essentially work the same way as `read-file`,
increasing the likelihood of cache hits.

Just like with `read-file`, we'll notify the model when the user makes
an edit to one of the tracked files. In the future, we want to send a
diff instead of just a list of files, but that's an orthogonal change.


Release Notes:
- agent: Improved caching of files in context

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Agus Zubiaga 2025-04-03 15:52:28 -03:00 committed by GitHub
parent 0c82541f0a
commit 315f1bf168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 551 additions and 136 deletions

View file

@ -158,7 +158,7 @@ impl HeadlessAssistant {
let model_registry = LanguageModelRegistry::read_global(cx);
if let Some(model) = model_registry.active_model() {
thread.update(cx, |thread, cx| {
thread.attach_tool_results(vec![], cx);
thread.attach_tool_results(cx);
thread.send_to_model(model, RequestKind::Chat, cx);
});
} else {