File tree Expand file tree Collapse file tree 4 files changed +59
-6
lines changed
copilot/tools/server/workflow/edit-workflow Expand file tree Collapse file tree 4 files changed +59
-6
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @vitest -environment node
3+ */
4+ import { describe , expect , it , vi } from 'vitest'
5+ import { createBlockFromParams } from './builders'
6+
7+ const agentBlockConfig = {
8+ type : 'agent' ,
9+ name : 'Agent' ,
10+ outputs : {
11+ content : { type : 'string' , description : 'Default content output' } ,
12+ } ,
13+ subBlocks : [ { id : 'responseFormat' , type : 'response-format' } ] ,
14+ }
15+
16+ vi . mock ( '@/blocks/registry' , ( ) => ( {
17+ getAllBlocks : ( ) => [ agentBlockConfig ] ,
18+ getBlock : ( type : string ) => ( type === 'agent' ? agentBlockConfig : undefined ) ,
19+ } ) )
20+
21+ describe ( 'createBlockFromParams' , ( ) => {
22+ it ( 'derives agent outputs from responseFormat when outputs are not provided' , ( ) => {
23+ const block = createBlockFromParams ( 'b-agent' , {
24+ type : 'agent' ,
25+ name : 'Agent' ,
26+ inputs : {
27+ responseFormat : {
28+ type : 'object' ,
29+ properties : {
30+ answer : {
31+ type : 'string' ,
32+ description : 'Structured answer text' ,
33+ } ,
34+ } ,
35+ required : [ 'answer' ] ,
36+ } ,
37+ } ,
38+ triggerMode : false ,
39+ } )
40+
41+ expect ( block . outputs . answer ) . toBeDefined ( )
42+ expect ( block . outputs . answer . type ) . toBe ( 'string' )
43+ } )
44+ } )
Original file line number Diff line number Diff line change 11import crypto from 'crypto'
22import { createLogger } from '@sim/logger'
33import type { PermissionGroupConfig } from '@/lib/permission-groups/types'
4- import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
4+ import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
55import { buildCanonicalIndex , isCanonicalPair } from '@/lib/workflows/subblocks/visibility'
66import { getAllBlocks } from '@/blocks/registry'
77import type { BlockConfig } from '@/blocks/types'
@@ -54,7 +54,10 @@ export function createBlockFromParams(
5454 subBlocks [ key ] = { id : key , type : 'short-input' , value : value }
5555 } )
5656 }
57- outputs = getBlockOutputs ( params . type , subBlocks , triggerMode )
57+ outputs = getEffectiveBlockOutputs ( params . type , subBlocks , {
58+ triggerMode,
59+ preferToolOutputs : ! triggerMode ,
60+ } )
5861 } else {
5962 outputs = { }
6063 }
Original file line number Diff line number Diff line change 1- import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
1+ import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
22import { getBlock } from '@/blocks'
33import type { BlockConfig , SubBlockConfig } from '@/blocks/types'
44import type { BlockState , SubBlockState , WorkflowState } from '@/stores/workflows/workflow/types'
@@ -85,7 +85,10 @@ function buildStartBlockState(
8585 subBlockValues [ config . id ] = initialValue ?? null
8686 } )
8787
88- const outputs = getBlockOutputs ( blockConfig . type , subBlocks )
88+ const outputs = getEffectiveBlockOutputs ( blockConfig . type , subBlocks , {
89+ triggerMode : false ,
90+ preferToolOutputs : true ,
91+ } )
8992
9093 const blockState : BlockState = {
9194 id : blockId ,
Original file line number Diff line number Diff line change 11import type { Edge } from 'reactflow'
22import { v4 as uuidv4 } from 'uuid'
33import { DEFAULT_DUPLICATE_OFFSET } from '@/lib/workflows/autolayout/constants'
4- import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
4+ import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
55import { mergeSubblockStateWithValues } from '@/lib/workflows/subblocks'
66import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
77import { getBlock } from '@/blocks'
@@ -188,7 +188,10 @@ export function prepareBlockState(options: PrepareBlockStateOptions): BlockState
188188 } )
189189 }
190190
191- const outputs = getBlockOutputs ( type , subBlocks , triggerMode )
191+ const outputs = getEffectiveBlockOutputs ( type , subBlocks , {
192+ triggerMode,
193+ preferToolOutputs : ! triggerMode ,
194+ } )
192195
193196 return {
194197 id,
You can’t perform that action at this time.
0 commit comments