Skip to content

Commit 0d45fb0

Browse files
waleedlatif1claude
andcommitted
fix(devin): scope session-tag mapping to tag ops and normalize array tag inputs
- Only map sessionTags into the tools tags param for append/replace operations, preventing stale sessionTags state from clobbering create_session tags - Fall back to a wired tags value when sessionTags is empty for tag operations - Normalize tag inputs (string or wired string[]) via normalizeTags so array values from other blocks no longer throw on .split Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b94e34e commit 0d45fb0

6 files changed

Lines changed: 38 additions & 31 deletions

File tree

apps/sim/blocks/blocks/devin.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ RULES:
108108
title: 'Tags',
109109
type: 'short-input',
110110
placeholder: 'Comma-separated tags',
111-
condition: { field: 'operation', value: 'create_session' },
112-
mode: 'advanced',
111+
required: { field: 'operation', value: ['append_session_tags', 'replace_session_tags'] },
112+
condition: {
113+
field: 'operation',
114+
value: ['create_session', 'append_session_tags', 'replace_session_tags'],
115+
},
113116
},
114117
{
115118
id: 'sessionId',
@@ -127,14 +130,6 @@ RULES:
127130
required: { field: 'operation', value: 'send_message' },
128131
condition: { field: 'operation', value: 'send_message' },
129132
},
130-
{
131-
id: 'sessionTags',
132-
title: 'Tags',
133-
type: 'short-input',
134-
placeholder: 'Comma-separated tags (max 50)',
135-
required: { field: 'operation', value: ['append_session_tags', 'replace_session_tags'] },
136-
condition: { field: 'operation', value: ['append_session_tags', 'replace_session_tags'] },
137-
},
138133
{
139134
id: 'limit',
140135
title: 'Limit',
@@ -189,9 +184,6 @@ RULES:
189184
const parsed = Number(params.limit)
190185
params.limit = Number.isFinite(parsed) ? parsed : undefined
191186
}
192-
if (params.sessionTags != null && params.sessionTags !== '') {
193-
params.tags = params.sessionTags
194-
}
195187
if (typeof params.terminateArchive === 'string') {
196188
params.archive = params.terminateArchive === 'true'
197189
}
@@ -207,8 +199,7 @@ RULES:
207199
orgId: { type: 'string', description: 'Devin organization ID' },
208200
playbookId: { type: 'string', description: 'Playbook ID to guide the session' },
209201
maxAcuLimit: { type: 'number', description: 'Maximum ACU limit' },
210-
tags: { type: 'string', description: 'Comma-separated tags' },
211-
sessionTags: { type: 'string', description: 'Comma-separated tags to append or replace' },
202+
tags: { type: 'string', description: 'Tags (comma-separated string or array of strings)' },
212203
limit: { type: 'number', description: 'Maximum number of results to return' },
213204
after: { type: 'string', description: 'Pagination cursor for the next page' },
214205
terminateArchive: {

apps/sim/tools/devin/append_session_tags.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ToolConfig } from '@/tools/types'
22
import type { DevinAppendSessionTagsParams, DevinSessionTagsResponse } from './types'
3+
import { normalizeTags } from './utils'
34

45
export const devinAppendSessionTagsTool: ToolConfig<
56
DevinAppendSessionTagsParams,
@@ -33,7 +34,7 @@ export const devinAppendSessionTagsTool: ToolConfig<
3334
type: 'string',
3435
required: true,
3536
visibility: 'user-or-llm',
36-
description: 'Comma-separated tags to append to the session',
37+
description: 'Tags to append to the session (comma-separated string or array of strings)',
3738
},
3839
},
3940

@@ -46,10 +47,7 @@ export const devinAppendSessionTagsTool: ToolConfig<
4647
'Content-Type': 'application/json',
4748
}),
4849
body: (params) => ({
49-
tags: params.tags
50-
.split(',')
51-
.map((t: string) => t.trim())
52-
.filter(Boolean),
50+
tags: normalizeTags(params.tags),
5351
}),
5452
},
5553

apps/sim/tools/devin/create_session.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ToolConfig } from '@/tools/types'
22
import type { DevinCreateSessionParams, DevinCreateSessionResponse } from './types'
33
import { DEVIN_SESSION_OUTPUT_PROPERTIES } from './types'
4+
import { normalizeTags } from './utils'
45

56
export const devinCreateSessionTool: ToolConfig<
67
DevinCreateSessionParams,
@@ -66,9 +67,8 @@ export const devinCreateSessionTool: ToolConfig<
6667
if (params.maxAcuLimit != null) {
6768
body.max_acu_limit = params.maxAcuLimit
6869
}
69-
if (params.tags) {
70-
body.tags = params.tags.split(',').map((t: string) => t.trim())
71-
}
70+
const tags = normalizeTags(params.tags)
71+
if (tags.length > 0) body.tags = tags
7272
return body
7373
},
7474
},

apps/sim/tools/devin/replace_session_tags.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ToolConfig } from '@/tools/types'
22
import type { DevinReplaceSessionTagsParams, DevinSessionTagsResponse } from './types'
3+
import { normalizeTags } from './utils'
34

45
export const devinReplaceSessionTagsTool: ToolConfig<
56
DevinReplaceSessionTagsParams,
@@ -33,7 +34,8 @@ export const devinReplaceSessionTagsTool: ToolConfig<
3334
type: 'string',
3435
required: true,
3536
visibility: 'user-or-llm',
36-
description: 'Comma-separated tags that will overwrite the existing tags',
37+
description:
38+
'Tags that will overwrite the existing tags (comma-separated string or array of strings)',
3739
},
3840
},
3941

@@ -46,10 +48,7 @@ export const devinReplaceSessionTagsTool: ToolConfig<
4648
'Content-Type': 'application/json',
4749
}),
4850
body: (params) => ({
49-
tags: params.tags
50-
.split(',')
51-
.map((t: string) => t.trim())
52-
.filter(Boolean),
51+
tags: normalizeTags(params.tags),
5352
}),
5453
},
5554

apps/sim/tools/devin/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface DevinCreateSessionParams {
66
prompt: string
77
playbookId?: string
88
maxAcuLimit?: number
9-
tags?: string
9+
tags?: string | string[]
1010
}
1111

1212
export interface DevinGetSessionParams {
@@ -53,14 +53,14 @@ export interface DevinAppendSessionTagsParams {
5353
apiKey: string
5454
orgId: string
5555
sessionId: string
56-
tags: string
56+
tags: string | string[]
5757
}
5858

5959
export interface DevinReplaceSessionTagsParams {
6060
apiKey: string
6161
orgId: string
6262
sessionId: string
63-
tags: string
63+
tags: string | string[]
6464
}
6565

6666
export interface DevinArchiveSessionParams {

apps/sim/tools/devin/utils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Normalize a tags input into a clean string array.
3+
*
4+
* Tags can arrive either as a comma-separated string (typed into the block's
5+
* text input) or as a string array (when wired from another block's JSON
6+
* output, e.g. the tags returned by a get/append/replace tags operation).
7+
*/
8+
export function normalizeTags(input: string | string[] | undefined | null): string[] {
9+
if (Array.isArray(input)) {
10+
return input.map((tag) => String(tag).trim()).filter(Boolean)
11+
}
12+
if (typeof input === 'string') {
13+
return input
14+
.split(',')
15+
.map((tag) => tag.trim())
16+
.filter(Boolean)
17+
}
18+
return []
19+
}

0 commit comments

Comments
 (0)