Skip to content

Commit 25396c0

Browse files
wpfleger96npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
andauthored
feat(buzz-agent): lazy skill loading via load_skill tool (#1283)
Signed-off-by: Will Pfleger <[email protected]> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
1 parent 6c920d2 commit 25396c0

6 files changed

Lines changed: 864 additions & 50 deletions

File tree

‎crates/buzz-agent/src/agent.rs‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use serde_json::json;
44
use tokio::sync::{watch, Semaphore};
55
use tokio::task::JoinSet;
66

7+
use crate::builtin;
78
use crate::config::{Config, MAX_PROMPT_BYTES, MAX_TOOL_CALLS_PER_TURN, MAX_TOOL_RESULT_BYTES};
89
use crate::handoff::HandoffOutcome;
10+
use crate::hints::SkillEntry;
911
use crate::llm::Llm;
1012
use crate::mcp::McpRegistry;
1113
use crate::mcp::ResultBudget;
@@ -25,6 +27,8 @@ pub struct RunCtx<'a> {
2527
pub system_prompt: &'a str,
2628
pub llm: &'a Llm,
2729
pub mcp: &'a Arc<McpRegistry>,
30+
/// Skills discovered at session creation; used by the built-in `load_skill` tool.
31+
pub skills: &'a [SkillEntry],
2832
pub wire: &'a WireSender,
2933
pub cancel: &'a mut watch::Receiver<bool>,
3034
pub history: &'a mut Vec<HistoryItem>,
@@ -90,7 +94,11 @@ impl RunCtx<'_> {
9094
}
9195
}
9296

93-
let tools = self.mcp.tools();
97+
let mut tools = self.mcp.tools();
98+
// Inject the built-in load_skill tool when skills are available.
99+
if !self.skills.is_empty() {
100+
tools.push(builtin::load_skill_def());
101+
}
94102
round = round.saturating_add(1);
95103
let response = tokio::select! {
96104
biased;
@@ -246,6 +254,17 @@ impl RunCtx<'_> {
246254
return Some(StopReason::Cancelled);
247255
}
248256
emit_pending(self.wire, self.session_id, call).await;
257+
258+
// Built-in load_skill: execute inline, no MCP round-trip.
259+
if call.name == builtin::LOAD_SKILL_TOOL {
260+
emit_in_progress(self.wire, self.session_id, call).await;
261+
let mut result = builtin::call_load_skill(&call.arguments, self.skills).await;
262+
result.provider_id = call.provider_id.clone();
263+
emit_completed(self.wire, self.session_id, call, &result).await;
264+
results[idx] = Some(result);
265+
continue;
266+
}
267+
249268
// Hook tools (bare name starts with `_`) are invisible to the
250269
// LLM and only callable via `call_hooks`. Treat any direct
251270
// invocation as if the tool didn't exist.

0 commit comments

Comments
 (0)