agent: store Vec<Tool> instead of Vec<ToolDef>
Agent.tools holds the Tool registry directly. ToolDefs are built on the fly at the API call site from Tool::to_tool_def(). No more pre-built ToolDef storage on Agent. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
e9b26f5d45
commit
e982cb192f
1 changed files with 5 additions and 5 deletions
|
|
@ -25,7 +25,7 @@ use tiktoken_rs::CoreBPE;
|
||||||
|
|
||||||
use api::{ApiClient, StreamEvent};
|
use api::{ApiClient, StreamEvent};
|
||||||
use context as journal;
|
use context as journal;
|
||||||
use tools::{ToolCall, ToolDef, FunctionCall, summarize_args};
|
use tools::{ToolCall, FunctionCall, summarize_args};
|
||||||
|
|
||||||
use crate::user::log::ConversationLog;
|
use crate::user::log::ConversationLog;
|
||||||
use crate::agent::api::types::*;
|
use crate::agent::api::types::*;
|
||||||
|
|
@ -72,7 +72,7 @@ impl DispatchState {
|
||||||
|
|
||||||
pub struct Agent {
|
pub struct Agent {
|
||||||
client: ApiClient,
|
client: ApiClient,
|
||||||
tool_defs: Vec<ToolDef>,
|
tools: Vec<tools::Tool>,
|
||||||
/// Last known prompt token count from the API (tracks context size).
|
/// Last known prompt token count from the API (tracks context size).
|
||||||
last_prompt_tokens: u32,
|
last_prompt_tokens: u32,
|
||||||
/// Current reasoning effort level ("none", "low", "high").
|
/// Current reasoning effort level ("none", "low", "high").
|
||||||
|
|
@ -127,7 +127,6 @@ impl Agent {
|
||||||
shared_context: SharedContextState,
|
shared_context: SharedContextState,
|
||||||
active_tools: crate::user::ui_channel::SharedActiveTools,
|
active_tools: crate::user::ui_channel::SharedActiveTools,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let tool_defs = tools::definitions();
|
|
||||||
let tokenizer = tiktoken_rs::cl100k_base()
|
let tokenizer = tiktoken_rs::cl100k_base()
|
||||||
.expect("failed to load cl100k_base tokenizer");
|
.expect("failed to load cl100k_base tokenizer");
|
||||||
|
|
||||||
|
|
@ -142,7 +141,7 @@ impl Agent {
|
||||||
let agent_cycles = crate::subconscious::subconscious::AgentCycleState::new(&session_id);
|
let agent_cycles = crate::subconscious::subconscious::AgentCycleState::new(&session_id);
|
||||||
let mut agent = Self {
|
let mut agent = Self {
|
||||||
client,
|
client,
|
||||||
tool_defs,
|
tools: tools::tools(),
|
||||||
last_prompt_tokens: 0,
|
last_prompt_tokens: 0,
|
||||||
reasoning_effort: "none".to_string(),
|
reasoning_effort: "none".to_string(),
|
||||||
temperature: 0.6,
|
temperature: 0.6,
|
||||||
|
|
@ -307,9 +306,10 @@ impl Agent {
|
||||||
top_p: me.top_p,
|
top_p: me.top_p,
|
||||||
top_k: me.top_k,
|
top_k: me.top_k,
|
||||||
};
|
};
|
||||||
|
let tool_defs: Vec<_> = me.tools.iter().map(|t| t.to_tool_def()).collect();
|
||||||
me.client.start_stream(
|
me.client.start_stream(
|
||||||
&api_messages,
|
&api_messages,
|
||||||
Some(&me.tool_defs),
|
Some(&tool_defs),
|
||||||
ui_tx,
|
ui_tx,
|
||||||
&me.reasoning_effort,
|
&me.reasoning_effort,
|
||||||
sampling,
|
sampling,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue