Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 222 additions & 72 deletions crates/agentic-server-core/src/executor/accumulator.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions crates/agentic-server-core/src/executor/compaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ fn item_has_meaningful_context(item: &InputItem) -> bool {
}),
},
InputItem::FunctionCall(call) => !call.name.trim().is_empty() || !call.arguments.trim().is_empty(),
InputItem::FunctionCallOutput(output) => !output.output.trim().is_empty(),
InputItem::FunctionCallOutput(output) => output.output.has_content(),
InputItem::CustomToolCall(call) => !call.name.trim().is_empty() || !call.input.trim().is_empty(),
InputItem::CustomToolCallOutput(output) => value_has_content(&output.output),
InputItem::CustomToolCallOutput(output) => output.output.has_content(),
InputItem::Reasoning(reasoning) => {
reasoning.content.iter().any(|content| !content.text.trim().is_empty())
|| reasoning.summary.iter().any(value_has_content)
Expand Down Expand Up @@ -390,7 +390,7 @@ mod tests {
user_message("first"),
InputItem::FunctionCallOutput(FunctionToolResultMessage {
call_id: "call_1".to_owned(),
output: "tool output".to_owned(),
output: "tool output".into(),
}),
user_message("second"),
];
Expand Down Expand Up @@ -427,7 +427,7 @@ mod tests {
user_message("hello context"),
InputItem::FunctionCallOutput(FunctionToolResultMessage {
call_id: "call_1".to_owned(),
output: "substantial tool output".to_owned(),
output: "substantial tool output".into(),
}),
]);

Expand Down
24 changes: 16 additions & 8 deletions crates/agentic-server-core/src/executor/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::gateway::{
GatewayCallResult, LoopDecision, append_gateway_calls_to_new_input, append_output_items_to_input,
append_tool_outputs, classify_round, emit_gateway_completed_events, emit_gateway_start_events,
execute_and_emit_output_calls, execute_output_calls, gateway_event_plans, has_client_owned_calls,
is_gateway_owned_call, public_output_items,
is_client_custom_call, is_gateway_owned_call, public_output_items,
};
use super::gateway_accumulator::{GatewayStreamAccumulator, StreamEvent, error_sse_chunk};
use crate::events::EventFrame;
Expand Down Expand Up @@ -262,13 +262,21 @@ async fn execute_and_emit_ordered_output_calls(
let first_gateway_index = output_items
.iter()
.position(|item| matches!(item, OutputItem::FunctionCall(call) if is_gateway_owned_call(call, registry)));
let first_gateway_run_end = first_gateway_index.map_or(0, |start| {
output_items[start..]
.iter()
.take_while(|item| matches!(item, OutputItem::FunctionCall(call) if is_gateway_owned_call(call, registry)))
.count()
.saturating_add(start)
});
let first_gateway_run_end = first_gateway_index
.filter(|start| {
!output_items[..*start]
.iter()
.any(|item| matches!(item, OutputItem::FunctionCall(call) if is_client_custom_call(call, registry)))
})
.map_or(0, |start| {
output_items[start..]
.iter()
.take_while(
|item| matches!(item, OutputItem::FunctionCall(call) if is_gateway_owned_call(call, registry)),
)
.count()
.saturating_add(start)
});
let first_gateway_run_len = first_gateway_run_end.saturating_sub(first_gateway_index.unwrap_or(0));
emit_gateway_start_events(&event_plans[..first_gateway_run_len], stream_accumulator, stream_sender)?;

Expand Down
Loading