Preserve structured output format during remote compaction (#63320)

## Why

Remote compaction v2 dropped the turn's final-answer schema, so its
request could lose the cached prompt prefix shared with sampling even
when both requests used the same cache key.

## What changed

Carry the turn's JSON schema and sampling strictness into compaction
requests, including the non-strict guardian verdict format. The Responses
API still generates compaction summaries independently of that schema.

## Testing

- Check that automatic compaction on Bedrock and GCP uses the same
  `text.format` and `prompt_cache_key` as sampling, with and without a schema.
- Check that guardian reviews retain their verdict format across compaction
  and retries, and that an approval after compaction allows the command to run.

GitOrigin-RevId: 2cb5df2539358e3d74f1dce51baac2806b6219eb
This commit is contained in:
jif
2026-11-23 12:17:37 +00:00
committed by copyberry
parent 3af06341bd
commit 9ee4539162
3 changed files with 104 additions and 9 deletions
@@ -192,8 +192,12 @@ pub(super) async fn run_remote_compact_v2_attempt(
},
parallel_tool_calls: true,
base_instructions,
output_schema: None,
output_schema_strict: true,
// Preserve the cached output-format prefix. Responses generates compaction
// summaries independently of this final-answer schema.
output_schema: turn_context.final_output_json_schema.clone(),
output_schema_strict: !crate::guardian::is_basic_session_source(
&turn_context.session_source,
),
prompt_cache_ttl: turn_context.prompt_cache_ttl,
cyber_access_program: turn_context.cyber_access_program,
});