also looking at this
fix(agent): stop handing an agent text a stranger wrote as its instructions
#1414
9 files
+425
-5
| @@ -1472,6 +1472,10 @@ cli | ||
| 1472 | 1472 | const { runFixCi } = await import('../src/ci') |
| 1473 | 1473 | return await runFixCi({ config, provider, prNumber, analysisOnly: true, logger }) |
| 1474 | 1474 | }, |
| 1475 | plan: async (number, isPullRequest, request) => { | |
| 1476 | const { runPlan } = await import('../src/agent') | |
| 1477 | return await runPlan({ config, provider, number, isPullRequest, request, logger }) | |
| 1478 | }, | |
| 1475 | 1479 | remember: async (text, context) => { |
| 1476 | 1480 | const { addLearning, createLearning, loadLearnings, serializeLearnings, DEFAULT_LEARNINGS_FILE } |
| 1477 | 1481 | = await import('../src/ai') |
| @@ -2967,17 +2971,36 @@ cli | ||
| 2967 | 2971 | await provider.updateIssue(issueNumber, { body: clearQuickSelection(issue.body) }) |
| 2968 | 2972 | |
| 2969 | 2973 | for (const action of selection.actions) { |
| 2970 | const { getFinishingTouch, runAgent } = await import('../src/agent') | |
| 2971 | const touch = getFinishingTouch(action === 'build' ? 'autofix' : 'plan') | |
| 2974 | // The issue title and body belong to whoever opened it, which on a | |
| 2975 | // public repository is anyone. They used to be concatenated into the | |
| 2976 | // task string — the half of the context the model is told to trust — | |
| 2977 | // and for a ticked "build" that task drives an agent holding write, | |
| 2978 | // shell and git tools. Both paths now read the issue through a tool, | |
| 2979 | // so the runner frames it as third-party data. | |
| 2980 | if (action === 'plan') { | |
| 2981 | const { runPlan } = await import('../src/agent') | |
| 2982 | const plan = await runPlan({ config, provider, number: issueNumber, isPullRequest: false, logger }) | |
| 2983 | ||
| 2984 | await provider.createComment(issueNumber, plan) | |
| 2985 | logger.success('✅ Ran plan') | |
| 2986 | continue | |
| 2987 | } | |
| 2988 | ||
| 2989 | const { BUILTIN_TOOLS, createReadIssueTool, getFinishingTouch, runAgent } = await import('../src/agent') | |
| 2990 | const touch = getFinishingTouch('autofix') | |
| 2972 | 2991 | |
| 2973 | 2992 | const result = await runAgent(ai, { |
| 2974 | 2993 | mode: touch.mode, |
| 2975 | task: `${touch.buildTask({ summary: issue.title, files: [] })}\n\nIssue:\n${issue.body}`, | |
| 2994 | task: `${touch.buildTask({ files: [] })}\n\nCall \`read_issue\` to see what was asked for.`, | |
| 2995 | tools: [...BUILTIN_TOOLS, createReadIssueTool(provider, issueNumber, false)], | |
| 2976 | 2996 | context: { workspace: process.cwd(), baseBranch: config.repository?.baseBranch ?? 'main' }, |
| 2977 | 2997 | logger, |
| 2978 | 2998 | }) |
| 2979 | 2999 | |
| 2980 | await provider.createComment(issueNumber, result.output) | |
| 3000 | await provider.createComment( | |
| 3001 | issueNumber, | |
| 3002 | result.output || `I could not finish that (${result.stopReason}).`, | |
| 3003 | ) | |
| 2981 | 3004 | logger.success(`✅ Ran ${action}`) |
| 2982 | 3005 | } |
| 2983 | 3006 | |