Support long-running agent turns
This commit is contained in:
@@ -344,6 +344,7 @@ pub(crate) struct Generator {
|
||||
pub(crate) struct ChatTurn {
|
||||
pub(crate) user: bool,
|
||||
pub(crate) tool: bool,
|
||||
pub(crate) system: bool,
|
||||
pub(crate) skip_previous_eos: bool,
|
||||
pub(crate) reasoning: Option<String>,
|
||||
pub(crate) reasoning_complete: bool,
|
||||
@@ -540,6 +541,7 @@ impl Generator {
|
||||
private_messages.push(ChatTurn {
|
||||
user: true,
|
||||
tool: false,
|
||||
system: false,
|
||||
skip_previous_eos: false,
|
||||
reasoning: None,
|
||||
reasoning_complete: true,
|
||||
@@ -743,6 +745,7 @@ impl Generator {
|
||||
let mut generated = ChatTurn {
|
||||
user: false,
|
||||
tool: false,
|
||||
system: false,
|
||||
skip_previous_eos: false,
|
||||
reasoning: reasoning.then(String::new),
|
||||
reasoning_complete: !reasoning,
|
||||
@@ -1068,7 +1071,7 @@ fn conversation_key(system: &str, reasoning: ReasoningMode, messages: &[ChatTurn
|
||||
output.extend_from_slice(value.as_bytes());
|
||||
}
|
||||
|
||||
let mut output = b"DS4Server chat checkpoint v3".to_vec();
|
||||
let mut output = b"DS4Server chat checkpoint v4".to_vec();
|
||||
text(&mut output, system);
|
||||
output.push(match reasoning {
|
||||
ReasoningMode::Direct => 0,
|
||||
@@ -1078,6 +1081,7 @@ fn conversation_key(system: &str, reasoning: ReasoningMode, messages: &[ChatTurn
|
||||
for message in messages {
|
||||
output.push(u8::from(message.user));
|
||||
output.push(u8::from(message.tool));
|
||||
output.push(u8::from(message.system));
|
||||
output.push(u8::from(message.skip_previous_eos));
|
||||
match &message.reasoning {
|
||||
Some(reasoning) => {
|
||||
@@ -1231,6 +1235,7 @@ mod sampling_tests {
|
||||
let mut generated = ChatTurn {
|
||||
user: false,
|
||||
tool: false,
|
||||
system: false,
|
||||
skip_previous_eos: false,
|
||||
reasoning: None,
|
||||
reasoning_complete: true,
|
||||
@@ -1251,6 +1256,7 @@ mod sampling_tests {
|
||||
let mut messages = vec![ChatTurn {
|
||||
user: true,
|
||||
tool: false,
|
||||
system: false,
|
||||
skip_previous_eos: false,
|
||||
reasoning: None,
|
||||
reasoning_complete: true,
|
||||
@@ -1269,6 +1275,12 @@ mod sampling_tests {
|
||||
tag,
|
||||
conversation_tag("System", ReasoningMode::Direct, &messages)
|
||||
);
|
||||
messages[0].system = true;
|
||||
assert_ne!(
|
||||
tag,
|
||||
conversation_tag("System", ReasoningMode::High, &messages)
|
||||
);
|
||||
messages[0].system = false;
|
||||
messages[0].skip_previous_eos = true;
|
||||
assert_ne!(
|
||||
tag,
|
||||
@@ -1278,6 +1290,7 @@ mod sampling_tests {
|
||||
messages.push(ChatTurn {
|
||||
user: false,
|
||||
tool: false,
|
||||
system: false,
|
||||
skip_previous_eos: false,
|
||||
reasoning: Some("because".into()),
|
||||
reasoning_complete: true,
|
||||
|
||||
Reference in New Issue
Block a user