@@ -255,6 +255,8 @@ interface SessionConfig {
255255 effort ?: EffortLevel ;
256256 /** Model to use for the session (e.g. "claude-sonnet-4-6") */
257257 model ?: string ;
258+ /** JSON Schema for structured task output — when set, the agent gets a create_output tool */
259+ jsonSchema ?: Record < string , unknown > | null ;
258260}
259261
260262interface ManagedSession {
@@ -561,6 +563,7 @@ When creating pull requests, add the following footer at the end of the PR descr
561563 customInstructions,
562564 effort,
563565 model,
566+ jsonSchema,
564567 } = config ;
565568
566569 // Preview config doesn't need a real repo — use a temp directory
@@ -623,6 +626,14 @@ When creating pull requests, add the following footer at the end of the PR descr
623626 codexBinaryPath : adapter === "codex" ? getCodexBinaryPath ( ) : undefined ,
624627 model,
625628 instructions : adapter === "codex" ? systemPrompt . append : undefined ,
629+ onStructuredOutput : jsonSchema
630+ ? async ( output ) => {
631+ const posthogAPI = agent . getPosthogAPI ( ) ;
632+ if ( posthogAPI ) {
633+ await posthogAPI . updateTaskRun ( taskId , taskRunId , { output } ) ;
634+ }
635+ }
636+ : undefined ,
626637 processCallbacks : {
627638 onProcessSpawned : ( info ) => {
628639 this . processTracking . register (
@@ -758,6 +769,7 @@ When creating pull requests, add the following footer at the end of the PR descr
758769 systemPrompt,
759770 ...( permissionMode && { permissionMode } ) ,
760771 ...( model != null && { model } ) ,
772+ ...( jsonSchema && { jsonSchema } ) ,
761773 claudeCode : {
762774 options : claudeCodeOptions ,
763775 } ,
@@ -780,6 +792,7 @@ When creating pull requests, add the following footer at the end of the PR descr
780792 systemPrompt,
781793 ...( permissionMode && { permissionMode } ) ,
782794 ...( model != null && { model } ) ,
795+ ...( jsonSchema && { jsonSchema } ) ,
783796 claudeCode : {
784797 options : claudeCodeOptions ,
785798 } ,
@@ -1470,6 +1483,7 @@ For git operations while detached:
14701483 "customInstructions" in params ? params . customInstructions : undefined ,
14711484 effort : "effort" in params ? params . effort : undefined ,
14721485 model : "model" in params ? params . model : undefined ,
1486+ jsonSchema : "jsonSchema" in params ? params . jsonSchema : undefined ,
14731487 } ;
14741488 }
14751489
0 commit comments