;
+
+ switch (operationType) {
+ case 'code':
+ operation = this.codeService.runCodeEditWorkflow(workingDirectory, input);
+ break;
+ case 'query':
+ operation = this.codeService.runCodebaseQuery(workingDirectory, input);
+ break;
+ case 'selectFiles':
+ operation = this.codeService.selectFilesToEdit(workingDirectory, input);
+ break;
+ default:
+ this.result = 'Error: Invalid operation type';
this.isLoading = false;
- }
- });
- }
+ return;
+ }
- private selectFilesToEdit(workingDirectory: string, input: string) {
- this.codeService.selectFilesToEdit(workingDirectory, input).subscribe({
- next: response => {
- this.result = JSON.stringify(response, null, 2);
+ operation.subscribe({
+ next: (response: any) => {
+ this.result = operationType === 'query' ? response.response : JSON.stringify(response, null, 2);
this.isLoading = false;
},
- error: error => {
- this.result = 'Error: ' + error.message;
+ error: (error: Error) => {
+ console.error(`Error in ${operationType} operation:`, error);
+ this.result = `Error during ${operationType} operation: ${error.message}`;
this.isLoading = false;
- }
+ },
});
}
}
diff --git a/frontend/src/app/code/code.module.ts b/frontend/src/app/code/code.module.ts
index 42bd8fca..125f6c45 100644
--- a/frontend/src/app/code/code.module.ts
+++ b/frontend/src/app/code/code.module.ts
@@ -4,14 +4,15 @@ import { ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CodeComponent } from './code.component';
import { MaterialModule } from '@app/material.module';
+import { marker } from '@biesbjerg/ngx-translate-extract-marker';
@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
MaterialModule,
- RouterModule.forChild([{ path: '', component: CodeComponent }])
+ RouterModule.forChild([{ path: '', component: CodeComponent, data: { title: marker('Repository actions') } }]),
],
- declarations: [CodeComponent]
+ declarations: [CodeComponent],
})
-export class CodeModule { }
+export class CodeModule {}
diff --git a/frontend/src/app/runAgent/runAgent.component.html b/frontend/src/app/runAgent/runAgent.component.html
index 2cb68ad5..d691ac47 100644
--- a/frontend/src/app/runAgent/runAgent.component.html
+++ b/frontend/src/app/runAgent/runAgent.component.html
@@ -11,10 +11,11 @@
- Function generation type
+ Function calling type
- Dynamic
+ Code Generation
XML
+ Native
diff --git a/frontend/src/app/runAgent/runAgent.component.spec.ts b/frontend/src/app/runAgent/runAgent.component.spec.ts
index 52370314..5b7e78fa 100644
--- a/frontend/src/app/runAgent/runAgent.component.spec.ts
+++ b/frontend/src/app/runAgent/runAgent.component.spec.ts
@@ -41,12 +41,12 @@ describe('RunAgentComponent', () => {
expect(component.runAgentForm.valid).toBeTruthy();
});
- it('should have "xml" as the default type', () => {
- expect(component.runAgentForm.get('type')?.value).toBe('python');
+ it('should have "codegen" as the default type', () => {
+ expect(component.runAgentForm.get('type')?.value).toBe('codegen');
});
- it('should allow changing the type to "python"', () => {
- component.runAgentForm.patchValue({ type: 'python' });
- expect(component.runAgentForm.get('type')?.value).toBe('python');
+ it('should allow changing the type to "xml"', () => {
+ component.runAgentForm.patchValue({ type: 'xml' });
+ expect(component.runAgentForm.get('type')?.value).toBe('xml');
});
});
diff --git a/frontend/src/app/runAgent/runAgent.component.ts b/frontend/src/app/runAgent/runAgent.component.ts
index 9a075798..7f4be46f 100644
--- a/frontend/src/app/runAgent/runAgent.component.ts
+++ b/frontend/src/app/runAgent/runAgent.component.ts
@@ -7,6 +7,7 @@ import { Router } from '@angular/router';
import { environment } from '@env/environment';
import { AgentEventService } from '@app/agent-event.service';
import { LlmService } from '@app/shared/services/llm.service';
+import { AgentType } from '@shared';
interface StartAgentResponse {
data: {
@@ -14,6 +15,8 @@ interface StartAgentResponse {
};
}
+const defaultType: AgentType = 'codegen';
+
@Component({
selector: 'app-run-agent',
templateUrl: './runAgent.component.html',
@@ -35,7 +38,7 @@ export class RunAgentComponent implements OnInit {
this.runAgentForm = new FormGroup({
name: new FormControl('', Validators.required),
userPrompt: new FormControl('', Validators.required),
- type: new FormControl('python', Validators.required), // TODO make a constant
+ type: new FormControl(defaultType, Validators.required),
llmEasy: new FormControl('', Validators.required),
llmMedium: new FormControl('', Validators.required),
llmHard: new FormControl('', Validators.required),
diff --git a/frontend/src/app/shared/services/code.service.ts b/frontend/src/app/shared/services/code.service.ts
index 82149cea..b2d9cdbf 100644
--- a/frontend/src/app/shared/services/code.service.ts
+++ b/frontend/src/app/shared/services/code.service.ts
@@ -2,10 +2,10 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '@env/environment';
-import {Data} from "@shared";
+import { Data } from '@shared';
@Injectable({
- providedIn: 'root'
+ providedIn: 'root',
})
export class CodeService {
constructor(private http: HttpClient) {}
@@ -14,8 +14,8 @@ export class CodeService {
return this.http.post(`${environment.serverUrl}/code/edit`, { workingDirectory, requirements });
}
- runCodebaseQuery(workingDirectory: string, query: string): Observable<{response:string}> {
- return this.http.post<{response:string}>(`${environment.serverUrl}/code/query`, { workingDirectory, query });
+ runCodebaseQuery(workingDirectory: string, query: string): Observable<{ response: string }> {
+ return this.http.post<{ response: string }>(`${environment.serverUrl}/code/query`, { workingDirectory, query });
}
selectFilesToEdit(workingDirectory: string, requirements: string): Observable {
diff --git a/src/agent/agentContextLocalStorage.ts b/src/agent/agentContextLocalStorage.ts
index 756f1247..9fa8c89f 100644
--- a/src/agent/agentContextLocalStorage.ts
+++ b/src/agent/agentContextLocalStorage.ts
@@ -57,7 +57,7 @@ export function createContext(config: RunAgentConfig): AgentContext {
traceId: '',
metadata: config.metadata ?? {},
name: config.agentName,
- type: config.type ?? 'python',
+ type: config.type ?? 'codegen',
user: config.user ?? currentUser(),
inputPrompt: '',
userPrompt: config.initialPrompt,
diff --git a/src/agent/agentContextTypes.ts b/src/agent/agentContextTypes.ts
index e5fdd4cf..99edeeda 100644
--- a/src/agent/agentContextTypes.ts
+++ b/src/agent/agentContextTypes.ts
@@ -13,7 +13,7 @@ import { User } from '#user/user';
*
*/
export type TaskLevel = 'easy' | 'medium' | 'hard' | 'xhard';
-export type AgentType = 'xml' | 'python';
+export type AgentType = 'xml' | 'codegen';
export interface AgentCompleted {
notifyCompleted(agentContext: AgentContext): Promise;
diff --git a/src/agent/agentRunner.ts b/src/agent/agentRunner.ts
index 99213d3d..e0f52b57 100644
--- a/src/agent/agentRunner.ts
+++ b/src/agent/agentRunner.ts
@@ -2,8 +2,7 @@ import { LlmFunctions } from '#agent/LlmFunctions';
import { createContext, llms } from '#agent/agentContextLocalStorage';
import { AgentCompleted, AgentContext, AgentLLMs, AgentType } from '#agent/agentContextTypes';
import { AGENT_REQUEST_FEEDBACK } from '#agent/agentFunctions';
-import { runCachingPythonAgent } from '#agent/cachingPythonAgentRunner';
-import { runPythonAgent } from '#agent/pythonAgentRunner';
+import { runCodeGenAgent } from '#agent/codeGenAgentRunner';
import { runXmlAgent } from '#agent/xmlAgentRunner';
import { FUNC_SEP } from '#functionSchema/functions';
import { FunctionCall, FunctionCallResult } from '#llm/llm';
@@ -25,7 +24,7 @@ export interface RunAgentConfig {
user?: User;
/** The name of this agent */
agentName: string;
- /** The type of autonomous agent function calling. Defaults to python/dynamic */
+ /** The type of autonomous agent function calling. Defaults to codegen */
type?: AgentType;
/** The function classes the agent has available to call */
functions: LlmFunctions | Array any>;
@@ -66,8 +65,8 @@ async function runAgent(agent: AgentContext): Promise {
case 'xml':
execution = await runXmlAgent(agent);
break;
- case 'python':
- execution = await runPythonAgent(agent);
+ case 'codegen':
+ execution = await runCodeGenAgent(agent);
break;
default:
throw new Error(`Invalid agent type ${agent.type}`);
@@ -196,7 +195,7 @@ export async function summariseLongFunctionOutput(functionCall: FunctionCall, re
const prompt = `${functionCall.function_name}\n\n
For the above function call summarise the output into a paragraph that captures key details about the output content, which might include identifiers, content summary, content structure and examples. Only responsd with the summary`;
- return await llms().easy.generateText(prompt, null, { id: 'summariseLongFunctionOutput' });
+ return await llms().easy.generateText(prompt, null, { id: 'Summarise long function output' });
}
/**
diff --git a/src/agent/agentSerialization.ts b/src/agent/agentSerialization.ts
index 7a993b27..7989507c 100644
--- a/src/agent/agentSerialization.ts
+++ b/src/agent/agentSerialization.ts
@@ -75,6 +75,7 @@ export async function deserializeAgentContext(serialized: Record'];
-export const DYNAMIC_AGENT_SPAN = 'DynamicAgent';
+export const CODEGEN_AGENT_SPAN = 'Codegen Agent';
let pyodide: PyodideInterface;
/*
- * The aim of the cachingPython agent compared to the pythonAgent is to utilise the context caching in Claude.
+ * The aim of the cachingCodegen agent compared to the codegenAgent is to utilise context caching in Claude/OpenAI/DeepSeek.
* This will require using the new methods on the LLM interface which have a message history. This message history
* will be treated in some ways like a stack.
*
@@ -45,11 +45,13 @@ let pyodide: PyodideInterface;
*
* @param agent
*/
-export async function runCachingPythonAgent(agent: AgentContext): Promise {
+export async function runCachingCodegenAgent(agent: AgentContext): Promise {
if (!pyodide) pyodide = await loadPyodide();
// Hot reload (TODO only when not deployed)
- const systemPrompt = readFileSync('src/agent/caching-python-agent-system-prompt').toString();
+ const systemPrompt = readFileSync('src/agent/caching-codegen-agent-system-prompt').toString();
+ const planningPrompt = readFileSync('src/agent/caching-planning').toString();
+ const codingPrompt = readFileSync('src/agent/coding-planning').toString();
const agentStateService = appContext().agentStateService;
agent.state = 'agent';
@@ -95,7 +97,7 @@ export async function runCachingPythonAgent(agent: AgentContext): Promise {
+ shouldContinue = await withActiveSpan(CODEGEN_AGENT_SPAN, async (span) => {
agent.callStack = [];
let completed = false;
@@ -158,7 +160,7 @@ export async function runCachingPythonAgent(agent: AgentContext): Promise response as per the system instructions provided given the user request, available functions, memory items and recent function call history',
+ text: planningPrompt, // 'Generate a response as per the system instructions provided given the user request, available functions, memory items and recent function call history'
};
agent.messages[6] = { role: 'assistant', text: '' };
agent.messages.length = 7; // If we've restarted remove any extra messages
@@ -173,7 +175,7 @@ export async function runCachingPythonAgent(agent: AgentContext): Promise' };
const agentCodeResponse: string = `\n${await agentLLM.generateTextFromMessages(agent.messages, {
diff --git a/src/agent/codeGenAgentCodeReview.ts b/src/agent/codeGenAgentCodeReview.ts
new file mode 100644
index 00000000..11731a65
--- /dev/null
+++ b/src/agent/codeGenAgentCodeReview.ts
@@ -0,0 +1,85 @@
+import { llms } from '#agent/agentContextLocalStorage';
+
+export async function reviewPythonCode(agentPlanResponse: string): Promise {
+ const prompt = `
+Your task is to review the code provided to ensure it follows the following instructions:
+- The built-in packages json, re, math and datetime are already imported in the script. Including additional imports is forbidden.
+- await on every call to functions defined previously in the block.
+- Keep the code as simple as possible. Do not manipulate the function return values unless absolutely necessary. Prefer returning the values returned from the functions directly.
+- Add comments with your reasoning.
+- Add print calls throughout your code
+- If defining new variables then add typings from the value being assigned.
+- If you save a variable to memory then do not return it.
+- You don't need to re-save existing memory values
+- Always code defensively, checking values are the type and format as expected
+- For any operation involving user-specified items, refer to 'Interpreting User Requests' items to code defensively, ensuring flexible and context-aware handling.
+- The script should return a Dict with any values you want to have available to view/process next. You don't need to do everything here.
+- When calling Agent_completed or Agent_requestFeedback you must directly return its result. (Ensure any required information has already been stored to memory)
+- This script may be running on repositories where the source code files are TypeScript, Java, Terraform, PHP, C#, C++, Ruby etc. Do not assume Python files.
+- You can directly analyze and return contents from memory tags and . If you need to analyze unstructured data then include it to a return Dict value to view in the next step.
+- All maths must be done in Python code
+- If calling \`json.dumps\` it must also be passed the arg cls=JsProxyEncoder. i.e. json.dumps(data, cls=JsProxyEncoder)
+- Output in a comment what you know with complete confidence about a value returned from a function
+- Do NOT assume anything about the structure of the results from functions, other than what the type indicates. Return values that require further analysis. Do not call \`.get()\` on an object with an Any type
+
+
+
+List all the Terraform projects available in our GitLab repository.
+
+
+# Check memory contents if we have retrieved the GitLab projects in a previous step. Not found.
+# Retrieve the list of all projects from GitLab
+projects: List[Dict] = await GitLab_getProjects()
+
+# Ensure projects is a list before processing
+if not isinstance(projects, list):
+ print("Warning: Expected a list of projects, but received a different type.")
+ return {"error": "Unexpected data format from GitLab_getProjects()"}
+
+print(f"Retrieved {len(projects)} projects from GitLab")
+
+# Initialize a list to store potential Terraform projects
+terraform_projects = []
+
+# Analyze the projects to identify potential Terraform projects
+for project in projects:
+ # Check if the project name or description contains Terraform-related keywords
+ if 'terraform' in project.get('name', '').lower() or 'terraform' in project.get('description', '').lower():
+ terraform_projects.append(project)
+
+print(f"Identified {len(terraform_projects)} potential Terraform projects")
+
+# If we couldn't identify any Terraform projects, we might need more information
+if not terraform_projects:
+ return await Agent_requestFeedback("I couldn't identify any Terraform projects based on project names and descriptions. Do you have any additional information on how Terraform projects are typically named or organized in your GitLab repository?")
+
+await Agent_saveMemory("potential_terraform_projects", json.dumps(potential_terraform_projects, cls=JsProxyEncoder)
+
+# Return the list of potential Terraform projects for further analysis
+return {"potential_terraform_projects": terraform_projects}
+
+
+
+Analysis:
+- The code should not assume the structure of the Dict from the results of GitLab_getProjects() and should not assume the naming conventions of the project names.
+- It is not required to check that projects isinstance of list, as we can inferr that from the typings.
+- The project list should be returned for full analysis.
+- The code should not save a value to memory and also return it.
+
+# Check memory contents if we have retrieved the GitLab projects in a previous step. Not found.
+# Retrieve the list of all projects from GitLab
+projects: List[Dict] = await GitLab_getProjects()
+
+print(f"Retrieved {len(projects)} projects from GitLab")
+# The structure and naming conventions of the projects is unknown, so return for full ananlysis
+return {"gitlab_projects": projects}
+
+
+
+
+${agentPlanResponse}
+
+First detail your review of the code, then output the updated code wrapped in tags. If there are no changes to make then output the existing code as is in the result tags.
+`;
+ return await llms().medium.generateTextWithResult(prompt, null, { id: 'Review agent python code', temperature: 0.8 });
+}
diff --git a/src/agent/pythonAgentRunner.test.ts b/src/agent/codeGenAgentRunner.test.ts
similarity index 97%
rename from src/agent/pythonAgentRunner.test.ts
rename to src/agent/codeGenAgentRunner.test.ts
index 03485d2c..641478b6 100644
--- a/src/agent/pythonAgentRunner.test.ts
+++ b/src/agent/codeGenAgentRunner.test.ts
@@ -13,7 +13,7 @@ import {
startAgent,
startAgentAndWait,
} from '#agent/agentRunner';
-import { convertTypeScriptToPython } from '#agent/pythonAgentUtils';
+import { convertTypeScriptToPython } from '#agent/codeGenAgentUtils';
import { TEST_FUNC_NOOP, TEST_FUNC_SKY_COLOUR, TEST_FUNC_SUM, TEST_FUNC_THROW_ERROR, THROW_ERROR_TEXT, TestFunctions } from '#functions/testFunctions';
import { MockLLM, mockLLM, mockLLMs } from '#llm/models/mock-llm';
import { logger } from '#o11y/logger';
@@ -38,7 +38,7 @@ const COMPLETE_FUNCTION_CALL_PLAN = `\nReady to complete\
const NOOP_FUNCTION_CALL_PLAN = `\nI'm going to call the noop function\n${PY_TEST_FUNC_NOOP}\n`;
const SKY_COLOUR_FUNCTION_CALL_PLAN = `\nGet the sky colour\n${PY_TEST_FUNC_SKY_COLOUR}\n`;
-describe('pythonAgentRunner', () => {
+describe('codegenAgentRunner', () => {
const ctx = initInMemoryApplicationContext();
let functions = new LlmFunctions();
@@ -49,7 +49,7 @@ describe('pythonAgentRunner', () => {
agentName: AGENT_NAME,
initialPrompt: 'test prompt',
systemPrompt: '',
- type: 'python',
+ type: 'codegen',
llms: mockLLMs(),
functions,
user: ctx.userService.getSingleUser(),
@@ -224,9 +224,9 @@ describe('pythonAgentRunner', () => {
});
describe('Function call throws an error', () => {
- it('should continue on if a function throws an error', async () => {
+ it.skip('should continue on if a function throws an error', async () => {
functions.addFunctionInstance(new TestFunctions(), 'TestFunctions');
-
+ // TODO fix why its throwing a SyntaxError: invalid syntax in the Python execution
const response = `error${PY_TEST_FUNC_THROW_ERROR}`;
mockLLM.setResponse(response);
diff --git a/src/agent/pythonAgentRunner.ts b/src/agent/codeGenAgentRunner.ts
similarity index 95%
rename from src/agent/pythonAgentRunner.ts
rename to src/agent/codeGenAgentRunner.ts
index 1ebce7f6..4ae6c3aa 100644
--- a/src/agent/pythonAgentRunner.ts
+++ b/src/agent/codeGenAgentRunner.ts
@@ -6,8 +6,8 @@ import { AgentContext } from '#agent/agentContextTypes';
import { AGENT_COMPLETED_NAME, AGENT_REQUEST_FEEDBACK, AGENT_SAVE_MEMORY_CONTENT_PARAM_NAME } from '#agent/agentFunctions';
import { buildFunctionCallHistoryPrompt, buildMemoryPrompt, buildToolStatePrompt, updateFunctionSchemas } from '#agent/agentPromptUtils';
import { AgentExecution, formatFunctionError, formatFunctionResult } from '#agent/agentRunner';
+import { convertJsonToPythonDeclaration, extractPythonCode } from '#agent/codeGenAgentUtils';
import { humanInTheLoop } from '#agent/humanInTheLoop';
-import { convertJsonToPythonDeclaration, extractPythonCode } from '#agent/pythonAgentUtils';
import { getServiceName } from '#fastify/trace-init/trace-init';
import { FUNC_SEP, FunctionSchema, getAllFunctionSchemas } from '#functionSchema/functions';
import { logger } from '#o11y/logger';
@@ -18,15 +18,15 @@ import { agentContext, agentContextStorage, llms } from './agentContextLocalStor
const stopSequences = [''];
-export const PY_AGENT_SPAN = 'PythonAgent';
+export const CODEGEN_AGENT_SPAN = 'CodeGen Agent';
let pyodide: PyodideInterface;
-export async function runPythonAgent(agent: AgentContext): Promise {
+export async function runCodeGenAgent(agent: AgentContext): Promise {
if (!pyodide) pyodide = await loadPyodide();
// Hot reload (TODO only when not deployed)
- const pythonSystemPrompt = readFileSync('src/agent/python-agent-system-prompt').toString();
+ const codegenSystemPrompt = readFileSync('src/agent/codegen-agent-system-prompt').toString();
const agentStateService = appContext().agentStateService;
agent.state = 'agent';
@@ -74,11 +74,11 @@ export async function runPythonAgent(agent: AgentContext): Promise {
+ shouldContinue = await withActiveSpan(CODEGEN_AGENT_SPAN, async (span) => {
agent.callStack = [];
// Might need to reload the agent for dynamic updating of the tools
const functionsXml = convertJsonToPythonDeclaration(getAllFunctionSchemas(agent.functions.getFunctionInstances()));
- const systemPromptWithFunctions = updateFunctionSchemas(pythonSystemPrompt, functionsXml);
+ const systemPromptWithFunctions = updateFunctionSchemas(codegenSystemPrompt, functionsXml);
let completed = false;
let requestFeedback = false;
@@ -126,15 +126,16 @@ export async function runPythonAgent(agent: AgentContext): Promise {
xhard: Claude3_5_Sonnet_Vertex(),
},
agentName: `gaia-${task.task_id}`,
- type: 'python',
+ type: 'codegen',
humanInLoop: {
budget,
count: 100,
diff --git a/src/functionSchema/functionDecorators.ts b/src/functionSchema/functionDecorators.ts
index 120e729f..5770a3f5 100644
--- a/src/functionSchema/functionDecorators.ts
+++ b/src/functionSchema/functionDecorators.ts
@@ -26,7 +26,7 @@ export function func() {
const tracer = getTracer();
const agent = agentContext();
- // TODO move agent.functionCallHistory.push from xml and python runners to here so agentWorkflows show the function call history
+ // TODO move agent.functionCallHistory.push from xml and codegen runners to here so agentWorkflows show the function call history
// output summarising might have to happen in the agentService.save
// // Convert arg array to parameters name/value map
// const parameters: { [key: string]: any } = {};
diff --git a/src/functions/cloud/google-cloud.ts b/src/functions/cloud/google-cloud.ts
index 3a9c2565..978ef9c2 100644
--- a/src/functions/cloud/google-cloud.ts
+++ b/src/functions/cloud/google-cloud.ts
@@ -67,12 +67,12 @@ export class GoogleCloud {
return result.stdout;
}
- /**
- * Returns the open alert incidents across all the production projects
- * @returns {string[]} the open alert incidents
- */
- @func()
- getOpenProductionIncidents(gcpProjectId: string): Promise {
- return Promise.resolve([]);
- }
+ // /**
+ // * Returns the open alert incidents across all the production projects
+ // * @returns {string[]} the open alert incidents
+ // */
+ // @func()
+ // getOpenProductionIncidents(gcpProjectId: string): Promise {
+ // return Promise.resolve([]);
+ // }
}
diff --git a/src/llm/models/mock-llm.ts b/src/llm/models/mock-llm.ts
index 8412bf63..bfc69363 100644
--- a/src/llm/models/mock-llm.ts
+++ b/src/llm/models/mock-llm.ts
@@ -114,7 +114,7 @@ export class MockLLM extends BaseLLM {
outputChars: responseText.length,
});
- logger.info(`MockLLM response ${responseText}`);
+ logger.debug(`MockLLM response ${responseText}`);
return responseText;
});
}
diff --git a/src/routes/agent/agent-start-route.ts b/src/routes/agent/agent-start-route.ts
index 9ab2ca71..3654f98e 100644
--- a/src/routes/agent/agent-start-route.ts
+++ b/src/routes/agent/agent-start-route.ts
@@ -1,17 +1,19 @@
-import { readFileSync } from 'fs';
import { Type } from '@sinclair/typebox';
import { LlmFunctions } from '#agent/LlmFunctions';
import { send } from '#fastify/index';
import { getLLM } from '#llm/llmFactory';
import { logger } from '#o11y/logger';
import { AppFastifyInstance } from '../../app';
-
import { AgentExecution, startAgent } from '#agent/agentRunner';
import { currentUser } from '#user/userService/userContext';
-
import { functionFactory } from '#functionSchema/functionDecorators';
+import {AgentType} from "#agent/agentContextTypes";
+
const v1BasePath = '/api/agent/v1';
+
+const AGENT_TYPES: Array = ['xml', 'codegen'];
+
export async function agentStartRoute(fastify: AppFastifyInstance) {
/** Starts a new agent */
fastify.post(
@@ -22,7 +24,7 @@ export async function agentStartRoute(fastify: AppFastifyInstance) {
name: Type.String(),
userPrompt: Type.String(),
functions: Type.Array(Type.String()),
- type: Type.String({ enum: ['xml', 'python'] }),
+ type: Type.String({ enum: AGENT_TYPES }),
budget: Type.Number({ minimum: 0 }),
count: Type.Integer({ minimum: 0 }),
llmEasy: Type.String(),
@@ -51,7 +53,7 @@ export async function agentStartRoute(fastify: AppFastifyInstance) {
user: currentUser(),
agentName: name,
initialPrompt: userPrompt,
- type: type as 'xml' | 'python',
+ type: type as AgentType,
humanInLoop: { budget, count },
llms: {
easy: getLLM(llmEasy),
diff --git a/src/routes/code/code-routes.ts b/src/routes/code/code-routes.ts
index 758e8ea8..d371b52f 100644
--- a/src/routes/code/code-routes.ts
+++ b/src/routes/code/code-routes.ts
@@ -12,7 +12,7 @@ import { CodeEditingAgent } from '#swe/codeEditingAgent';
import { codebaseQuery } from '#swe/codebaseQuery';
import { SelectFilesResponse, selectFilesToEdit } from '#swe/selectFilesToEdit';
import { AppFastifyInstance } from '../../app';
-import { systemDir } from '../../appVars';
+import { sophiaDirName, systemDir } from '../../appVars';
function findRepositories(dir: string): string[] {
const repos: string[] = [];
@@ -107,7 +107,9 @@ export async function codeRoutes(fastify: AppFastifyInstance) {
let response = '';
await runAgentWorkflow(config, async () => {
// In the UI we strip out the systemDir
- if (workingDirectory !== systemDir()) {
+ logger.info(`systemDir ${systemDir()}`);
+ logger.info(`workinDir ${workingDirectory}`);
+ if (join(workingDirectory, sophiaDirName) !== systemDir()) {
workingDirectory = join(systemDir(), workingDirectory);
}
logger.info(`Setting working directory to ${workingDirectory}`);
diff --git a/src/swe/codeEditingAgent.ts b/src/swe/codeEditingAgent.ts
index 265445c8..6e913366 100644
--- a/src/swe/codeEditingAgent.ts
+++ b/src/swe/codeEditingAgent.ts
@@ -94,7 +94,7 @@ First discuss what 3rd party API usages would be required in the changes, if any
Then respond in following format:
{
- searchQueries: ["query 1", "query 2"]
+ "searchQueries": ["query 1", "query 2"]
}
`;