Defer sync Guardian tool-output truncation to transcript preparation (#56533)

## What changed

Preserve tool outputs during sync transcript collection and apply the profile's `tool_tokens` limit during transcript preparation, matching tool-call handling. Keep async and Node REPL output truncation unchanged.

GitOrigin-RevId: cf1594bcf25553c08d53b86bee1dd151e4c5db64
This commit is contained in:
ioanbudea-OAI
2026-10-23 17:28:33 +00:00
committed by copyberry
parent ea819e1f4d
commit 0efc474605
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -267,7 +267,7 @@ pub(crate) fn render_guardian_transcript_entries(
/// Keep both tool calls and tool results here. The reviewer often needs the
/// agent's exact queried path / arguments as well as the returned evidence to
/// decide whether the pending approval is justified.
/// Tool-call truncation happens in sync preparation; other caps still apply
/// Tool-call and output truncation happen in sync preparation; other caps still apply
/// during collection. The cursor counts every non-empty evidence entry.
pub(super) fn collect_guardian_context(
history: &dyn SectionHistory,
+2 -2
View File
@@ -150,7 +150,8 @@ impl ContextProfile {
let prepare_text = |text: &str| {
let text = match self.target {
ContextTarget::Sync => match &entry.kind {
ConversationTranscriptEntryKind::ToolCall(_) => {
ConversationTranscriptEntryKind::ToolCall(_)
| ConversationTranscriptEntryKind::ToolOutput(_) => {
std::borrow::Cow::Owned(crate::truncate_text(
text,
self.transcript.entry_limits.tool_tokens,
@@ -161,7 +162,6 @@ impl ContextProfile {
| ConversationTranscriptEntryKind::Assistant
| ConversationTranscriptEntryKind::ProtectedAssistant
| ConversationTranscriptEntryKind::Reasoning
| ConversationTranscriptEntryKind::ToolOutput(_)
| ConversationTranscriptEntryKind::NodeReplToolOutput(_) => {
std::borrow::Cow::Borrowed(text)
}
+2 -1
View File
@@ -2,7 +2,7 @@
//!
//! Both Guardian consumers receive the same role and tool-source attribution,
//! with generated compaction summaries attributed to the assistant, complete user
//! messages and capped non-user entries, except sync tool calls prepared later. Resolved context profiles
//! messages and capped non-user entries, except sync tool calls and outputs prepared later. Resolved context profiles
//! apply aggregate retention after the host selects its full/delta slice. Tool outputs with a
//! call ID retain their generic label when the call is unavailable. Outputs
//! without a call ID require an explicit name.
@@ -411,6 +411,7 @@ fn collect_transcript_for_target(
truncate_text(&text, config.entry_limits.message_tokens)
}
ConversationTranscriptEntryKind::ToolCall(_)
| ConversationTranscriptEntryKind::ToolOutput(_)
if target == crate::ContextTarget::Sync =>
{
text