基于 Windows + .NET 10,每个代码文件配套同名文档,让 LLM 能自主理解、修改、迭代整个项目。
| 维度 | 选型 |
|---|---|
| 平台 | Windows |
| 运行时 | .NET 10 |
| 语言 | C# |
| 提供商 | 支持状态 | 说明 |
|---|---|---|
| MiMo | ✅ 原生支持 | reasoning_content、thinking 模式、流式 tool_calls |
| OpenAI 兼容 | ✅ 协议兼容 | 任何实现 /chat/completions 端点的服务 |
MiMo 特有优化:
reasoning_content字段 — 捕获模型思考过程CleanHistoryForMiMo— 满足 MiMo API 对 tool 消息的历史要求- thinking 模式 — mimo-v2.5/pro 默认开启,mimo-v2-flash 显式开启
- 流式 tool_calls 修复 — 处理 MiMo API 拼接导致的 JSON 问题
配置方式(llm-config.json):
{
"activeProvider": "mimo",
"activeModel": "mimo-v2.5-pro",
"providers": {
"mimo": {
"baseUrl": "https://api.mimo.example.com",
"apiKey": "your-key"
},
"openai": {
"baseUrl": "https://api.openai.com",
"apiKey": "your-key"
}
}
}每个 .cs 文件都有同名 .cs.md 文档(如 AgentLoop.cs → AgentLoop.cs.md),LLM 可直接读取文档理解代码语义,实现代码自迭代:
LLM 读取 AgentLoop.cs.md → 理解设计意图和接口契约
LLM 修改 AgentLoop.cs → 按文档约束保证改动不破坏架构
LLM 更新 AgentLoop.cs.md → 文档与代码保持同步
这意味着项目本身可以由 LLM 持续迭代维护,无需人工逐文件解释上下文。
- ReAct 循环 — 推理→执行→观察的闭环
- 工具系统 — 注册、执行、缓存、并行调用
- LLM 集成 — OpenAI 兼容协议,支持流式/非流式
- 安全策略 — 风险分级、审计日志、权限控制
- 会话管理 — 内存缓存 + Markdown 持久化
- 智能优化 — 工具缓存、死循环检测、指数退避重试
// 注入依赖
var agentLoop = new AgentLoop(
llm, registry, executor, promptBuilder, logger, config);
// 执行 Agent Loop
var result = await agentLoop.RunAsync(
userMessage: "分析这个项目的结构",
maxIterations: 100);
Console.WriteLine(result.Content);Agent.Core/
├── Planning/ # Agent 循环、提示词构建
│ ├── AgentLoop.cs # ReAct 循环核心
│ └── SystemPromptBuilder.cs
├── LLM/ # LLM 连接器
│ └── LlmConnector.cs
├── Tools/ # 工具系统
│ ├── ToolRegistry.cs
│ └── ToolExecutor.cs
├── Models/ # 数据模型
├── Config/ # 配置
├── Security/ # 安全策略
├── Context/ # 会话管理
└── doc/ # 文档
| 层级 | 类型 | 风险 | 说明 |
|---|---|---|---|
| L0 | SDK 基础调用 | 只读 | 自动执行 |
| L1 | PowerShell 命令/脚本 | 本地写入 | 自动执行 + Git commit |
| L2 | .cs 单文件 | 系统修改 | 简单确认 |
| L3 | 编译的 .exe | 危险操作 | 二次确认 |
- .NET 10+
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Logging
- Microsoft.PowerShell.SDK
每个代码文件都有同名 .cs.md 文档,提供:
- 职责说明
- 接口文档(参数、返回值)
- 使用示例
- 注意事项
| 模块 | 关键文件 | 说明 |
|---|---|---|
| Planning | AgentLoop.cs | ReAct 循环核心 |
| Planning | SystemPromptBuilder.cs | 系统提示词构建 |
| LLM | LlmConnector.cs | OpenAI 兼容连接器 |
| Tools | ToolRegistry.cs | 工具注册中心 |
| Tools | ToolExecutor.cs | 工具执行管道 |
| Security | PolicyEngine.cs | 安全策略引擎 |
| Context | SessionStore.cs | 会话持久化 |
MIT License