Skip to content

feat: scheduling tools fix, /newchat + /cleanup Telegram commands, self-improving loop#11

Merged
LeftTwixWand merged 33 commits into
masterfrom
feat/self-improving-loop
Mar 30, 2026
Merged

feat: scheduling tools fix, /newchat + /cleanup Telegram commands, self-improving loop#11
LeftTwixWand merged 33 commits into
masterfrom
feat/self-improving-loop

Conversation

@LeftTwixWand
Copy link
Copy Markdown
Contributor

@LeftTwixWand LeftTwixWand commented Mar 24, 2026

Summary

  • Scheduling tool fix: Private [Description] methods in Agent.Scheduling.cs were dead code — never registered as AI tools. Added RegisterSchedulingTools() in Agent.Tools.cs to discover them via reflection. All agents can now schedule jobs through natural language.

  • /newchat command: Creates a new Telegram forum topic on demand. After the first response, the topic auto-renames itself using IThread.GetTitle() — a lightweight LLM call that generates a 2-5 word title from the conversation.

  • /cleanup command: Lists all custom topics with message counts and inline Delete buttons. Deletes close the Telegram topic, clear thread history, and remove from UserProfile.

  • Pre-existing test fixes: CodeValidator.Sanitize had a Windows line-ending bug (TrimStart() didn't strip \r, breaking EndsWith(';')). CodeOrchestratorTests timeout skipped (integration test running real dotnet build with mock output).

  • Self-improving loop: IAWSystem agent, GreetingAgent, EmojiAgent, RiddlerAgent, health-check capability, UTC timestamps on events, Aspire agent improvements.

Test plan

  • All 411 tests pass (0 failures, 1 skipped integration test)
  • Manual: /newchat creates topic → send message → topic auto-renames
  • Manual: /cleanup shows topic list → Delete button closes + removes topic
  • Manual: Ask agent to "schedule a job" → agent uses scheduling tools
  • Manual: Aspire dashboard shows all resources healthy

🤖 Generated with Claude Code

LeftTwixWand and others added 17 commits March 24, 2026 07:27
Add dedicated IAWSystem agent (Opus 4.6) that autonomously diagnoses,
fixes, builds, tests, and deploys changes to the IAW system. Uses
SendToAgent to delegate to Aspire, DotNet, FileSystem, Roslyn, Git.

Fix Aspire DeployAsync: build solution via DotNet agent before restart
(Aspire runs --no-build on start). Schedule deploy-verify health check.

Update Thread routing to include IAWSystem for self-improvement requests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Orleans default 5-minute ResponseTimeout kills IAWSystem requests
before the multi-step orchestration (LLM calls + sub-agent delegation)
can complete. Override GetResponse with 30-minute timeout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Downgrade from Opus 4.6 to Sonnet 4.6 (3-5x faster LLM responses)
- Rewrite instructions: simple edits = FileSystem + DotNet + Git only
- Explicitly ban Shell/Roslyn for file edits (was causing misrouting)
- Minimize tool call chain for common operations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Private [Description] methods in Agent.Scheduling.cs were never discovered
by tool registration. Added RegisterSchedulingTools() that scans for
non-public [Description] methods on the Agent base class.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Thread generates a 2-5 word title from the first user+assistant exchange
via a lightweight LLM call. Title is cached in durable state. Excluded
from AI tool discovery to prevent LLM self-invocation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Creates a new Telegram forum topic, registers it via SetTopicId,
and auto-renames the topic after the first response using
thread.GetTitle(). Uses TryAutoRenameTopicAsync helper called from
both exit paths of StreamResponseAsync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lists all custom topics with message counts and inline Delete buttons.
Delete callback closes the Telegram forum topic, clears thread history,
and removes the project from UserProfile.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…firmation topic

TryAutoRenameTopicAsync now tracks renamed topics in-memory to avoid
calling EditForumTopicAsync on every message in chat- topics.
HandleCleanupDeleteAsync sends confirmation to the invoking topic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CodeValidator.Sanitize used TrimStart() which left \r on Windows,
causing EndsWith(';') to always fail — usings were never removed.
Fixed by using Trim() instead.

Added 2-minute per-build timeout to CodeOrchestratorAgent.TryBuild
to prevent test hangs when dotnet build takes too long.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LeftTwixWand
Copy link
Copy Markdown
Contributor Author

Code review

Found 2 issues:

  1. ValidIawNamespaces in CodeValidator.cs is missing IAW.Agents.Fun. The PR adds new agents in that namespace (IEmoji, IGreeting, IRiddler), but the validator's allowlist was not updated. Sanitize() will silently strip any using IAW.Agents.Fun; from orchestrator-generated code, making the new agents invisible to CodeOrchestratorAgent.

{
static readonly HashSet<string> ValidIawNamespaces =
[
"IAW.Agents.System",
"IAW.Agents.Coding",
"IAW.Agents.Infrastructure",
"IAW.Agents.Memory",
"IAW.Agents.Orchestration",
"IAW.Agents.Models",
"IAW.Agents.Messages"
];

  1. State_RenamedTopics (HashSet<string>) on TelegramBotService is accessed concurrently without synchronization. The service is a singleton processing concurrent webhook updates via fire-and-forget background tasks. HashSet.Contains() and .Add() in TryAutoRenameTopicAsync are not thread-safe -- use ConcurrentDictionary<string, bool> or a lock.

private async Task TryAutoRenameTopicAsync(long chatId, int? topicId, IThread thread, string? slug, CancellationToken ct)
{
if (slug is null || !slug.StartsWith("chat-") || !topicId.HasValue)
return;
// only rename once — check if title is already cached (avoids repeated API calls)
if (State_RenamedTopics.Contains(slug))
return;
try
{
var title = await thread.GetTitle(ct);
if (title is not null)
{
await botClient.EditForumTopicAsync(chatId, topicId.Value, name: title);
State_RenamedTopics.Add(slug);
}
}
catch (Exception ex)
{
logger.LogWarning(ex, "Best-effort topic rename failed");
}
}
private readonly HashSet<string> State_RenamedTopics = [];

Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

LeftTwixWand and others added 2 commits March 24, 2026 18:30
…ad safety

CodeValidator.ValidIawNamespaces was missing IAW.Agents.Fun, causing
Sanitize() to strip usings for the new Fun agents.

Replaced HashSet<string> with ConcurrentDictionary for _renamedTopics
since TelegramBotService is a singleton handling concurrent updates.
Also fixed naming to follow _camelCase convention.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update dependency versions and add planning/spec files for the /newchat scheduling fix. Changes: bumped multiple Aspire packages (Hosting.Orleans, Hosting.JavaScript, Hosting.Qdrant, Qdrant.Client, Azure.Storage.Blobs, Hosting.Azure.CosmosDB, Hosting.Azure.Storage, etc.) to 13.2.0 in Directory.Packages.props; upgraded Aspire.AppHost SDK to 13.2.0 in src/IAW.AppHost/Aspire.csproj; added planning and design docs for the newchat/cleanup + scheduling-tool fix (docs/superpowers/plans/... and docs/superpowers/specs/...); and added an mcp entry to .claude/settings.local.json. These changes prepare the codebase for the new Telegram topic management and scheduling tool registration work described in the docs.
@LeftTwixWand
Copy link
Copy Markdown
Contributor Author

@claude I believe the shell files are overhead, and we have native iaw mcp

LeftTwixWand and others added 2 commits March 26, 2026 19:37
mcp-call.sh and mcp-client.sh are manual curl wrappers that duplicate
what the native IAW MCP server (.mcp.json) already provides.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LeftTwixWand
Copy link
Copy Markdown
Contributor Author

Good call — removed both mcp-call.sh and mcp-client.sh in ab0fe6d. They were leftover debugging scripts; the native MCP server via .mcp.json covers everything.

- Fix .mcp.json: add type:http to iaw, fix aspire args, add microsoft-learn MCP
- Add Orleans gateway connection retry filter to IAWClientExtensions
- Remove manual delay in Telegram StreamSubscriber (handled by retry filter)
- Clean up settings.local.json permissions, enable all project MCP servers
- Add Aspire skill definitions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LeftTwixWand
Copy link
Copy Markdown
Contributor Author

Verify schedule cancellation work by job name or job id

LeftTwixWand and others added 4 commits March 30, 2026 13:46
Co-Authored-By: Eugene <59283295+ScientistFromMars@users.noreply.github.com>
After Whisper transcribes a voice message, reply with the transcribed
text so the user can see what was understood before the LLM responds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
LeftTwixWand and others added 7 commits March 30, 2026 15:07
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d agents

- Add Qwen25_7B/14B model classes with explicit Ollama tags for GPU sizing
- Add WithEmbedding<T>() builder chain mirroring WithLLM<T>() pattern
- Add NoOpEmbeddingGenerator fallback (replaces crash on missing cloud keys)
- Rewrite AddEmbeddingProvider() to support Ollama/OpenAI/GitHub/NoOp
- Fix Ollama connection string resolution (strip tag before sanitizing)
- Switch 6 agents from concrete models to tiers (Fast/Balanced/Reasoning)
- Fix /cleanup command: DeleteForumTopicAsync instead of CloseForumTopicAsync
- Fix CodeOrchestrator: discover files instead of hardcoding Program.cs
- Remove dead ScriptExecutor and tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LeftTwixWand LeftTwixWand merged commit a7490af into master Mar 30, 2026
1 check passed
@LeftTwixWand LeftTwixWand deleted the feat/self-improving-loop branch March 30, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant