summaryrefslogtreecommitdiff
path: root/src/Agent.Core/Runtime/StructuredJson.cs
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-08-12 00:02:23 +0900
committertanaka takashi <isazaka@gmail.com>2026-08-12 00:02:23 +0900
commitce550a127b7dc972651bd15b9f09979a2c38688f (patch)
treef4e09d0f64f74a585e015e6f548c5589fd2442ba /src/Agent.Core/Runtime/StructuredJson.cs
parent55db81082f9165a3965f860cd618bac4242c56b1 (diff)
feat: harden Python workflow and structured planning
Replace the uv-specific skill with a portable Python skill and rewrite the default user system prompt as a concise, structured Markdown execution policy. Normalize a single fenced structured-JSON response, retry invalid skill selection with think disabled, validate selected skill output, and make coding plans keep editing and verification in one task. Document the file_edit patch payload, expose that contract in the tool catalog, and convert malformed patch input into a retryable tool failure instead of terminating the agent task. Update configuration and runtime tests for the Python skill, exact tool catalog, structured-output retry, and implementation-and-verification planning guidance. Verified with 82 Agent.Core tests and an agent-mcp Python scheduling scenario with 49 passing unittest cases.
Diffstat (limited to 'src/Agent.Core/Runtime/StructuredJson.cs')
-rw-r--r--src/Agent.Core/Runtime/StructuredJson.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Agent.Core/Runtime/StructuredJson.cs b/src/Agent.Core/Runtime/StructuredJson.cs
new file mode 100644
index 0000000..e0c1650
--- /dev/null
+++ b/src/Agent.Core/Runtime/StructuredJson.cs
@@ -0,0 +1,22 @@
+namespace Agent.Core.Runtime;
+
+internal static class StructuredJson
+{
+ public static string Unwrap(string content)
+ {
+ string value = content.Trim();
+ int fenceStart = value.IndexOf("```", StringComparison.Ordinal);
+ if (fenceStart < 0) return value;
+ int firstLineEnd = value.IndexOf('\n', fenceStart);
+ if (firstLineEnd < 0) return value;
+ string opening = value[fenceStart..firstLineEnd].TrimEnd('\r');
+ if (!string.Equals(opening, "```", StringComparison.Ordinal) &&
+ !string.Equals(opening, "```json", StringComparison.OrdinalIgnoreCase))
+ return value;
+
+ int fenceEnd = value.IndexOf("```", firstLineEnd + 1, StringComparison.Ordinal);
+ if (fenceEnd < 0 || value.IndexOf("```", fenceEnd + 3, StringComparison.Ordinal) >= 0)
+ return value;
+ return value[(firstLineEnd + 1)..fenceEnd].Trim();
+ }
+}