Retain user instructions in Guardian context (#42844)

## Why

Guardian reviews need the original user instructions even when compaction or
transcript selection removes them from the active conversation window.

## What changed

- Capture complete user messages in host-owned retained context and include them
  as ordered authorization evidence alongside verified answers.
- Omit oversized instructions atomically and emit an explicit incomplete-evidence
  notice instead of exposing a potentially misleading partial permission.
- Mark user messages inherited by forked agents so they remain model-visible
  without becoming child-local authorization.

## Testing

- Cover retained instructions across compaction, resume, rollback, and agent
  forks, including oversized evidence and legacy context behavior.

GitOrigin-RevId: 97122509d818c90d2f87c6a1b29c99c05ad0316e
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-04 20:27:18 +00:00
1 parent 147137c1f4
commit 9c4253ffc1
20 files changed
+663 -140

No files matched your search

+8
View File
@@ -496,6 +496,10 @@ pub(super) fn collect_guardian_context(
struct GuardianReviewHistory<'a>(&'a dyn ConversationHistorySnapshot);
impl SectionHistory for GuardianReviewHistory<'_> {
fn retained_context(&self) -> Option<&codex_history::RetainedContext> {
self.0.retained_context()
}
fn items(&self) -> Box<dyn Iterator<Item = &ResponseItem> + Send + '_> {
self.0.review_items()
}
@@ -504,6 +508,10 @@ impl SectionHistory for GuardianReviewHistory<'_> {
struct FilteredGuardianHistory<'a>(&'a dyn SectionHistory);
impl SectionHistory for FilteredGuardianHistory<'_> {
fn retained_context(&self) -> Option<&codex_history::RetainedContext> {
self.0.retained_context()
}
fn items(&self) -> Box<dyn Iterator<Item = &ResponseItem> + Send + '_> {
Box::new(self.0.items().filter(|item| {
!matches!(