Skip to content

Commit

Permalink
throw
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Jan 28, 2025
1 parent 06690aa commit 6e6b69a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/core/src/core/chain-of-thought.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export class ChainOfThought extends EventEmitter {
private async breakdownGoalIntoSubtasks(
goal: Goal,
maxRetries: number = 3
): Promise<void> {
): Promise<string | void> {
const [relevantDocs, relevantExperiences, blackboardState] =
await Promise.all([
this.memory.findSimilarDocuments(goal.description, 5),
Expand Down Expand Up @@ -539,9 +539,13 @@ export class ChainOfThought extends EventEmitter {
// Update original goal status
this.goalManager.updateGoalStatus(goal.id, "active");
} catch (error) {
throw new Error(
`Failed to refine goal after ${maxRetries} attempts: ${error}`
this.logger.error(
"breakdownGoalIntoSubtasks",
"Failed to refine goal",
{ error }
);

return JSON.stringify({ error });
}
}

Expand Down Expand Up @@ -1232,7 +1236,7 @@ ${availableOutputs
public async think(
userQuery: string,
maxIterations: number = 10
): Promise<void> {
): Promise<void | string> {
this.emit("think:start", { query: userQuery });

try {
Expand Down Expand Up @@ -1288,7 +1292,7 @@ ${availableOutputs
);
} catch (error) {
this.emit("think:error", { query: userQuery, error });
throw error;
return JSON.stringify({ error });
}

currentIteration++;
Expand All @@ -1301,7 +1305,7 @@ ${availableOutputs
}
} catch (error) {
this.emit("think:error", { query: userQuery, error });
throw error;
return JSON.stringify({ error });
}
}

Expand Down

0 comments on commit 6e6b69a

Please sign in to comment.