Skip to content

Commit af63b01

Browse files
committed
support both
1 parent 365f46a commit af63b01

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ APPLE_CODESIGN_KEYCHAIN_PASSWORD="xxx"
1212

1313
VITE_POSTHOG_API_KEY=xxx
1414
VITE_POSTHOG_API_HOST=xxx
15-
VITE_POSTHOG_UI_HOST=xxx
15+
VITE_POSTHOG_UI_HOST=xxx
16+
17+
# Use new LLM gateway locally (experimental, needs to be started in mprocs)
18+
LLM_GATEWAY_URL=http://localhost:3308

packages/agent/src/adapters/claude/claude.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -673,28 +673,30 @@ export class ClaudeAcpAgent implements Agent {
673673
throw RequestError.authRequired();
674674
}
675675

676-
// Text/thinking content is streamed via stream_event, so we only process
677-
// non-text blocks (tool_use, etc.) here to avoid duplication.
676+
// When using the gateway service, text/thinking is streamed via stream_event,
677+
// so skip them here to avoid duplication.
678678
const content = message.message.content;
679-
const contentToProcess = Array.isArray(content)
680-
? content.filter(
681-
(block) => block.type !== "text" && block.type !== "thinking",
682-
)
683-
: [];
684-
685-
if (contentToProcess.length > 0) {
686-
for (const notification of toAcpNotifications(
687-
contentToProcess,
688-
message.message.role,
689-
params.sessionId,
690-
this.toolUseCache,
691-
this.fileContentCache,
692-
this.client,
693-
this.logger,
694-
)) {
695-
await this.client.sessionUpdate(notification);
696-
this.appendNotification(params.sessionId, notification);
697-
}
679+
const isUsingGatewayService = !!(
680+
process.env.LLM_GATEWAY_URL
681+
);
682+
const contentToProcess =
683+
isUsingGatewayService && Array.isArray(content)
684+
? content.filter(
685+
(block) => block.type !== "text" && block.type !== "thinking",
686+
)
687+
: content;
688+
689+
for (const notification of toAcpNotifications(
690+
contentToProcess,
691+
message.message.role,
692+
params.sessionId,
693+
this.toolUseCache,
694+
this.fileContentCache,
695+
this.client,
696+
this.logger,
697+
)) {
698+
await this.client.sessionUpdate(notification);
699+
this.appendNotification(params.sessionId, notification);
698700
}
699701
break;
700702
}

0 commit comments

Comments
 (0)