Skip to content

A programming framework for agentic AI

Fix GH bugs (#50)

Kosta Petan4808f2145ab2
diff --git a/samples/gh-flow/infra/app/gh-flow.bicep b/samples/gh-flow/infra/app/gh-flow.bicep
index a56274f08..0a78aea50 100644
--- a/samples/gh-flow/infra/app/gh-flow.bicep
+++ b/samples/gh-flow/infra/app/gh-flow.bicep
@@ -103,7 +103,7 @@ module app '../core/host/container-app.bicep' = {
value: location
}
{
- name: 'AzureOptions__ManagedIdentity'
+ name: 'AZURE_CLIENT_ID'
value: ghFlowIdentity.properties.clientId
}
{
diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/Sandbox.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/Sandbox.cs
index 3e543796c..17e1d2ce8 100644
--- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/Sandbox.cs
+++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/Sandbox.cs
@@ -53,7 +53,7 @@ public class Sandbox : Agent, IRemindable
{
if (!_state.State.IsCompleted)
{
- var sandboxId = $"sk-sandbox-{_state.State.Org}-{_state.State.Repo}-{_state.State.ParentIssueNumber}-{_state.State.IssueNumber}";
+ var sandboxId = $"sk-sandbox-{_state.State.Org}-{_state.State.Repo}-{_state.State.ParentIssueNumber}-{_state.State.IssueNumber}".ToLower();
if (await _azService.IsSandboxCompleted(sandboxId))
{
await _azService.DeleteSandbox(sandboxId);
diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs
index 48becfcfe..64081aae8 100644
--- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs
+++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs
@@ -21,7 +21,8 @@ builder.Services.AddTransient(CreateKernel);
builder.Services.AddTransient(CreateMemory);
builder.Services.AddHttpClient();
-builder.Services.AddSingleton(s =>
+
+builder.Services.AddTransient(s =>
{
var ghOptions = s.GetService<IOptions<GithubOptions>>();
var logger = s.GetService<ILogger<GithubAuthService>>();
@@ -30,11 +31,10 @@ builder.Services.AddSingleton(s =>
return client;
});
-
builder.Services.AddAzureClients(clientBuilder =>
{
- clientBuilder.UseCredential(new DefaultAzureCredential());
clientBuilder.AddArmClient(default);
+ clientBuilder.UseCredential(new DefaultAzureCredential());
});
builder.Services.AddSingleton<GithubAuthService>();
diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/AzureService.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/AzureService.cs
index 6c9b6bad7..78a9aade5 100644
--- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/AzureService.cs
+++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/AzureService.cs
@@ -66,7 +66,7 @@ public class AzureService : IManageAzure
{
try
{
- var runId = $"sk-sandbox-{org}-{repo}-{parentIssueNumber}-{issueNumber}";
+ var runId = $"sk-sandbox-{org}-{repo}-{parentIssueNumber}-{issueNumber}".ToLower();
var resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(_azSettings.SubscriptionId, _azSettings.ContainerInstancesResourceGroup);
var resourceGroupResource = _client.GetResourceGroupResource(resourceGroupResourceId);
var scriptPath = $"/azfiles/output/{org}-{repo}/{parentIssueNumber}/{issueNumber}/run.sh";
diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/GithubService.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/GithubService.cs
index f8516075b..e43641e7f 100644
--- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/GithubService.cs
+++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Services/GithubService.cs
@@ -51,9 +51,23 @@ public class GithubService : IManageGithub
{
var value = reader.ReadToEnd();
- await _ghClient.Repository.Content.CreateFile(
+ // Check if the file exists
+ var existingFiles = await _ghClient.Repository.Content.GetAllContentsByRef(org, repo, filePath, branch);
+ if (existingFiles.Any())
+ {
+ var existingFile = existingFiles.First();
+ // If the file exists, update it
+ var updateChangeSet = await _ghClient.Repository.Content.UpdateFile(
org, repo, filePath,
- new CreateFileRequest($"Commit message", value, branch)); // TODO: add more meaningfull commit message
+ new UpdateFileRequest("Updated file via AI", value, existingFile.Sha, branch)); // TODO: add more meaningfull commit message
+ }
+ else
+ {
+ // If the file doesn't exist, create it
+ var createChangeSet = await _ghClient.Repository.Content.CreateFile(
+ org, repo, filePath,
+ new CreateFileRequest("Created file via AI", value, branch)); // TODO: add more meaningfull commit message
+ }
}
}
catch (Exception ex)
diff --git a/src/Microsoft.AI.Agents.Orleans/AiAgent.cs b/src/Microsoft.AI.Agents.Orleans/AiAgent.cs
index dceb4df23..692ff3aeb 100644
--- a/src/Microsoft.AI.Agents.Orleans/AiAgent.cs
+++ b/src/Microsoft.AI.Agents.Orleans/AiAgent.cs
@@ -44,6 +44,7 @@ public abstract class AiAgent<T> : Agent, IAiAgent
var function = _kernel.CreateFunctionFromPrompt(template, propmptSettings);
var result = (await _kernel.InvokeAsync(function, arguments)).ToString();
AddToHistory(result, ChatUserType.Agent);
+ await _state.WriteStateAsync();
return result;
}