Add a feature flag for code-mode host output truncation (#58159)

## What changed

Add the disabled-by-default `code_mode_host_output_truncation` feature flag. When enabled, Core requests server-side output truncation for its built-in code-mode session providers over both stdio and gRPC. Injected providers retain control of their session settings, and explicit session options pass through unchanged.

## Testing

Add coverage for both transports verifying that the host's output-limit notice survives a zero-token observation budget. Extend the shared-provider test to exercise an injected provider with the new flag enabled.

GitOrigin-RevId: edbb65e930bf544e3d2f8384767037a6fb82d451
This commit is contained in:
Sean Huang
2026-10-29 19:29:05 +00:00
committed by copyberry
parent 7f1c09979c
commit fa4ebe87af
6 changed files with 119 additions and 6 deletions
+14 -5
View File
@@ -756,16 +756,25 @@ impl ThreadManager {
config: &Config,
host_program: PathBuf,
) -> Arc<dyn CodeModeSessionProvider> {
if config.features.enabled(Feature::CodeModeHostGrpc) {
Arc::new(
let provider: Arc<dyn CodeModeSessionProvider> =
if config.features.enabled(Feature::CodeModeHostGrpc) {
Arc::new(
crate::code_mode_host::ProcessOwnedGrpcCodeModeSessionProvider::with_host_program(
host_program,
),
)
} else {
Arc::new(ProcessOwnedCodeModeSessionProvider::with_host_program(
host_program,
))
};
if config
.features
.enabled(Feature::CodeModeHostOutputTruncation)
{
Arc::new(crate::code_mode_host::LocalServerOutputProvider { inner: provider })
} else {
Arc::new(ProcessOwnedCodeModeSessionProvider::with_host_program(
host_program,
))
provider
}
}