Skip to content

Commit c01c45d

Browse files
authored
feat: bump agent to use new research mode (#119)
1 parent d96b12a commit c01c45d

File tree

5 files changed

+35
-50
lines changed

5 files changed

+35
-50
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@ai-sdk/openai": "^2.0.52",
6464
"@dnd-kit/react": "^0.1.21",
6565
"@phosphor-icons/react": "^2.1.10",
66-
"@posthog/agent": "1.16.4",
66+
"@posthog/agent": "1.17.0",
6767
"@radix-ui/react-icons": "^1.3.2",
6868
"@radix-ui/themes": "^3.2.1",
6969
"@recallai/desktop-sdk": "^1.3.2",

src/main/services/agent.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -307,34 +307,4 @@ export function registerAgentIpc(
307307
},
308308
);
309309

310-
ipcMain.handle(
311-
"agent-extract-questions",
312-
async (
313-
_event: IpcMainInvokeEvent,
314-
{
315-
taskId,
316-
repoPath,
317-
apiKey,
318-
apiHost,
319-
projectId,
320-
}: {
321-
taskId: string;
322-
repoPath: string;
323-
apiKey: string;
324-
apiHost: string;
325-
projectId: number;
326-
},
327-
): Promise<Array<{ id: string; question: string; options: string[] }>> => {
328-
const agent = new Agent({
329-
workingDirectory: repoPath,
330-
posthogApiKey: apiKey,
331-
posthogApiUrl: apiHost,
332-
posthogProjectId: projectId,
333-
debug: true,
334-
});
335-
336-
const questions = await agent.extractQuestionsFromResearch(taskId, false);
337-
return questions;
338-
},
339-
);
340310
}

src/main/services/fs.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -307,41 +307,50 @@ export function registerFsIpc(): void {
307307
}>,
308308
): Promise<void> => {
309309
try {
310-
const questionsPath = path.join(
310+
const researchPath = path.join(
311311
repoPath,
312312
".posthog",
313313
taskId,
314-
"questions.json",
314+
"research.json",
315315
);
316316

317-
// Read existing questions.json
318-
let questionsData: {
319-
answered: boolean;
320-
answers: Array<{
317+
// Read existing research.json
318+
let researchData: {
319+
actionabilityScore: number;
320+
context: string;
321+
keyFiles: string[];
322+
blockers?: string[];
323+
questions?: Array<{
324+
id: string;
325+
question: string;
326+
options: string[];
327+
}>;
328+
answered?: boolean;
329+
answers?: Array<{
321330
questionId: string;
322331
selectedOption: string;
323332
customInput?: string;
324333
}>;
325334
};
326335
try {
327-
const content = await fsPromises.readFile(questionsPath, "utf-8");
328-
questionsData = JSON.parse(content);
336+
const content = await fsPromises.readFile(researchPath, "utf-8");
337+
researchData = JSON.parse(content);
329338
} catch {
330-
throw new Error(`questions.json not found for task ${taskId}`);
339+
throw new Error(`research.json not found for task ${taskId}`);
331340
}
332341

333342
// Update with answers
334-
questionsData.answered = true;
335-
questionsData.answers = answers;
343+
researchData.answered = true;
344+
researchData.answers = answers;
336345

337346
// Write back to file
338347
await fsPromises.writeFile(
339-
questionsPath,
340-
JSON.stringify(questionsData, null, 2),
348+
researchPath,
349+
JSON.stringify(researchData, null, 2),
341350
"utf-8",
342351
);
343352

344-
console.log(`Saved answers to questions.json for task ${taskId}`);
353+
console.log(`Saved answers to research.json for task ${taskId}`);
345354

346355
// Commit the answers (local mode - no push)
347356
try {

src/renderer/features/tasks/components/TaskDetail.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,23 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) {
176176
addQuestionAnswer(task.id, answer);
177177
}
178178

179-
// Save answers to questions.json
179+
// Save answers to research.json
180180
if (repoPath) {
181181
try {
182182
await window.electronAPI?.saveQuestionAnswers(
183183
repoPath,
184184
task.id,
185185
answers,
186186
);
187-
console.log("Answers saved to questions.json");
187+
console.log("Answers saved to research.json");
188188

189189
// Set phase to planning and trigger next run
190190
setPlanModePhase(task.id, "planning");
191191

192192
// Trigger the next phase (planning) by running the task again
193193
runTask(task.id, task);
194194
} catch (error) {
195-
console.error("Failed to save answers to questions.json:", error);
195+
console.error("Failed to save answers to research.json:", error);
196196
}
197197
}
198198
};

src/renderer/features/tasks/stores/taskExecutionStore.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,17 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
641641

642642
if (taskState.clarifyingQuestions.length > 0) return;
643643

644-
const artifactEvent = taskState.logs.find(isArtifactEvent);
644+
// Look specifically for research_questions artifact
645+
const artifactEvent = taskState.logs.find(
646+
(log): log is AgentEvent & ArtifactEvent =>
647+
isArtifactEvent(log) &&
648+
(log as ArtifactEvent).kind === "research_questions"
649+
);
650+
645651
if (!artifactEvent) return;
646652

647653
const event = artifactEvent as ArtifactEvent;
648-
if (event.kind === "research_questions" && event.content) {
654+
if (event.content) {
649655
const questions = toClarifyingQuestions(event.content);
650656
store.setClarifyingQuestions(taskId, questions);
651657
store.setPlanModePhase(taskId, "questions");

0 commit comments

Comments
 (0)