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:
YeonGyu-Kim
2026-04-02 15:02:28 +09:00
parent 0d2cd3229e
commit 29b99b21f7
+16 -10
View File
@@ -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>,
}