Skip to content

Commit f00dedd

Browse files
LeftTwixWandclaude
andcommitted
fix: address code review findings — cache resolver, fix misleading descriptions
Critical: - C1: Cache AgentInterfaceResolver.ScanInterfaces() to avoid full assembly scan on every SendToAgent call - C2: Fix misleading CleanLogsAsync description (it reads logs, doesn't clean) Important: - I1: Fix DeployAsync description to not claim rebuild capability (TODO stub) - I3: Remove deploy-verify job from OnActivateAsync (only schedule from DeployAsync) - I4: Add Aspire to error message's available agents list Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0d2f286 commit f00dedd

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/Agents/Infrastructure/AspireAgent.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ await ScheduleRecurringJob("log-monitor", TimeSpan.FromMinutes(30),
2828
"Check system health and report any resource errors or warnings.", ct);
2929
}
3030

31-
if (!ScheduledJobs.ContainsKey("deploy-verify"))
32-
{
33-
await ScheduleJob("deploy-verify", TimeSpan.FromSeconds(60),
34-
"Verify deployment health: check all resources are running.", ct);
35-
}
31+
// deploy-verify job is scheduled from DeployAsync, not on every activation
3632
}
3733

3834
protected override async Task OnScheduledJobDueAsync(ScheduledJobItem job, CancellationToken ct)

src/Agents/Infrastructure/IAspire.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ distributed system through the Aspire dashboard.
4242
[Description("Get recent structured logs for a resource. Shows errors and warnings first.")]
4343
Task<string> GetLogsAsync(string resourceName, CancellationToken ct = default);
4444

45-
[Description("Check system health and clean up monitoring state. Reports any unhealthy resources.")]
45+
[Description("Read recent logs for a resource and report monitoring state. Same as GetLogs — use for health checks.")]
4646
Task<string> CleanLogsAsync(string resourceName, CancellationToken ct = default);
4747

48-
[Description("Deploy code changes. Stops assistant, rebuilds from source via MCP /deploy endpoint, then starts with fresh binary. Use after writing code changes — slower than RestartResource but picks up new code.")]
48+
[Description("Restart the assistant resource. NOTE: currently does not rebuild from source — code changes require manual build first. Full deploy via Aspire SDK is planned.")]
4949
Task<string> DeployAsync(CancellationToken ct = default);
5050
}

src/Agents/Orchestration/ThreadAgent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private async Task<string> SendToAgentAsync(string agentName, string request, Ca
7272
var interfaceType = AgentInterfaceResolver.ResolveByDisplayName(agentName)
7373
?? AgentInterfaceResolver.Resolve(agentName);
7474
if (interfaceType is null)
75-
return $"Unknown agent: {agentName}. Available: Shell, DotNet, FileSystem, Git, Roslyn, GitHub.";
75+
return $"Unknown agent: {agentName}. Available: Shell, DotNet, FileSystem, Git, Roslyn, GitHub, Aspire.";
7676

7777
var threadId = this.GetPrimaryKeyString();
7878
var agent = (IAgent)GrainFactory.GetGrain(interfaceType, $"{threadId}/{interfaceType.Name}");

src/Core/Extensions/AgentInterfaceResolver.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public static class AgentInterfaceResolver
4747
});
4848
}
4949

50+
private static IReadOnlyList<Type>? _cachedInterfaces;
51+
5052
private static IReadOnlyList<Type> ScanInterfaces() =>
51-
AppDomain.CurrentDomain.GetAssemblies()
53+
_cachedInterfaces ??= AppDomain.CurrentDomain.GetAssemblies()
5254
.SelectMany(a => { try { return a.GetTypes(); } catch { return []; } })
5355
.Where(t => t.IsInterface
5456
&& t != typeof(IAgent)

0 commit comments

Comments
 (0)