tools: delete ToolDef and FunctionDef

ToolDef and FunctionDef are gone. Tool definitions are static strings
on the Tool struct. The API layer builds JSON from Tool::to_json().

- ChatRequest.tools is now Option<serde_json::Value>
- start_stream takes &[Tool] instead of Option<&[ToolDef]>
- openai::stream_events takes &serde_json::Value for tools
- memory_and_journal_tools() returns Vec<Tool> for subconscious agents
- Subconscious agents filter by t.name instead of t.function.name

No more runtime JSON construction for tool definitions.
No more ToolDef::new(). No more FunctionDef.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 16:39:04 -04:00 committed by Kent Overstreet
parent d195160b1e
commit 51e632c997
7 changed files with 33 additions and 78 deletions

View file

@ -295,13 +295,13 @@ fn run_one_agent_inner(
_llm_tag: &str,
log: &(dyn Fn(&str) + Sync),
) -> Result<AgentResult, String> {
let all_tools = crate::agent::tools::memory_and_journal_definitions();
let all_tools = crate::agent::tools::memory_and_journal_tools();
let effective_tools: Vec<String> = if def.tools.is_empty() {
all_tools.iter().map(|t| t.function.name.clone()).collect()
all_tools.iter().map(|t| t.name.to_string()).collect()
} else {
all_tools.iter()
.filter(|t| def.tools.iter().any(|w| w == &t.function.name))
.map(|t| t.function.name.clone())
.filter(|t| def.tools.iter().any(|w| w == &t.name))
.map(|t| t.name.to_string())
.collect()
};
let tools_desc = effective_tools.join(", ");