fix(tools): extract stream stop helpers
Resolves clippy::too_many_lines in tools/lib.rs. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
0d2cd3229e
commit
29b99b21f7
1 changed files with 16 additions and 10 deletions
|
|
@ -1902,19 +1902,11 @@ impl ApiClient for ProviderRuntimeClient {
|
||||||
|
|
||||||
push_prompt_cache_record(&self.client, &mut events);
|
push_prompt_cache_record(&self.client, &mut events);
|
||||||
|
|
||||||
if !saw_stop
|
if should_append_message_stop(&events, saw_stop) {
|
||||||
&& events.iter().any(|event| {
|
|
||||||
matches!(event, AssistantEvent::TextDelta(text) if !text.is_empty())
|
|
||||||
|| matches!(event, AssistantEvent::ToolUse { .. })
|
|
||||||
})
|
|
||||||
{
|
|
||||||
events.push(AssistantEvent::MessageStop);
|
events.push(AssistantEvent::MessageStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
if events
|
if has_message_stop(&events) {
|
||||||
.iter()
|
|
||||||
.any(|event| matches!(event, AssistantEvent::MessageStop))
|
|
||||||
{
|
|
||||||
return Ok(events);
|
return Ok(events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1933,6 +1925,20 @@ impl ApiClient for ProviderRuntimeClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn should_append_message_stop(events: &[AssistantEvent], saw_stop: bool) -> bool {
|
||||||
|
!saw_stop
|
||||||
|
&& events.iter().any(|event| {
|
||||||
|
matches!(event, AssistantEvent::TextDelta(text) if !text.is_empty())
|
||||||
|
|| matches!(event, AssistantEvent::ToolUse { .. })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn has_message_stop(events: &[AssistantEvent]) -> bool {
|
||||||
|
events
|
||||||
|
.iter()
|
||||||
|
.any(|event| matches!(event, AssistantEvent::MessageStop))
|
||||||
|
}
|
||||||
|
|
||||||
struct SubagentToolExecutor {
|
struct SubagentToolExecutor {
|
||||||
allowed_tools: BTreeSet<String>,
|
allowed_tools: BTreeSet<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue