Skip to content

Commit c949ef7

Browse files
committed
... getting closer now
Signed-off-by: David Zager <[email protected]>
1 parent c63b498 commit c949ef7

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

agentic/src/clients/solutionServerClient.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,6 @@ export class SolutionServerClient {
374374
},
375375
});
376376

377-
let bestHintResult: GetBestHintResult | undefined;
378-
379377
if (result.content && Array.isArray(result.content) && result.content.length > 0) {
380378
for (const chunk of result.content) {
381379
if ("text" in chunk) {
@@ -391,28 +389,24 @@ export class SolutionServerClient {
391389
"hint" in parsed &&
392390
"hint_id" in parsed
393391
) {
394-
bestHintResult = {
392+
console.log(`Found best hint for violation ${rulesetName} - ${violationName}`);
393+
return {
395394
hint: parsed.hint,
396395
hint_id: parsed.hint_id,
397396
};
398397
}
399398
} catch (parseError) {
400399
console.error(`Failed to parse best hint response: ${parseError}`);
401-
bestHintResult = undefined;
400+
return undefined;
402401
}
403402
}
404403
break;
405404
}
406405
}
407406
}
408407

409-
if (bestHintResult) {
410-
console.log(`Found best hint for violation ${rulesetName} - ${violationName}`);
411-
} else {
412-
console.log(`No hint found for violation ${rulesetName} - ${violationName}`);
413-
}
414-
415-
return bestHintResult;
408+
console.log(`No hint found for violation ${rulesetName} - ${violationName}`);
409+
return undefined;
416410
} catch (error) {
417411
console.error(
418412
`Error getting best hint for violation ${rulesetName} - ${violationName}: ${error}`,

agentic/src/nodes/analysisIssueFix.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "@langchain/core/messages";
88
import { promises as fsPromises } from "fs";
99
import { type DynamicStructuredTool } from "@langchain/core/tools";
10+
import { createPatch } from "diff";
1011

1112
import {
1213
type SummarizeAdditionalInfoInputState,
@@ -18,9 +19,7 @@ import {
1819
} from "../schemas/analysisIssueFix";
1920
import { BaseNode, type ModelInfo } from "./base";
2021
import { type KaiFsCache, KaiWorkflowMessageType } from "../types";
21-
import { type SolutionServerClient } from "../clients/solutionServerClient";
22-
import { GetBestHintResult } from "../clients/solutionServerClient";
23-
import { createPatch } from "diff";
22+
import { type GetBestHintResult, SolutionServerClient } from "src/clients/solutionServerClient";
2423

2524
type IssueFixResponseParserState = "reasoning" | "updatedFile" | "additionalInfo";
2625

@@ -55,6 +54,7 @@ export class AnalysisIssueFix extends BaseNode {
5554
...state,
5655
// since we are using a reducer, allResponses has to be reset
5756
outputAllResponses: [],
57+
outputHints: [],
5858
inputFileUri: undefined,
5959
inputFileContent: undefined,
6060
inputIncidents: [],
@@ -137,9 +137,8 @@ export class AnalysisIssueFix extends BaseNode {
137137
},
138138
];
139139
nextState.outputUpdatedFile = undefined;
140-
nextState.outputUpdatedFileUri = undefined;
141140
nextState.outputAdditionalInfo = undefined;
142-
nextState.outputHints = undefined;
141+
nextState.outputHints = [];
143142
}
144143
// if this was the last file we worked on, accumulate additional infromation
145144
if (state.currentIdx === state.inputIncidentsByUris.length) {
@@ -149,15 +148,13 @@ export class AnalysisIssueFix extends BaseNode {
149148
reasoning: `${acc.reasoning}\n${val.outputReasoning}`,
150149
additionalInfo: `${acc.additionalInfo}\n${val.outputAdditionalInfo}`,
151150
uris: acc.uris.concat([relative(this.workspaceDir, val.outputUpdatedFileUri!)]),
152-
hints: acc.hints.concat(val.outputHints || []),
153151
};
154152
},
155153
{
156154
reasoning: "",
157155
additionalInfo: "",
158156
uris: [],
159-
hints: [],
160-
} as { reasoning: string; additionalInfo: string; uris: string[]; hints: number[] },
157+
} as { reasoning: string; additionalInfo: string; uris: string[] },
161158
);
162159
nextState.inputAllAdditionalInfo = accumulated.additionalInfo;
163160
nextState.inputAllReasoning = accumulated.reasoning;
@@ -170,13 +167,13 @@ export class AnalysisIssueFix extends BaseNode {
170167
async fixAnalysisIssue(
171168
state: typeof AnalysisIssueFixInputState.State,
172169
): Promise<typeof AnalysisIssueFixOutputState.State> {
173-
if (!state.inputFileUri || !state.inputFileContent || !state.inputIncidents) {
170+
if (!state.inputFileUri || !state.inputFileContent || state.inputIncidents.length === 0) {
174171
return {
175172
outputUpdatedFile: undefined,
176173
outputAdditionalInfo: undefined,
177174
outputReasoning: undefined,
178175
outputUpdatedFileUri: state.inputFileUri,
179-
outputHints: undefined,
176+
outputHints: [],
180177
};
181178
}
182179

@@ -216,7 +213,6 @@ export class AnalysisIssueFix extends BaseNode {
216213
new HumanMessage(`I will give you a file for which I want to take one step towards migrating ${state.migrationHint}.
217214
I will provide you with static source code analysis information highlighting an issue which needs to be addressed.
218215
Fix all the issues described. Other problems will be solved in subsequent steps so it is unnecessary to handle them now.
219-
Some issues may include hints to guide you towards the best solution approach.
220216
Before attempting to migrate the code from ${state.migrationHint}, reason through what changes are required and why.
221217
222218
Pay attention to changes you make and impacts to external dependencies in the pom.xml as well as changes to imports we need to consider.
@@ -254,7 +250,6 @@ Write the step by step reasoning in this markdown section. If you are unsure of
254250
## Additional Information (optional)
255251
256252
If you have any additional details or steps that need to be performed, put it here. Do not summarize any of the changes you already made in this section. Only mention any additional changes needed.`);
257-
console.log(humanMessage.content);
258253

259254
const response = await this.streamOrInvoke([sysMessage, humanMessage], {
260255
emitResponseChunks: true,
@@ -267,7 +262,7 @@ If you have any additional details or steps that need to be performed, put it he
267262
outputUpdatedFile: undefined,
268263
outputReasoning: undefined,
269264
outputUpdatedFileUri: state.inputFileUri,
270-
outputHints: undefined,
265+
outputHints: [],
271266
};
272267
}
273268

agentic/src/workflows/interactiveWorkflow.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export class KaiInteractiveWorkflow
266266
});
267267

268268
// if there is any additional information spit by analysis workflow, capture that
269-
const additionalInformation: string = analysisFixOutputState.summarizedAdditionalInfo || "";
269+
const additionalInformation: string = analysisFixOutputState.summarizedAdditionalInfo;
270270
if (
271271
!input.enableAdditionalInformation ||
272272
additionalInformation.length < 1 ||
@@ -312,7 +312,7 @@ export class KaiInteractiveWorkflow
312312
migrationHint: input.migrationHint,
313313
programmingLanguage: input.programmingLanguage,
314314
plannerInputAgents: ["generalFix", "javaDependency"],
315-
plannerInputBackground: analysisFixOutputState.summarizedHistory || "",
315+
plannerInputBackground: analysisFixOutputState.summarizedHistory,
316316
enableDiagnosticsFixes: input.enableDiagnostics ?? false,
317317
// internal fields
318318
inputDiagnosticsTasks: undefined,
@@ -377,8 +377,7 @@ export class KaiInteractiveWorkflow
377377
});
378378

379379
// if these attributes are available, router meant to solve the analysis issue
380-
if (state.inputFileContent && state.inputFileUri && state.inputIncidents) {
381-
console.log(`[DEBUG] Going to fix_analysis_issue`);
380+
if (state.inputFileContent && state.inputFileUri && state.inputIncidents.length > 0) {
382381
return "fix_analysis_issue";
383382
}
384383

@@ -392,7 +391,7 @@ export class KaiInteractiveWorkflow
392391
// this will make router pick up the next incident in list
393392
if (
394393
state.currentIdx < state.inputIncidentsByUris.length &&
395-
(!state.inputFileContent || !state.inputFileUri || !state.inputIncidents)
394+
(!state.inputFileContent || !state.inputFileUri || state.inputIncidents.length === 0)
396395
) {
397396
console.log(`[DEBUG] Going back to fix_analysis_issue_router for next incident`);
398397
return "fix_analysis_issue_router";
@@ -415,8 +414,6 @@ export class KaiInteractiveWorkflow
415414
return "fix_analysis_issue_router";
416415
}
417416
}
418-
419-
console.log(`[DEBUG] All processing complete, going to END`);
420417
return END;
421418
}
422419

0 commit comments

Comments
 (0)