authorgravatar for abdulazeez44@gmail.comAbdul Azeez <abdulazeez44@gmail.com> 2026-06-05 23:56:32+05:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-05 18:26:32+00:00
loge1ce9f850006c8ff6eff9685e3004eab2c5c03cc
tree7c1f139b3a31692e6b58d3f8a7ca20d88c2ce2bd
parent602148f8fe4b5fe369c253022af6bedc27cd553a
signature Signed by PGP key B5690EEEBB952194

fix: handle Claude Agent SDK 0.3.x system messages to stop runtime-warning flood (#2872)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

3 files changed, 58 insertions(+), 0 deletions(-)

apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts+20
...@@ -344,6 +344,26 @@ function runtimeEventToActivities(...@@ -344,6 +344,26 @@ function runtimeEventToActivities(
344 ];344 ];
345 }345 }
346346
347 case "tool.denied": {
348 return [
349 {
350 id: event.eventId,
351 createdAt: event.createdAt,
352 tone: "error",
353 kind: "tool.denied",
354 summary: `Tool denied: ${event.payload.toolName}`,
355 payload: {
356 toolName: event.payload.toolName,
357 ...(event.payload.toolUseId ? { toolUseId: event.payload.toolUseId } : {}),
358 ...(event.payload.reason ? { detail: truncateDetail(event.payload.reason) } : {}),
359 ...(event.payload.agentId ? { agentId: event.payload.agentId } : {}),
360 },
361 turnId: toTurnId(event.turnId) ?? null,
362 ...maybeSequence,
363 },
364 ];
365 }
366
347 case "runtime.warning": {367 case "runtime.warning": {
348 return [368 return [
349 {369 {
apps/server/src/provider/Layers/ClaudeAdapter.ts+21
...@@ -2267,6 +2267,27 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (...@@ -2267,6 +2267,27 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
2267 },2267 },
2268 });2268 });
2269 return;2269 return;
2270 case "thinking_tokens":
2271 return;
2272 case "permission_denied":
2273 yield* offerRuntimeEvent({
2274 ...base,
2275 type: "tool.denied",
2276 payload: {
2277 toolName: message.tool_name,
2278 ...(message.tool_use_id ? { toolUseId: message.tool_use_id } : {}),
2279 ...(message.decision_reason ? { reason: message.decision_reason } : {}),
2280 ...(message.agent_id ? { agentId: message.agent_id } : {}),
2281 },
2282 });
2283 return;
2284 case "mirror_error":
2285 yield* emitRuntimeError(
2286 context,
2287 `Claude workspace mirror error: ${message.error}`,
2288 message,
2289 );
2290 return;
2270 default:2291 default:
2271 yield* emitRuntimeWarning(2292 yield* emitRuntimeWarning(
2272 context,2293 context,
packages/contracts/src/providerRuntime.ts+17
...@@ -241,6 +241,7 @@ const ModelReroutedType = Schema.Literal("model.rerouted");...@@ -241,6 +241,7 @@ const ModelReroutedType = Schema.Literal("model.rerouted");
241const ConfigWarningType = Schema.Literal("config.warning");241const ConfigWarningType = Schema.Literal("config.warning");
242const DeprecationNoticeType = Schema.Literal("deprecation.notice");242const DeprecationNoticeType = Schema.Literal("deprecation.notice");
243const FilesPersistedType = Schema.Literal("files.persisted");243const FilesPersistedType = Schema.Literal("files.persisted");
244const ToolDeniedType = Schema.Literal("tool.denied");
244const RuntimeWarningType = Schema.Literal("runtime.warning");245const RuntimeWarningType = Schema.Literal("runtime.warning");
245const RuntimeErrorType = Schema.Literal("runtime.error");246const RuntimeErrorType = Schema.Literal("runtime.error");
246247
...@@ -589,6 +590,14 @@ const FilesPersistedPayload = Schema.Struct({...@@ -589,6 +590,14 @@ const FilesPersistedPayload = Schema.Struct({
589});590});
590export type FilesPersistedPayload = typeof FilesPersistedPayload.Type;591export type FilesPersistedPayload = typeof FilesPersistedPayload.Type;
591592
593const ToolDeniedPayload = Schema.Struct({
594 toolName: TrimmedNonEmptyStringSchema,
595 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
596 reason: Schema.optional(TrimmedNonEmptyStringSchema),
597 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
598});
599export type ToolDeniedPayload = typeof ToolDeniedPayload.Type;
600
592const RuntimeWarningPayload = Schema.Struct({601const RuntimeWarningPayload = Schema.Struct({
593 message: TrimmedNonEmptyStringSchema,602 message: TrimmedNonEmptyStringSchema,
594 detail: Schema.optional(Schema.Unknown),603 detail: Schema.optional(Schema.Unknown),
...@@ -934,6 +943,13 @@ const ProviderRuntimeFilesPersistedEvent = Schema.Struct({...@@ -934,6 +943,13 @@ const ProviderRuntimeFilesPersistedEvent = Schema.Struct({
934});943});
935export type ProviderRuntimeFilesPersistedEvent = typeof ProviderRuntimeFilesPersistedEvent.Type;944export type ProviderRuntimeFilesPersistedEvent = typeof ProviderRuntimeFilesPersistedEvent.Type;
936945
946const ProviderRuntimeToolDeniedEvent = Schema.Struct({
947 ...ProviderRuntimeEventBase.fields,
948 type: ToolDeniedType,
949 payload: ToolDeniedPayload,
950});
951export type ProviderRuntimeToolDeniedEvent = typeof ProviderRuntimeToolDeniedEvent.Type;
952
937const ProviderRuntimeWarningEvent = Schema.Struct({953const ProviderRuntimeWarningEvent = Schema.Struct({
938 ...ProviderRuntimeEventBase.fields,954 ...ProviderRuntimeEventBase.fields,
939 type: RuntimeWarningType,955 type: RuntimeWarningType,
...@@ -994,6 +1010,7 @@ export const ProviderRuntimeEventV2 = Schema.Union([...@@ -994,6 +1010,7 @@ export const ProviderRuntimeEventV2 = Schema.Union([
994 ProviderRuntimeConfigWarningEvent,1010 ProviderRuntimeConfigWarningEvent,
995 ProviderRuntimeDeprecationNoticeEvent,1011 ProviderRuntimeDeprecationNoticeEvent,
996 ProviderRuntimeFilesPersistedEvent,1012 ProviderRuntimeFilesPersistedEvent,
1013 ProviderRuntimeToolDeniedEvent,
997 ProviderRuntimeWarningEvent,1014 ProviderRuntimeWarningEvent,
998 ProviderRuntimeErrorEvent,1015 ProviderRuntimeErrorEvent,
999]);1016]);