Make agent tools schema-driven
This commit is contained in:
1130
src/agent.rs
1130
src/agent.rs
File diff suppressed because it is too large
Load Diff
@@ -479,6 +479,8 @@ impl App {
|
||||
return;
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
self.reset_agent_tool_repeats();
|
||||
#[cfg(target_os = "macos")]
|
||||
let opening_turn = self.selected_session.is_none();
|
||||
#[cfg(target_os = "macos")]
|
||||
let opening_agents = if opening_turn {
|
||||
@@ -1193,6 +1195,20 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn reset_agent_tool_repeats(&mut self) {
|
||||
let Some((session_id, tools)) = &self.agent_tools else {
|
||||
return;
|
||||
};
|
||||
if Some(*session_id) != self.selected_session {
|
||||
return;
|
||||
}
|
||||
tools
|
||||
.lock()
|
||||
.unwrap_or_else(|poisoned| poisoned.into_inner())
|
||||
.reset_repeated_calls();
|
||||
}
|
||||
|
||||
fn finish_turn_summary(&mut self) {
|
||||
self.context_notice = None;
|
||||
let Some(turn) = self.active_turn.take() else {
|
||||
@@ -1307,6 +1323,7 @@ impl App {
|
||||
let assistant_reasoning = effective.turn.reasoning_mode != ReasoningMode::Direct;
|
||||
let queued = queued_prompt(self.queued_inputs.drain(..));
|
||||
if queued.is_some() {
|
||||
self.reset_agent_tool_repeats();
|
||||
self.a2ui_auto_switch_pending = true;
|
||||
}
|
||||
let reminders = if self.system_prompt_reminder_due() {
|
||||
|
||||
@@ -34,10 +34,6 @@ static VAULT_LOCK: RwLock<()> = RwLock::new(());
|
||||
pub(crate) const PROMPT: &str = r#"# Dev Brain
|
||||
Dev Brain is a managed Obsidian wiki, not a project directory or generic memory. Call dev_brain_info to get both its real folder and the separate registered project folders. Use the Dev Brain folder only for wiki maintenance; use a registered project folder for cited source files and Git commands. Do not invent a .brain path or use bash for wiki maintenance. Read schema.md before maintaining pages and append material changes to log.md. Call dev_brain_validate after edits; it rebuilds index.md and skills.md and reports broken links as repairable warnings without discarding content. Validation is semantic freshness work, not revision bookkeeping: for each reported drifted source, re-read that file, check whether its changes alter the page's documented findings, update the page when needed, then update only that source record to the newest commit that changed that file. For a large revision-backed source, use `git diff <recorded-revision> -- path` to focus on what changed before reading the necessary current context. Also inspect the commits affecting the file since its recorded revision. If code disappeared, do not assume its behavior was deleted: inspect the full change commits and search the current project, callers, and tests for a rename, replacement, or move to another file; update the page's source list when evidence moved. Never copy the repository's overall HEAD into every source revision. Repeat for every drifted source, then call dev_brain_validate again. Fix warnings with ordinary edits or by creating the missing page. The system prompt lists verified skills by name, description, and Markdown path. When a task matches a skill, read that complete skill file before acting and follow its instructions."#;
|
||||
|
||||
pub(crate) const TOOL_SCHEMAS: &str = r#"{"type":"function","function":{"name":"dev_brain_info","description":"Return the separate Dev Brain wiki folder and registered project source folders. Use ordinary file tools on the returned paths.","parameters":{"type":"object","properties":{}}}}
|
||||
{"type":"function","function":{"name":"dev_brain_search","description":"Search the validated Dev Brain index with freshness and project evidence. Use ordinary search for literal or regex file search.","parameters":{"type":"object","properties":{"query":{"type":"string"},"limit":{"type":"number"},"authoritative":{"type":"boolean"}},"required":["query"]}}}
|
||||
{"type":"function","function":{"name":"dev_brain_validate","description":"Validate managed pages after ordinary file edits, report every drifted project source for semantic reinspection and per-source revision updates, deterministically rebuild index.md and skills.md, refresh search, and report repairable link warnings.","parameters":{"type":"object","properties":{}}}}"#;
|
||||
|
||||
const DEFAULT_INDEX: &str = "# Dev Brain index\n\nNo topic pages have been compiled yet.\n";
|
||||
const DEFAULT_SKILLS: &str = "# Dev Brain skills\n\nNo verified skills are available.\n";
|
||||
const DEFAULT_LOG: &str =
|
||||
|
||||
Reference in New Issue
Block a user