Skip to content

Commit afa497a

Browse files
committed
System role in cache
1 parent c69d710 commit afa497a

5 files changed

Lines changed: 64 additions & 12 deletions

File tree

apps/sim/app/api/mcp/copilot/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { resolveWorkflowIdForUser } from '@/lib/workflows/utils'
3838

3939
const logger = createLogger('CopilotMcpAPI')
4040
const mcpRateLimiter = new RateLimiter()
41-
const DEFAULT_COPILOT_MODEL = 'claude-opus-4-6'
41+
const DEFAULT_COPILOT_MODEL = 'claude-opus-4-8'
4242

4343
export const dynamic = 'force-dynamic'
4444
export const runtime = 'nodejs'

apps/sim/lib/copilot/chat/payload.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ vi.mock('@/tools/params', () => ({
5757
createUserToolSchema: mockCreateUserToolSchema,
5858
}))
5959

60-
import { buildIntegrationToolSchemas } from './payload'
60+
import { buildCopilotRequestPayload, buildIntegrationToolSchemas } from './payload'
6161

6262
describe('buildIntegrationToolSchemas', () => {
6363
beforeEach(() => {
@@ -123,3 +123,31 @@ describe('buildIntegrationToolSchemas', () => {
123123
)
124124
})
125125
})
126+
127+
describe('buildCopilotRequestPayload', () => {
128+
beforeEach(() => {
129+
vi.clearAllMocks()
130+
})
131+
132+
it('passes workspaceContext through to the Go request payload', async () => {
133+
const payload = await buildCopilotRequestPayload(
134+
{
135+
message: 'debug workspace',
136+
userId: 'user-1',
137+
userMessageId: 'msg-1',
138+
mode: 'agent',
139+
model: 'claude-opus-4-8',
140+
workspaceId: 'ws-1',
141+
workspaceContext: 'workspace inventory',
142+
},
143+
{ selectedModel: 'claude-opus-4-8' }
144+
)
145+
146+
expect(payload).toEqual(
147+
expect.objectContaining({
148+
workspaceId: 'ws-1',
149+
workspaceContext: 'workspace inventory',
150+
})
151+
)
152+
})
153+
})

apps/sim/lib/copilot/chat/post.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,17 @@ describe('handleUnifiedChatPost', () => {
167167
)
168168

169169
expect(response.status).toBe(200)
170+
expect(generateWorkspaceContext).toHaveBeenCalledWith('ws-1', 'user-1')
170171
expect(buildCopilotRequestPayload).toHaveBeenCalledWith(
171172
expect.objectContaining({
172-
model: 'claude-opus-4-7',
173+
model: 'claude-opus-4-8',
174+
workspaceContext: 'workspace context',
173175
}),
174-
{ selectedModel: 'claude-opus-4-7' }
176+
{ selectedModel: 'claude-opus-4-8' }
175177
)
176178
expect(createSSEStream).toHaveBeenCalledWith(
177179
expect.objectContaining({
178-
titleModel: 'claude-opus-4-7',
180+
titleModel: 'claude-opus-4-8',
179181
workspaceId: 'ws-1',
180182
orchestrateOptions: expect.objectContaining({
181183
workflowId: 'wf-1',
@@ -213,7 +215,7 @@ describe('handleUnifiedChatPost', () => {
213215
)
214216
expect(createSSEStream).toHaveBeenCalledWith(
215217
expect.objectContaining({
216-
titleModel: 'claude-opus-4-7',
218+
titleModel: 'claude-opus-4-8',
217219
workspaceId: 'ws-1',
218220
orchestrateOptions: expect.objectContaining({
219221
workspaceId: 'ws-1',

apps/sim/lib/copilot/chat/post.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import type { ChatContext } from '@/stores/panel'
5050
export const maxDuration = 3600
5151

5252
const logger = createLogger('UnifiedChatAPI')
53-
const DEFAULT_MODEL = 'claude-opus-4-7'
53+
const DEFAULT_MODEL = 'claude-opus-4-8'
5454

5555
const FileAttachmentSchema = z.object({
5656
id: z.string(),
@@ -172,6 +172,7 @@ type UnifiedChatBranch =
172172
commands?: string[]
173173
prefetch?: boolean
174174
implicitFeedback?: string
175+
workspaceContext?: string
175176
}) => Promise<Record<string, unknown>>
176177
buildExecutionContext: (params: {
177178
userId: string
@@ -556,7 +557,7 @@ async function resolveBranch(params: {
556557
workflowId: resolvedWorkflowId,
557558
workflowName: resolved.workflowName,
558559
workspaceId: resolvedWorkspaceId,
559-
effectiveModel: selectedModel,
560+
effectiveModel: selectedModel,
560561
selectedModel,
561562
mode: mode ?? 'agent',
562563
provider,
@@ -582,6 +583,7 @@ async function resolveBranch(params: {
582583
chatId: payloadParams.chatId,
583584
prefetch: payloadParams.prefetch,
584585
implicitFeedback: payloadParams.implicitFeedback,
586+
workspaceContext: payloadParams.workspaceContext,
585587
userPermission: payloadParams.userPermission,
586588
userTimezone: payloadParams.userTimezone,
587589
},
@@ -852,11 +854,11 @@ export async function handleUnifiedChatPost(req: NextRequest) {
852854
// apparent "gap" before the model call. Each promise is its own
853855
// span; they run concurrently under Promise.all below.
854856
const workspaceContextPromise =
855-
branch.kind === 'workspace'
857+
workspaceId
856858
? withCopilotSpan(
857859
TraceSpan.CopilotChatBuildWorkspaceContext,
858-
{ [TraceAttr.WorkspaceId]: branch.workspaceId },
859-
() => generateWorkspaceContext(branch.workspaceId, authenticatedUserId),
860+
{ [TraceAttr.WorkspaceId]: workspaceId },
861+
() => generateWorkspaceContext(workspaceId, authenticatedUserId),
860862
activeOtelRoot.context
861863
)
862864
: Promise.resolve(undefined)
@@ -950,6 +952,7 @@ export async function handleUnifiedChatPost(req: NextRequest) {
950952
commands: body.commands,
951953
prefetch: body.prefetch,
952954
implicitFeedback: body.implicitFeedback,
955+
workspaceContext,
953956
})
954957
: branch.buildPayload({
955958
message: body.message,

apps/sim/providers/models.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,26 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
567567
toolUsageControl: true,
568568
},
569569
models: [
570+
{
571+
id: 'claude-opus-4-8',
572+
pricing: {
573+
input: 5.0,
574+
cachedInput: 0.5,
575+
output: 25.0,
576+
updatedAt: '2026-05-28',
577+
},
578+
capabilities: {
579+
nativeStructuredOutputs: true,
580+
maxOutputTokens: 128000,
581+
thinking: {
582+
levels: ['low', 'medium', 'high', 'xhigh', 'max'],
583+
default: 'high',
584+
},
585+
},
586+
contextWindow: 1000000,
587+
releaseDate: '2026-05-28',
588+
recommended: true,
589+
},
570590
{
571591
id: 'claude-opus-4-7',
572592
pricing: {
@@ -585,7 +605,6 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
585605
},
586606
contextWindow: 1000000,
587607
releaseDate: '2026-04-16',
588-
recommended: true,
589608
},
590609
{
591610
id: 'claude-opus-4-6',

0 commit comments

Comments
 (0)