mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
feat: add structured output support
Add support for Agent SDK structured outputs. New input: json_schema - JSON schema for validated outputs Auto-sets GitHub Action outputs for each field Security: - Reserved output protection (prevents shadowing) - 1MB output size limits enforced - Output key format validation - Objects/arrays >1MB skipped (not truncated to invalid JSON) Tests: - 26 unit tests - 5 integration tests - 480 tests passing Docs: https://docs.claude.com/en/docs/agent-sdk/structured-outputs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -149,6 +149,14 @@ export const agentMode: Mode = {
|
||||
claudeArgs = `--mcp-config '${escapedOurConfig}'`;
|
||||
}
|
||||
|
||||
// Add JSON schema if provided
|
||||
const jsonSchemaStr = process.env.JSON_SCHEMA || "";
|
||||
if (jsonSchemaStr) {
|
||||
// CLI validates schema - just escape for safe shell passing
|
||||
const escapedSchema = jsonSchemaStr.replace(/'/g, "'\\''");
|
||||
claudeArgs += ` --json-schema '${escapedSchema}'`;
|
||||
}
|
||||
|
||||
// Append user's claude_args (which may have more --mcp-config flags)
|
||||
claudeArgs = `${claudeArgs} ${userClaudeArgs}`.trim();
|
||||
|
||||
|
||||
@@ -177,6 +177,14 @@ export const tagMode: Mode = {
|
||||
// Add required tools for tag mode
|
||||
claudeArgs += ` --allowedTools "${tagModeTools.join(",")}"`;
|
||||
|
||||
// Add JSON schema if provided
|
||||
const jsonSchemaStr = process.env.JSON_SCHEMA || "";
|
||||
if (jsonSchemaStr) {
|
||||
// CLI validates schema - just escape for safe shell passing
|
||||
const escapedSchema = jsonSchemaStr.replace(/'/g, "'\\''");
|
||||
claudeArgs += ` --json-schema '${escapedSchema}'`;
|
||||
}
|
||||
|
||||
// Append user's claude_args (which may have more --mcp-config flags)
|
||||
if (userClaudeArgs) {
|
||||
claudeArgs += ` ${userClaudeArgs}`;
|
||||
|
||||
Reference in New Issue
Block a user