agent tools do something now

This commit is contained in:
perf3ct 2025-03-19 20:17:52 +00:00
parent 0d4b6a71fc
commit 90db570e30
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
4 changed files with 820 additions and 767 deletions

View File

@ -289,6 +289,7 @@ export class ContextualThinkingTool {
getThinkingSummary(thinkingId: string): string { getThinkingSummary(thinkingId: string): string {
const process = this.getThinkingProcess(thinkingId); const process = this.getThinkingProcess(thinkingId);
if (!process) { if (!process) {
log.error(`No thinking process found for id: ${thinkingId}`);
return "No thinking process available."; return "No thinking process available.";
} }
@ -301,6 +302,8 @@ export class ContextualThinkingTool {
const evidence = process.steps.filter(s => s.type === 'evidence'); const evidence = process.steps.filter(s => s.type === 'evidence');
const conclusions = process.steps.filter(s => s.type === 'conclusion'); const conclusions = process.steps.filter(s => s.type === 'conclusion');
log.info(`Generating thinking summary with: ${observations.length} observations, ${questions.length} questions, ${hypotheses.length} hypotheses, ${evidence.length} evidence, ${conclusions.length} conclusions`);
// Add observations // Add observations
if (observations.length > 0) { if (observations.length > 0) {
summary += "### Observations:\n"; summary += "### Observations:\n";
@ -346,6 +349,7 @@ export class ContextualThinkingTool {
summary += "\n"; summary += "\n";
} }
log.info(`Generated thinking summary with ${summary.length} characters`);
return summary; return summary;
} }

View File

@ -443,11 +443,32 @@ export class NoteNavigatorTool {
try { try {
log.info(`Getting note structure for note ${noteId}`); log.info(`Getting note structure for note ${noteId}`);
// Special handling for 'root' or other special notes
if (noteId === 'root' || !noteId) {
log.info('Using root as the special note for structure');
return {
noteId: 'root',
title: 'Root',
type: 'root',
childCount: 0, // We don't know how many direct children root has
attributes: [],
parentPath: []
};
}
// Get the note from becca // Get the note from becca
const note = becca.notes[noteId]; const note = becca.notes[noteId];
if (!note) { if (!note) {
throw new Error(`Note ${noteId} not found`); log.error(`Note ${noteId} not found in becca.notes`);
return {
noteId,
title: 'Unknown',
type: 'unknown',
childCount: 0,
attributes: [],
parentPath: []
};
} }
// Get child notes count // Get child notes count

View File

@ -44,6 +44,16 @@ export class QueryDecompositionTool {
// Log the decomposition attempt for tracking // Log the decomposition attempt for tracking
log.info(`Decomposing query: "${query.substring(0, 100)}..."`); log.info(`Decomposing query: "${query.substring(0, 100)}..."`);
if (!query || query.trim().length === 0) {
log.info("Query decomposition called with empty query");
return {
originalQuery: query,
subQueries: [],
status: 'pending',
complexity: 0
};
}
// Assess query complexity to determine if decomposition is needed // Assess query complexity to determine if decomposition is needed
const complexity = this.assessQueryComplexity(query); const complexity = this.assessQueryComplexity(query);
log.info(`Query complexity assessment: ${complexity}/10`); log.info(`Query complexity assessment: ${complexity}/10`);
@ -52,14 +62,25 @@ export class QueryDecompositionTool {
// Use a lower threshold (2 instead of 3) to decompose more queries // Use a lower threshold (2 instead of 3) to decompose more queries
if (complexity < 2) { if (complexity < 2) {
log.info(`Query is simple (complexity ${complexity}), returning as single sub-query`); log.info(`Query is simple (complexity ${complexity}), returning as single sub-query`);
return {
originalQuery: query, const mainSubQuery = {
subQueries: [{
id: this.generateSubQueryId(), id: this.generateSubQueryId(),
text: query, text: query,
reason: 'Direct question that can be answered without decomposition', reason: 'Direct question that can be answered without decomposition',
isAnswered: false isAnswered: false
}], };
// Still add a generic exploration query to get some related content
const genericQuery = {
id: this.generateSubQueryId(),
text: `Information related to ${query}`,
reason: "Generic exploration to find related content",
isAnswered: false
};
return {
originalQuery: query,
subQueries: [mainSubQuery, genericQuery],
status: 'pending', status: 'pending',
complexity complexity
}; };
@ -283,7 +304,7 @@ export class QueryDecompositionTool {
subQueries.push({ subQueries.push({
id: this.generateSubQueryId(), id: this.generateSubQueryId(),
text, text,
reason: `Separate question ${i+1} detected in the original query`, reason: `Separate question ${i + 1} detected in the original query`,
isAnswered: false isAnswered: false
}); });
} }

View File

@ -147,10 +147,13 @@ export class ContextService {
// Step 4: Add agent tools context with thinking process if requested // Step 4: Add agent tools context with thinking process if requested
let enhancedContext = context; let enhancedContext = context;
if (contextNoteId) {
try { try {
// Pass 'root' as the default noteId when no specific note is selected
const noteIdToUse = contextNoteId || 'root';
log.info(`Calling getAgentToolsContext with noteId=${noteIdToUse}, showThinking=${showThinking}`);
const agentContext = await this.getAgentToolsContext( const agentContext = await this.getAgentToolsContext(
contextNoteId, noteIdToUse,
userQuestion, userQuestion,
showThinking, showThinking,
relevantNotes relevantNotes
@ -163,7 +166,6 @@ export class ContextService {
log.error(`Error getting agent tools context: ${error}`); log.error(`Error getting agent tools context: ${error}`);
// Continue with the basic context // Continue with the basic context
} }
}
return { return {
context: enhancedContext, context: enhancedContext,
@ -402,8 +404,13 @@ export class ContextService {
// Add thinking process if requested // Add thinking process if requested
if (showThinking) { if (showThinking) {
log.info(`Including thinking process in context (showThinking=true)`);
agentContext += `\n## Reasoning Process\n`; agentContext += `\n## Reasoning Process\n`;
agentContext += contextualThinkingTool.getThinkingSummary(thinkingId); const thinkingSummary = contextualThinkingTool.getThinkingSummary(thinkingId);
log.info(`Thinking summary length: ${thinkingSummary.length} characters`);
agentContext += thinkingSummary;
} else {
log.info(`Skipping thinking process in context (showThinking=false)`);
} }
// Log stats about the context // Log stats about the context