Allow async user messages through code mode (#63730)

## Why

Agents could send async user messages only through a top-level tool call, even in code mode.

## What changed

Set `features.send_message_to_user_async.direct_only` to `false` to make the tool follow the session's tool mode. Direct mode exposes it as a top-level tool, code mode allows both top-level and nested calls, and code-mode-only sessions require nested calls and reject direct calls. The default keeps the tool top-level only. Existing agent opt-ins still apply.

## Testing

Add integration coverage for tool visibility, call results, and message delivery across all three tool modes with both values of `direct_only`. Improve failure diagnostics in the multiline shell snapshot test and paste `/status` as a single input event in the daemon compatibility test.

GitOrigin-RevId: c69bb2fba8bf776eff01382d8869fc869fc9d479
This commit is contained in:
surajs-oai
2026-11-24 19:56:22 +00:00
committed by copyberry
parent 7015377ecd
commit 7a24022794
8 changed files with 158 additions and 17 deletions
@@ -538,7 +538,8 @@ fn brokered_snapshots_filter_complete_multiline_exports() -> Result<()> {
allowed_brokered_keys: &[],
},
|_| true,
);
)
.with_context(|| format!("{shell}: snapshot rejected multiline export {value:?}"))?;
let path = dir.path().join("snapshot.sh");
std::fs::write(&path, snapshot)?;
let replayed = Command::new(shell)
@@ -560,7 +561,8 @@ fn brokered_snapshots_filter_complete_multiline_exports() -> Result<()> {
assert_eq!(
replayed.stdout,
format!("{value}\0unset\0kept\0original name\0original value\0original escaped{function_value}{exported_setting}").as_bytes(),
"{shell}"
"{shell}: replay stderr: {}",
String::from_utf8_lossy(&replayed.stderr)
);
}
}