mirror of
https://github.com/ultraworkers/claw-code-parity.git
synced 2026-04-29 16:17:50 +02:00
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:
@@ -1902,19 +1902,11 @@ impl ApiClient for ProviderRuntimeClient {
|
||||
|
||||
push_prompt_cache_record(&self.client, &mut events);
|
||||
|
||||
if !saw_stop
|
||||
&& events.iter().any(|event| {
|
||||
matches!(event, AssistantEvent::TextDelta(text) if !text.is_empty())
|
||||
|| matches!(event, AssistantEvent::ToolUse { .. })
|
||||
})
|
||||
{
|
||||
if should_append_message_stop(&events, saw_stop) {
|
||||
events.push(AssistantEvent::MessageStop);
|
||||
}
|
||||
|
||||
if events
|
||||
.iter()
|
||||
.any(|event| matches!(event, AssistantEvent::MessageStop))
|
||||
{
|
||||
if has_message_stop(&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 {
|
||||
allowed_tools: BTreeSet<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user