@devries-cameron20 / t3code Mirror · read-only / commits / 2c2a286ad0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 12:15 UTC

fix(server): Claude sessions no longer log a canUseTool shadowing warning (#31548)

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

Mahir Taha Özdin committed Nov 15, 2026 at 07:54 UTC 2c2a286ad0bd45d25c7e7b54feee3664e42292c0
2 files changed +59 -4
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+33
@@ -757,6 +757,39 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
757 });
758 });
759
760 +describe("ClaudeAdapterV2 SDK warnings", () => {
761 + it("drops only the SDK's canUseTool shadowing warning while opening a query", async () => {
762 + using emitWarning = vi.spyOn(process, "emitWarning").mockImplementation(() => {});
763 + for (const options of [
764 + { permissionMode: "default", allowedTools: [ClaudeAdapterV2.CLAUDE_T3_MCP_TOOL_WILDCARD] },
765 + { permissionMode: "bypassPermissions", allowDangerouslySkipPermissions: true },
766 + ] satisfies ReadonlyArray<ClaudeSdk.Options>) {
767 + const query = ClaudeAdapterV2.withoutClaudeCanUseToolShadowedWarning(() =>
768 + ClaudeSdk.query({
769 + prompt: "",
770 + options: {
771 + ...options,
772 + canUseTool: async (_toolName, input) => ({ behavior: "allow", updatedInput: input }),
773 + pathToClaudeCodeExecutable: "/nonexistent/claude",
774 + },
775 + }),
776 + );
777 + await query.next().catch(() => undefined);
778 + }
779 + ClaudeAdapterV2.withoutClaudeCanUseToolShadowedWarning(() =>
780 + process.emitWarning("unrelated", { code: "UNRELATED_WARNING" }),
781 + );
782 +
783 + assert.deepEqual(
784 + emitWarning.mock.calls.map(([, options]) =>
785 + typeof options === "object" ? options.code : options,
786 + ),
787 + ["UNRELATED_WARNING"],
788 + );
789 + assert.strictEqual<unknown>(process.emitWarning, emitWarning);
790 + });
791 +});
792 +
793 describe("ClaudeAdapterV2 native protocol logging", () => {
794 it("injects thread-scoped MCP configuration without logging the credential", () => {
795 const threadId = ThreadId.make("thread-claude-mcp");
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+26 -4
@@ -1355,6 +1355,26 @@ const forkClaudeSessionInWorker = Effect.fn("forkClaudeSessionInWorker")(functio
1355 );
1356 });
1357
1358 +const CLAUDE_CAN_USE_TOOL_SHADOWED_WARNING = "CLAUDE_SDK_CAN_USE_TOOL_SHADOWED";
1359 +
1360 +// query() warns when canUseTool meets bypassPermissions or bare allowedTools. T3 installs
1361 +// canUseTool in every mode on purpose (AskUserQuestion, ask rules), so it is per-session noise.
1362 +export function withoutClaudeCanUseToolShadowedWarning<A>(run: () => A): A {
1363 + const emitWarning = process.emitWarning;
1364 + process.emitWarning = function (this: NodeJS.Process, ...args: Parameters<typeof emitWarning>) {
1365 + const [, options] = args;
1366 + if (typeof options === "object" && options.code === CLAUDE_CAN_USE_TOOL_SHADOWED_WARNING) {
1367 + return;
1368 + }
1369 + return Reflect.apply(emitWarning, this, args);
1370 + } as typeof emitWarning;
1371 + try {
1372 + return run();
1373 + } finally {
1374 + process.emitWarning = emitWarning;
1375 + }
1376 +}
1377 +
1378 export const layerQueryRunner: Layer.Layer<
1379 ClaudeAgentSdkQueryRunner,
1380 never,
@@ -1563,10 +1583,12 @@ export const layerQueryRunner: Layer.Layer<
1583 const queryRuntime = yield* Effect.uninterruptibleMask((restore) =>
1584 Effect.try({
1585 try: () =>
1566 - query({
1567 - prompt,
1568 - options: { ...options, spawnClaudeCodeProcess },
1569 - }),
1586 + withoutClaudeCanUseToolShadowedWarning(() =>
1587 + query({
1588 + prompt,
1589 + options: { ...options, spawnClaudeCodeProcess },
1590 + }),
1591 + ),
1592 catch: (cause) => queryRunnerError(cause, "query"),
1593 }).pipe(
1594 Effect.tap((queryRuntime) =>