From d5d0a84e573c833843279c520ce2d5765425ba93 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Tue, 11 Aug 2026 00:15:54 +0900 Subject: feat: implement LLM skill selection with Ollama structured output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P5残件3項目を実装: 1. Ollama structured output (format param): - OllamaChatRequestへFormat プロパティ追加 (JsonElement?) - IOllamaClientへChatStructuredAsync メソッド追加 - OllamaClient.ChatCoreAsync へformat パラメータ追加 - ChatStructuredAsync はtoolsなし、format指定でJSON構造化出力を要求 2. AgentRuntime skill selection step: - SelectSkillsAsync メソッド追加: メインループ前にOllamaへskill catalogを送信 - structured output で {"selected_skills": ["name"]} を取得 - ParseSelectedSkills: JSON解析、unknown skill名排除、重複排除、最大10件 - structured output非対応モデルはfallback空リスト - 選択されたskillのInstructionsのみPromptContext.SelectedSkillsへ設定 - Progressive Disclosure Stage 2→3 が完了 3. Skill security/path validation: - SelectSkillsAsync でsettings.Skillsからのみ選択(unknown name排除) - SkillLoader でreparse point skip済み(既存実装) - 選択数上限10件でDoS防止 - Skill load != permission grant 維持: allowed-toolsはSandbox permissionに影響しない 変更対象: - OllamaModels.cs: OllamaChatRequest.Format プロパティ追加 - IOllamaClient.cs: ChatStructuredAsync メソッド追加 - OllamaClient.cs: ChatCoreAsync へformat パラメータ追加、ChatStructuredAsync 実装 - AgentRuntime.cs: SelectSkillsAsync + ParseSelectedSkills、メインループ前の選択ステップ 検証結果: - Release build: 警告0、エラー0 - Core tests: 61/61 PASS、skip 0 - Planner tests: 10/10 PASS、skip 0 --- src/Agent.Core/Ollama/OllamaModels.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Agent.Core/Ollama/OllamaModels.cs') diff --git a/src/Agent.Core/Ollama/OllamaModels.cs b/src/Agent.Core/Ollama/OllamaModels.cs index 823a178..f4b3884 100644 --- a/src/Agent.Core/Ollama/OllamaModels.cs +++ b/src/Agent.Core/Ollama/OllamaModels.cs @@ -33,6 +33,7 @@ public sealed class OllamaChatRequest [JsonPropertyName("keep_alive")] public required string KeepAlive { get; init; } [JsonPropertyName("options")] public required IReadOnlyDictionary Options { get; init; } [JsonPropertyName("tools"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public IReadOnlyList? Tools { get; init; } + [JsonPropertyName("format"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public JsonElement? Format { get; init; } } public sealed class OllamaChatResponse -- cgit v1.2.3