hive-runtime: compact ACP sessions through the agent's compact command
An ACP agent's session is now compacted like a claude one: proactively once a turn crosses the percent-of-window watermark, and on the operator's /compact or the agent's compact tool. Before, the ACP backend's compact returned Unsupported and no watermark applied to it. - AcpRuntime takes the same CompactionPolicy as ClaudeRuntime; make_session builds one PercentPolicy (with CHECKPOINT_PROMPT) and hands it to whichever backend runs. - The runtime keeps the commands each session advertises in available_commands_update. If `compact` is among them, compaction sends the prompt `/compact` on the same session, which is how the ACP spec runs an advertised command. A proactive compaction runs the checkpoint turn first, as InfiniteSession does. - With no compact command, the checkpoint turn runs, the session is archived, and the next turn starts a new one with the system prompt. - Error::Unsupported had no producer left, so it and drive_turn's "/compact skipped" arm are gone. Refs #4391
This commit is contained in:
parent
3bef1dfab6
commit
cec35bfbb1
6 changed files with 356 additions and 76 deletions
|
|
@ -185,6 +185,23 @@ pub(super) fn session_model(response: &Value) -> Option<String> {
|
|||
.map(str::to_owned)
|
||||
}
|
||||
|
||||
/// The command names an `available_commands_update` advertises, or `None`
|
||||
/// for any other `update`. Each replaces the session's previous list.
|
||||
pub(super) fn advertised_commands(update: &Value) -> Option<Vec<String>> {
|
||||
if update.get("sessionUpdate").and_then(Value::as_str) != Some("available_commands_update") {
|
||||
return None;
|
||||
}
|
||||
let commands = update.get("availableCommands").and_then(Value::as_array);
|
||||
Some(
|
||||
commands
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|c| c.get("name").and_then(Value::as_str))
|
||||
.map(str::to_owned)
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Convert a claude `--mcp-config` document into ACP's `mcpServers` list.
|
||||
/// Returns the list and the server names, in the same order.
|
||||
pub(super) fn mcp_servers(config: &Value) -> (Vec<Value>, Vec<String>) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue