This is an agent that specializes in completing code related tasks. This agent will take a user's task to be done, write a plan, generate code, execute code, and move on to the next step of the plan until the task is complete while correcting itself for any errors. It currently only supports generating and running PowerShell or Python code.
- Enter a task in natural language and the agent will generate code to complete the task. We have only tested using English but may work with other languages.
- Type
'y'
and press enter or just press enter (prompt defaults to'y'
) to run the generated code. Auto execution is configurable in the settings file, where the agent will run the code without user confirmation. - Sit back and watch the agent do the work.
- Install Python and PowerShell 7. Make sure they are added to the
PATH
environment variable. - Configure the AI service to use in the setting file
- For OpenAI, you need the Model Name and API Key. Docs: OpenAI Model, OpenAI API Key.
- For Azure OpenAI Service, you need the Endpoint, Deployment Name, Model Name, and API Key. Docs: Access to Azure OpenAI, Create an Azure OpenAI deployment.
To configure the agent, run /agent config interpreter
to open up the setting file in your default editor,
and then update the file based on the following example.
{
// To use the Azure OpenAI service:
// - Set `Endpoint` to the endpoint of your Azure OpenAI service,
// or the endpoint to the Azure API Management service if you are using it as a gateway.
// - Set `Deployment` to the deployment name of your Azure OpenAI service.
// - Set `ModelName` to the name of the model used for your deployment, e.g. "gpt-4-0613".
// - Set `Key` to the access key of your Azure OpenAI service,
// or the key of the Azure API Management service if you are using it as a gateway.
"Endpoint": "<insert your Azure OpenAI endpoint>",
"Deployment": "<insert your deployment name>",
"ModelName": "<insert the model name>",
"Key": "<insert your key>",
"AutoExecution": false, // 'true' to allow the agent run code automatically; 'false' to always prompt before running code.
"DisplayErrors": true // 'true' to display the errors when running code; 'false' to hide the errors to be less verbose.
// To use the public OpenAI service:
// - Ignore the `Endpoint` and `Deployment` keys.
// - Set `ModelName` to the name of the model to be used. e.g. "gpt-4o".
// - Set `Key` to be the OpenAI access token.
// Replace the above with the following:
/*
"ModelName": "<insert the model name>",
"Key": "<insert your key>",
"AutoExecution": false,
"DisplayErrors": true
*/
}
The architecture of this agent is depicted in the diagram below.
- The agent is initialized using the
interpreter.agent.json
file. - The model type (function calling or text based) is determined based on the setting.
TaskCompletionChat
is the main loop of the program, where a user query is processed.- If the AI response does not contain a function call/code, the main program loop is terminated.
- If the AI response contains a function call/code, the code gets executed upon user's approval.
- Code output is displayed, collected, and returned to the AI.
- If any errors is detected when running the code, the agent attempts to correct them and re-rerun code.
- The main loop continues until task is complete or more information is needed.
The execution flow of this agent is depicted in the diagram below.
- AI generated code still may produce incorrect code and responses.
- Agent may produce hallucinations for code results if there is no output to verify the code.
- Chat history is reduced to git token limits per model. When chat is too long, agent will lose context of earliest results.
- Agent can't handle concurrent tasks.