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
|
|
@ -44,8 +44,8 @@ pub trait Runtime {
|
|||
sink: &impl Sink,
|
||||
) -> impl Future<Output = Result<Progress>>;
|
||||
|
||||
/// Compact the durable session now. A backend that cannot returns
|
||||
/// [`Error::Unsupported`].
|
||||
/// Compact the durable session now. With no session there is nothing to
|
||||
/// compact, and this succeeds without doing anything.
|
||||
fn compact(&self, config: &Config, sink: &impl Sink) -> impl Future<Output = Result<()>>;
|
||||
|
||||
/// Set the durable session aside so the next turn starts a fresh one.
|
||||
|
|
@ -63,7 +63,7 @@ pub trait Runtime {
|
|||
/// [`RuntimeSpec`].
|
||||
pub enum AgentRuntime<P: CompactionPolicy> {
|
||||
Claude(ClaudeRuntime<P>),
|
||||
Acp(Box<AcpRuntime>),
|
||||
Acp(Box<AcpRuntime<P>>),
|
||||
}
|
||||
|
||||
impl<P: CompactionPolicy> Runtime for AgentRuntime<P> {
|
||||
|
|
@ -106,9 +106,6 @@ pub enum Error {
|
|||
/// From the ACP backend.
|
||||
#[error(transparent)]
|
||||
Acp(#[from] AcpError),
|
||||
/// The backend does not implement this operation.
|
||||
#[error("{0} is not supported by this runtime")]
|
||||
Unsupported(&'static str),
|
||||
}
|
||||
|
||||
/// Result alias for this crate.
|
||||
|
|
|
|||
Loading…
Reference in a new issue