The best way to control Claude Code, Codex and more from any computer or phone
feat(server,web,mobile): thread links name their environment and never a title (#26239)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 20:39 UTC
c2fbf0a52454f2816012eae1fe7230cc69d69f2a
27 files changed
+427
-185
apps/mobile/src/features/threads/PendingUserInputCard.tsx
+7
-4
@@ -1,6 +1,6 @@
1
import { Button } from "../../components/ui/Button";
2
import { QuestionAttachments } from "./QuestionAttachments";
3
-import type { RuntimeRequestId } from "@t3tools/contracts";
3
+import type { EnvironmentId, RuntimeRequestId } from "@t3tools/contracts";
4
import type { ThreadUserInputQuestion } from "@t3tools/client-runtime/state/thread-requests";
5
import { useRef } from "react";
6
import { Platform, Pressable, ScrollView, View, type LayoutChangeEvent } from "react-native";
@@ -23,6 +23,7 @@ import { cn } from "../../lib/cn";
23
import { SelectableMarkdownText } from "../../native/SelectableMarkdownText";
24
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
25
import { useMarkdownPreviewStyles } from "../files/FileMarkdownPreview";
26
+import { useLiveThreadLinkLabels } from "../../state/entities";
27
import {
28
isPendingUserInputOptionSelected,
29
type PendingUserInput,
@@ -30,6 +31,7 @@ import {
31
} from "../../lib/threadActivity";
32
33
export interface PendingUserInputCardProps {
34
+ readonly environmentId: EnvironmentId;
35
readonly canOperateThread: boolean;
36
readonly pendingUserInput: PendingUserInput;
37
readonly maxHeight: DerivedValue<number>;
@@ -59,12 +61,13 @@ export interface PendingUserInputCardProps {
61
/** Android cannot hit-test overlays beyond their parent's bounds; render its expanded card in-flow. */
62
const EXPANDED_CARD_IS_OVERLAY = Platform.OS === "ios";
63
62
-function QuestionText(props: { readonly markdown: string }) {
64
+function QuestionText(props: { readonly markdown: string; readonly environmentId: EnvironmentId }) {
65
const styles = useMarkdownPreviewStyles();
66
+ const markdown = useLiveThreadLinkLabels(props.markdown, props.environmentId);
67
const openLink = useOpenPullRequest();
68
return (
69
<SelectableMarkdownText
67
- markdown={props.markdown}
70
+ markdown={markdown}
71
textStyle={styles.nativeTextStyle}
72
onLinkPress={(href) => void openLink(href)}
73
/>
@@ -217,7 +220,7 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
220
<Text className="font-t3-bold text-xs uppercase tracking-[1px] text-foreground-muted">
221
{question.header}
222
</Text>
220
- <QuestionText markdown={question.question} />
223
+ <QuestionText markdown={question.question} environmentId={props.environmentId} />
224
<View className="gap-2">
225
{question.options.map((option) => {
226
const optionValue = option.value ?? option.label.trim();
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+1
@@ -1513,6 +1513,7 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
1513
) : null}
1514
{props.activePendingUserInput ? (
1515
<PendingUserInputCard
1516
+ environmentId={props.environmentId}
1517
canOperateThread={props.canOperateThread}
1518
pendingUserInput={props.activePendingUserInput}
1519
maxHeight={pendingUserInputMaxHeight}
apps/mobile/src/features/threads/ThreadFeed.tsx
+19
-13
@@ -56,7 +56,7 @@ import {
56
} from "@t3tools/contracts";
57
import { renderAssistantCitationsAsText } from "@t3tools/shared/assistantCitations";
58
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
59
-import { parseThreadLinkHref, resolveThreadLinkRef } from "@t3tools/shared/threadLinks";
59
+import { parseThreadLinkHref } from "@t3tools/shared/threadLinks";
60
import { PROMPT_LINK_MAX_PROMPT_LENGTH } from "@t3tools/shared/promptLinks";
61
import {
62
parseComposerContextHref,
@@ -239,6 +239,7 @@ import {
239
WORKSPACE_BASENAME_LOOKUP_LIMIT,
240
} from "@t3tools/client-runtime/workspace-basename-lookup";
241
import {
242
+ resolveThreadLink,
243
useLiveThreadLinkLabels,
244
useQuietThreadShell,
245
useThreadChipIcons,
@@ -2255,13 +2256,16 @@ export const ThreadFeed = memo(function ThreadFeed({
2256
});
2257
};
2258
const resolveLinkedThread = (href: string) => {
2258
- const linkedThreadId = parseThreadLinkHref(href);
2259
- if (!linkedThreadId) return null;
2260
- const source = scopeThreadRef(props.environmentId, linkedThreadId);
2261
- return (
2262
- resolveThreadLinkRef(source, appAtomRegistry.get(environmentThreadShells.threadRefsAtom)) ??
2263
- source
2259
+ const link = parseThreadLinkHref(href);
2260
+ if (!link) return null;
2261
+ const resolved = resolveThreadLink(
2262
+ (atom) => appAtomRegistry.get(atom),
2263
+ link,
2264
+ props.environmentId,
2265
);
2266
+ if (resolved !== null || link.environmentId !== null) return resolved;
2267
+ // A v1 link names no environment, so it falls back to this message's.
2268
+ return scopeThreadRef(props.environmentId, link.threadId);
2269
};
2270
const onMarkdownLinkPress = (href: string, imageEmbed = false) => {
2271
markdownLinkRequest.current?.abort();
@@ -2273,12 +2277,14 @@ export const ThreadFeed = memo(function ThreadFeed({
2277
if (instructionsPath) openSkillInstructions(instructionsPath);
2278
return;
2279
}
2276
- const target = resolveLinkedThread(href);
2277
- if (target) {
2278
- openLinkedThread({
2279
- environmentId: String(target.environmentId),
2280
- threadId: String(target.threadId),
2281
- });
2280
+ if (parseThreadLinkHref(href)) {
2281
+ const target = resolveLinkedThread(href);
2282
+ if (target) {
2283
+ openLinkedThread({
2284
+ environmentId: String(target.environmentId),
2285
+ threadId: String(target.threadId),
2286
+ });
2287
+ }
2288
return;
2289
}
2290
const media = resolveMarkdownMediaPreview(href, {
apps/mobile/src/lib/enrichedLinkPresentation.test.ts
+13
-5
@@ -51,10 +51,12 @@ describe("Enriched link presentation", () => {
51
});
52
53
it("presents thread links as thread chips and leaves other links alone", () => {
54
- expect(enrichedThreadLinkPresentation("t3-thread://v1/thread%3Aproject%3A1")).toEqual({
55
- accent: "#009c96",
56
- icon: { kind: "chip", name: "messages-square" },
57
- });
54
+ for (const href of ["t3-thread://v1/thread%3Aproject%3A1", "t3-thread://v2/env/thread_1"]) {
55
+ expect(enrichedThreadLinkPresentation(href), href).toEqual({
56
+ accent: "#009c96",
57
+ icon: { kind: "chip", name: "messages-square" },
58
+ });
59
+ }
60
for (const href of [
61
"https://github.com/example/repo/pull/7",
62
"https://example.com",
@@ -70,7 +72,7 @@ describe("Enriched link presentation", () => {
72
expect(
73
threadChipTargets(
74
here,
73
- "See [A](t3-thread://v1/thread_a), [A again](t3-thread://v1/thread_a) and [B](t3-thread://v1/thread_b).",
75
+ "See [A](t3-thread://v1/thread_a), [A again](t3-thread://v1/thread_a), [B](t3-thread://v1/thread_b) and [D](t3-thread://v2/env-there/thread_d).",
76
[
77
{
78
version: 1,
@@ -86,6 +88,12 @@ describe("Enriched link presentation", () => {
88
).toEqual([
89
{ href: "t3-thread://v1/thread_a", environmentId: here, threadId: "thread_a", link: true },
90
{ href: "t3-thread://v1/thread_b", environmentId: here, threadId: "thread_b", link: true },
91
+ {
92
+ href: "t3-thread://v2/env-there/thread_d",
93
+ environmentId: there,
94
+ threadId: "thread_d",
95
+ link: true,
96
+ },
97
{
98
href: "t3-context://v1/thread/thr1",
99
environmentId: there,
apps/mobile/src/lib/enrichedLinkPresentation.ts
+10
-3
@@ -58,9 +58,16 @@ export function threadChipTargets(
58
): ReadonlyArray<ThreadChipTarget> {
59
const targets = new Map<string, ThreadChipTarget>();
60
if (hasThreadLinks(markdown)) {
61
- for (const [, href = ""] of markdown.matchAll(/\]\((t3-thread:\/\/v1\/[^\s)]+)\)/g)) {
62
- const threadId = parseThreadLinkHref(href);
63
- if (threadId) targets.set(href, { href, environmentId, threadId, link: true });
61
+ for (const [, href = ""] of markdown.matchAll(/\]\((t3-thread:\/\/v[12]\/[^\s)]+)\)/g)) {
62
+ const link = parseThreadLinkHref(href);
63
+ if (link) {
64
+ targets.set(href, {
65
+ href,
66
+ environmentId: link.environmentId ?? environmentId,
67
+ threadId: link.threadId,
68
+ link: true,
69
+ });
70
+ }
71
}
72
}
73
for (const record of records ?? []) {
apps/mobile/src/state/entities.ts
+52
-26
@@ -17,9 +17,13 @@ import {
17
} from "@t3tools/contracts";
18
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
19
import {
20
+ guessThreadLinkRef,
21
hasThreadLinks,
22
+ parseThreadLinkHref,
23
relabelThreadLinks,
22
- resolveThreadLinkRef,
24
+ threadLinkCandidates,
25
+ threadLinkRefs,
26
+ type ThreadLink,
27
} from "@t3tools/shared/threadLinks";
28
import * as Option from "effect/Option";
29
import * as Schema from "effect/Schema";
@@ -45,26 +49,35 @@ const EMPTY_SERVER_CONFIG_ATOM = Atom.make<ServerConfig | null>(null).pipe(
49
const EMPTY_THREAD_ATOM = Atom.make<EnvironmentThread | null>(null).pipe(
50
Atom.withLabel("mobile-thread:empty"),
51
);
48
-const EMPTY_THREAD_TITLES: ReadonlyMap<ThreadId, string> = new Map();
49
-const EMPTY_THREAD_TITLES_ATOM = Atom.make(EMPTY_THREAD_TITLES).pipe(
50
- Atom.withLabel("mobile-thread-titles:empty"),
52
+const EMPTY_THREAD_LINK_TITLES_ATOM = Atom.make<ReadonlyMap<string, string>>(new Map()).pipe(
53
+ Atom.withLabel("mobile-thread-link-titles:empty"),
54
);
55
53
-const threadTitlesAtom = Atom.family((environmentId: EnvironmentId) => {
54
- let previous = EMPTY_THREAD_TITLES;
56
+const decodeThreadKey = Schema.decodeUnknownSync(Schema.Tuple([EnvironmentId, ThreadId]));
57
+const threadKey = (ref: ScopedThreadRef) => JSON.stringify([ref.environmentId, ref.threadId]);
58
+
59
+// Null when this client doesn't know the thread. Keyed, so a link never walks an environment's threads.
60
+const threadTitleAtom = Atom.family((key: string) => {
61
+ const ref = scopeThreadRef(...decodeThreadKey(JSON.parse(key)));
62
+ return Atom.make((get) => get(environmentThreadShells.threadShellAtom(ref))?.title ?? null).pipe(
63
+ Atom.withLabel(`mobile-thread-title:${key}`),
64
+ );
65
+});
66
+
67
+const decodeThreadKeys = Schema.decodeUnknownSync(Schema.Array(Schema.String));
68
+
69
+const threadLinkTitlesAtom = Atom.family((key: string) => {
70
+ const refKeys = decodeThreadKeys(JSON.parse(key));
71
return Atom.make((get) => {
56
- const index = get(environmentThreadShells.environmentThreadIndexAtom(environmentId));
57
- const unchanged =
58
- index.size === previous.size &&
59
- Array.from(index).every(([threadId, shell]) => previous.get(threadId) === shell.title);
60
- if (!unchanged) {
61
- previous = new Map(Array.from(index, ([threadId, shell]) => [threadId, shell.title]));
72
+ const titles = new Map<string, string>();
73
+ for (const refKey of refKeys) {
74
+ const title = get(threadTitleAtom(refKey));
75
+ if (title !== null) titles.set(refKey, title);
76
}
63
- return previous;
64
- }).pipe(Atom.withLabel(`mobile-thread-titles:${environmentId}`));
77
+ return titles;
78
+ }).pipe(Atom.withLabel(`mobile-thread-link-titles:${key}`));
79
});
80
67
-const decodeThreadKey = Schema.decodeUnknownSync(Schema.Tuple([EnvironmentId, ThreadId]));
81
const decodeThreadChipTargets = Schema.decodeUnknownSync(
82
Schema.Array(
83
Schema.Struct({
@@ -118,13 +131,11 @@ const threadChipIconsAtom = Atom.family((key: string) => {
131
return Atom.make((get) => {
132
const icons = new Map<string, string>();
133
for (const target of targets) {
121
- const source = scopeThreadRef(target.environmentId, target.threadId);
122
- const ref = target.link
123
- ? (resolveThreadLinkRef(source, get(environmentThreadShells.threadRefsAtom)) ?? source)
124
- : source;
125
- const icon = get(
126
- threadProjectChipIconAtom(JSON.stringify([ref.environmentId, ref.threadId])),
127
- );
134
+ const link = target.link ? parseThreadLinkHref(target.href) : null;
135
+ const ref =
136
+ (link ? resolveThreadLink(get, link, target.environmentId) : null) ??
137
+ scopeThreadRef(target.environmentId, target.threadId);
138
+ const icon = get(threadProjectChipIconAtom(threadKey(ref)));
139
if (icon) icons.set(target.href, icon);
140
}
141
return icons;
@@ -190,11 +201,26 @@ export function useChildThreadInputs(ref: ScopedThreadRef) {
201
202
export function useLiveThreadLinkLabels(markdown: string, environmentId: EnvironmentId): string {
203
const titles = useAtomValue(
193
- hasThreadLinks(markdown) ? threadTitlesAtom(environmentId) : EMPTY_THREAD_TITLES_ATOM,
204
+ hasThreadLinks(markdown)
205
+ ? threadLinkTitlesAtom(JSON.stringify(threadLinkRefs(markdown, environmentId).map(threadKey)))
206
+ : EMPTY_THREAD_LINK_TITLES_ATOM,
207
+ );
208
+ return relabelThreadLinks(markdown, environmentId, (ref) => titles.get(threadKey(ref)));
209
+}
210
+
211
+/** Keyed reads; every thread is read only to place a v1 link its message's environment lacks. */
212
+export function resolveThreadLink(
213
+ read: <A>(atom: Atom.Atom<A>) => A,
214
+ link: ThreadLink,
215
+ messageEnvironmentId: EnvironmentId,
216
+): ScopedThreadRef | null {
217
+ const known = threadLinkCandidates(link, messageEnvironmentId).find(
218
+ (ref) => read(threadTitleAtom(threadKey(ref))) !== null,
219
);
195
- return titles.size === 0
196
- ? markdown
197
- : relabelThreadLinks(markdown, (threadId) => titles.get(threadId));
220
+ if (known) return known;
221
+ return link.environmentId === null
222
+ ? guessThreadLinkRef(link, read(environmentThreadShells.threadRefsAtom))
223
+ : null;
224
}
225
226
export function useThreadChipIcons(
apps/server/src/mcp/OrchestratorMcpService.ts
+22
-8
@@ -1,5 +1,6 @@
1
import {
2
CommandId,
3
+ type EnvironmentId,
4
type RunId,
5
isProviderAvailable,
6
MessageId,
@@ -748,13 +749,14 @@ function threadPullRequests(
749
}
750
751
function listItemFromShell(
752
+ environmentId: EnvironmentId,
753
shell: OrchestrationV2ThreadShell,
754
nowMs: number,
755
): OrchestratorMcpThreadListItem {
756
return {
757
threadId: shell.id,
758
title: shell.title,
757
- link: formatThreadLink(shell.id, shell.title),
759
+ link: formatThreadLink({ environmentId, threadId: shell.id }),
760
createdBy: shell.createdBy,
761
creationSource: shell.creationSource,
762
status: shell.activityRunStatus ?? shell.status,
@@ -776,6 +778,7 @@ function listItemFromShell(
778
}
779
780
function threadDetail(
781
+ environmentId: EnvironmentId,
782
projection: Pick<OrchestrationV2ThreadProjection, "thread" | "runs" | "runtimeRequests">,
783
itemCount: number,
784
shell: OrchestrationV2ThreadShell,
@@ -787,7 +790,7 @@ function threadDetail(
790
threadId: projection.thread.id,
791
projectId: projection.thread.projectId,
792
title: projection.thread.title,
790
- link: formatThreadLink(projection.thread.id, projection.thread.title),
793
+ link: formatThreadLink({ environmentId, threadId: projection.thread.id }),
794
createdBy: projection.thread.createdBy,
795
creationSource: projection.thread.creationSource,
796
status: active?.status ?? latest?.status ?? "idle",
@@ -1518,7 +1521,10 @@ const make = Effect.gen(function* () {
1521
const result = {
1522
taskId: task.id,
1523
childThreadId: task.childThreadId,
1521
- link: formatThreadLink(task.childThreadId, childControls.thread.title),
1524
+ link: formatThreadLink({
1525
+ environmentId: scope.environmentId,
1526
+ threadId: task.childThreadId,
1527
+ }),
1528
childRunId: childRun?.id ?? null,
1529
childNodeId: task.id,
1530
status,
@@ -1674,7 +1680,9 @@ const make = Effect.gen(function* () {
1680
return {
1681
taskId: task.id,
1682
childThreadId: null,
1677
- ...(task.remoteChild === undefined ? {} : { remoteChild: task.remoteChild }),
1683
+ ...(task.remoteChild === undefined
1684
+ ? {}
1685
+ : { remoteChild: task.remoteChild, link: formatThreadLink(task.remoteChild) }),
1686
childRunId: null,
1687
childNodeId: task.id,
1688
status,
@@ -2739,7 +2747,7 @@ const make = Effect.gen(function* () {
2747
);
2748
return {
2749
threadId,
2742
- link: formatThreadLink(threadId, projection.thread.title),
2750
+ link: formatThreadLink({ environmentId: scope.environmentId, threadId }),
2751
runId: run?.id ?? null,
2752
status: run?.status ?? "idle",
2753
title: projection.thread.title,
@@ -2792,7 +2800,7 @@ const make = Effect.gen(function* () {
2800
return {
2801
projectId,
2802
currentThreadId: parent?.thread.id ?? null,
2795
- threads: page.map((shell) => listItemFromShell(shell, nowMs)),
2803
+ threads: page.map((shell) => listItemFromShell(scope.environmentId, shell, nowMs)),
2804
nextCursor,
2805
total: filtered.length,
2806
} satisfies OrchestratorMcpThreadListResult;
@@ -2872,7 +2880,13 @@ const make = Effect.gen(function* () {
2880
}
2881
}
2882
return {
2875
- thread: threadDetail(target, timeline.totalItems, shell, yield* Clock.currentTimeMillis),
2883
+ thread: threadDetail(
2884
+ scope.environmentId,
2885
+ target,
2886
+ timeline.totalItems,
2887
+ shell,
2888
+ yield* Clock.currentTimeMillis,
2889
+ ),
2890
recentRuns: target.runs
2891
.toSorted((left, right) => right.ordinal - left.ordinal)
2892
.slice(0, input.runLimit ?? DEFAULT_THREAD_RUN_LIMIT)
@@ -2931,7 +2945,7 @@ const make = Effect.gen(function* () {
2945
);
2946
return {
2947
threadId: input.threadId,
2934
- link: formatThreadLink(input.threadId, target.thread.title),
2948
+ link: formatThreadLink({ environmentId: scope.environmentId, threadId: input.threadId }),
2949
messageId,
2950
runId: result.run.id,
2951
...(result.run.delegatedTaskId === undefined ? {} : { taskId: result.run.delegatedTaskId }),
apps/server/src/mcp/toolkits/project/handlers.test.ts
+1
-1
@@ -185,7 +185,7 @@ it.effect(
185
expect(belowCeiling.result).toMatchObject({
186
projectId: belowCeiling.projectId,
187
modelSelection: belowCeiling.modelSelection,
188
- link: `[Fix](t3-thread://v1/${belowCeiling.launched[0]?.threadId})`,
188
+ link: `<t3-thread://v2/environment/${belowCeiling.launched[0]?.threadId}>`,
189
});
190
expect(belowCeiling.launched[0]?.runtimeMode).toBe("approval-required");
191
expect(belowCeiling.launched[0]?.initialMessage?.senderThreadId).toBeUndefined();
apps/server/src/mcp/toolkits/project/handlers.ts
+1
-1
@@ -240,7 +240,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
240
const run = result.projection.runs.find((run) => run.userMessageId === messageId);
241
return {
242
threadId: thread.id,
243
- link: formatThreadLink(thread.id, thread.title),
243
+ link: formatThreadLink({ environmentId: scope.environmentId, threadId: thread.id }),
244
projectId: thread.projectId,
245
modelSelection: thread.modelSelection,
246
runId: run?.id ?? null,
apps/server/src/mcp/toolkits/thread/handlers.ts
+5
-1
@@ -11,6 +11,7 @@ import * as Effect from "effect/Effect";
11
import { modelSelectionCommandType } from "@t3tools/shared/model";
12
import { formatThreadLink } from "@t3tools/shared/threadLinks";
13
14
+import * as McpInvocationContext from "../../McpInvocationContext.ts";
15
import * as McpToolAccess from "../../McpToolAccess.ts";
16
import {
17
dispatchFailure,
@@ -103,9 +104,11 @@ export const layer = McpToolAccess.toLayer(ThreadToolkit, {
104
const { task, threadId } = yield* scheduler
105
.runNow({ id: input.taskId })
106
.pipe(Effect.mapError(unavailable));
107
+ const { environmentId } = yield* McpInvocationContext.McpInvocationContext;
108
return {
109
taskId: task.id,
110
threadId,
111
+ ...(threadId === null ? {} : { link: formatThreadLink({ environmentId, threadId }) }),
112
lastRunStatus: task.lastRunStatus,
113
runCount: task.runCount,
114
nextRunAt: task.nextRunAt,
@@ -115,6 +118,7 @@ export const layer = McpToolAccess.toLayer(ThreadToolkit, {
118
t3_thread_search: McpToolAccess.reads((input) =>
119
Effect.gen(function* () {
120
const { caller } = yield* readCaller();
121
+ const { environmentId } = yield* McpInvocationContext.McpInvocationContext;
122
const threadSearch = yield* ThreadSearch.ThreadSearch;
123
const { matches } = yield* threadSearch
124
.searchThreads({ ...input, projectId: input.projectId ?? caller?.projectId })
@@ -122,7 +126,7 @@ export const layer = McpToolAccess.toLayer(ThreadToolkit, {
126
return {
127
matches: matches.map((match) => ({
128
...match,
125
- link: formatThreadLink(match.threadId, match.title),
129
+ link: formatThreadLink({ environmentId, threadId: match.threadId }),
130
})),
131
};
132
}),
apps/server/src/mcp/toolkits/thread/tools.ts
+1
@@ -226,6 +226,7 @@ const ScheduledTaskRunTool = Tool.make("run_scheduled_task_now", {
226
success: Schema.Struct({
227
taskId: ScheduledTaskId,
228
threadId: ScheduledTask.fields.threadId,
229
+ link: Schema.optional(Schema.String),
230
lastRunStatus: ScheduledTask.fields.lastRunStatus,
231
runCount: NonNegativeInt,
232
nextRunAt: ScheduledTask.fields.nextRunAt,
apps/server/src/peer/RemoteDelegation.test.ts
+5
@@ -759,6 +759,7 @@ const delegateToBox = (laptopEnv: Effect.Success<ReturnType<typeof makeLaptop>>)
759
status: string;
760
childThreadId: null;
761
remoteChild: { environmentId: string; threadId: ThreadId; label: string };
762
+ link?: string;
763
};
764
}),
765
);
@@ -807,6 +808,10 @@ it.effect("a task delegated to the box wakes the laptop's parent when it ends th
808
});
809
// The box launched it in the project with the same repository.
810
expect(yield* Ref.get(thread.launched)).toBe(delegated.remoteChild.threadId);
811
+ // Its link opens the thread there, so the parent can mention it like any other.
812
+ expect(delegated.link).toBe(
813
+ `<t3-thread://v2/${box.environmentId}/${delegated.remoteChild.threadId}>`,
814
+ );
815
// ...naming the parent here, so the thread there links back to it.
816
expect(yield* Ref.get(thread.delegatedFrom)).toEqual({
817
environmentId: laptop.environmentId,
apps/server/src/provider/agentContextBudget.json
+2
-2
@@ -1,5 +1,5 @@
1
{
2
- "claudeSystemAppendBytes": 5258,
3
- "codexAdditionalContextBytes": 5810,
2
+ "claudeSystemAppendBytes": 5135,
3
+ "codexAdditionalContextBytes": 5687,
4
"mcpToolListJsonBytes": 45861
5
}
apps/web/src/components/ChatMarkdown.tsx
+7
-5
@@ -1060,13 +1060,15 @@ const CHAT_MARKDOWN_COMPONENTS = {
1060
const text = use(ChatMarkdownTextContext);
1061
const citation = href ? parseAssistantCitationHref(href) : null;
1062
if (citation) return <AssistantCitationChip citation={citation} />;
1063
- const linkedThreadId = href ? parseThreadLinkHref(href) : null;
1064
- if (linkedThreadId) {
1065
- const label = hastPlainTextDeep(node) || linkedThreadId;
1063
+ const threadLink = href ? parseThreadLinkHref(href) : null;
1064
+ if (threadLink) {
1065
+ const written = hastPlainTextDeep(node);
1066
+ // An autolink's text is its own URL, which is no label.
1067
+ const label = written && parseThreadLinkHref(written) === null ? written : null;
1068
return environmentId ? (
1067
- <MarkdownThreadLink environmentId={environmentId} threadId={linkedThreadId} label={label} />
1069
+ <MarkdownThreadLink environmentId={environmentId} link={threadLink} label={label} />
1070
) : (
1069
- <span>{label}</span>
1071
+ <span>{label ?? "Thread"}</span>
1072
);
1073
}
1074
const contextReference = href ? parseComposerContextHref(href) : null;
apps/web/src/components/chat/MarkdownThreadLink.tsx
+22
-20
@@ -1,39 +1,41 @@
1
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
2
-import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
2
+import type { EnvironmentId } from "@t3tools/contracts";
3
import {
4
formatThreadLink,
5
+ guessThreadLinkRef,
6
percentDecodedThreadLinkId,
6
- resolveThreadLinkRef,
7
+ type ThreadLink,
8
+ unknownThreadLinkLabel,
9
} from "@t3tools/shared/threadLinks";
10
11
import { useThreadRefs, useThreadShell } from "../../state/entities";
12
+import { UnresolvedChip } from "../contextChipParts";
13
import { ThreadContextChip } from "../ThreadContextChip";
14
15
+/** `label` is the link's written text; an autolink has none. */
16
export function MarkdownThreadLink(props: {
17
readonly environmentId: EnvironmentId;
14
- readonly threadId: ThreadId;
15
- readonly label: string;
18
+ readonly link: ThreadLink;
19
+ readonly label: string | null;
20
}) {
17
- const decodedId = percentDecodedThreadLinkId(props.threadId);
18
- const written = useThreadShell(scopeThreadRef(props.environmentId, props.threadId));
21
+ const environmentId = props.link.environmentId ?? props.environmentId;
22
+ const decodedId = percentDecodedThreadLinkId(props.link.threadId);
23
+ const written = useThreadShell(scopeThreadRef(environmentId, props.link.threadId));
24
const decoded = useThreadShell(
20
- written === null && decodedId !== null ? scopeThreadRef(props.environmentId, decodedId) : null,
25
+ written === null && decodedId !== null ? scopeThreadRef(environmentId, decodedId) : null,
26
);
27
const local = written ?? decoded;
23
- const refs = useThreadRefs(local === null);
24
- const remote = useThreadShell(
25
- local === null
26
- ? resolveThreadLinkRef(scopeThreadRef(props.environmentId, props.threadId), refs)
27
- : null,
28
- );
28
+ const guess = local === null && props.link.environmentId === null;
29
+ const refs = useThreadRefs(guess);
30
+ const remote = useThreadShell(guess ? guessThreadLinkRef(props.link, refs) : null);
31
const thread = local ?? remote;
30
- const environmentId = thread?.environmentId ?? props.environmentId;
31
- const threadId = thread?.id ?? props.threadId;
32
- const title = thread?.title.trim() || props.label;
32
+ if (thread === null) {
33
+ const unknown = unknownThreadLinkLabel(props.link, props.environmentId);
34
+ return <UnresolvedChip label={props.label ?? unknown} tooltip={unknown} />;
35
+ }
36
+ const ref = { environmentId: thread.environmentId, threadId: thread.id };
37
+ const title = thread.title.trim() || props.label || "Untitled thread";
38
return (
34
- <ThreadContextChip
35
- record={{ environmentId, threadId, title: props.label }}
36
- copyMarkdown={formatThreadLink(threadId, title)}
37
- />
39
+ <ThreadContextChip record={{ ...ref, title }} copyMarkdown={formatThreadLink(ref, title)} />
40
);
41
}
apps/web/src/components/chat/timelineMinimapItems.test.ts
new
+16
@@ -0,0 +1,16 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+
3
+import { resolveTimelineMinimapPreview } from "./timelineMinimapItems";
4
+
5
+describe("resolveTimelineMinimapPreview", () => {
6
+ it("previews a thread autolink as prose, not its URL", () => {
7
+ const preview = resolveTimelineMinimapPreview({
8
+ id: "turn-1",
9
+ rowIndex: 0,
10
+ userText: null,
11
+ assistantText:
12
+ "Started <t3-thread://v2/env-1/thread-1> and [Fix CI](t3-thread://v2/env-1/t2).",
13
+ });
14
+ expect(preview?.assistantText).toBe("Started a thread and Fix CI.");
15
+ });
16
+});
apps/web/src/components/chat/timelineMinimapItems.ts
+4
-1
@@ -1,3 +1,4 @@
1
+import { parseThreadLinkHref } from "@t3tools/shared/threadLinks";
2
import type { Nodes } from "mdast";
3
import remarkGfm from "remark-gfm";
4
import remarkParse from "remark-parse";
@@ -82,7 +83,9 @@ function markdownNodeText(node: Nodes): string {
83
if (node.type === "image" || node.type === "imageReference") return node.alt ?? "";
84
if (!("children" in node)) return "";
85
const separator = INLINE_PARENT_TYPES.has(node.type) ? "" : " ";
85
- return node.children.map(markdownNodeText).join(separator);
86
+ const text = node.children.map(markdownNodeText).join(separator);
87
+ // A thread autolink's only text is its URL.
88
+ return node.type === "link" && parseThreadLinkHref(text) !== null ? "a thread" : text;
89
}
90
91
function compactMinimapPreview(text: string | null | undefined) {
apps/web/src/pendingUserInput.test.ts
+1
-1
@@ -27,7 +27,7 @@ describe("projectPendingUserInputAnswer", () => {
27
it("sends thread chips as readable links with the actual thread ID", () => {
28
const answer = `Compare ${formatInlineContextReference(threadContextReference(record))}`;
29
expect(projectPendingUserInputAnswer(answer, [record])).toBe(
30
- "Compare [Reference work](t3-thread://v1/reference-thread)",
30
+ "Compare [Reference work](t3-thread://v2/env-answer/reference-thread)",
31
);
32
});
33
apps/web/src/pendingUserInput.ts
+1
-1
@@ -12,7 +12,7 @@ export function projectPendingUserInputAnswer(
12
const recordsById = new Map(threadContexts.map((record) => [record.contextId, record]));
13
return replaceComposerContextReferences(answer, (reference) => {
14
const record = reference.kind === "thread" ? recordsById.get(reference.contextId) : undefined;
15
- return record ? formatThreadLink(record.threadId, reference.label) : reference.source;
15
+ return record ? formatThreadLink(record, reference.label) : reference.source;
16
});
17
}
18
docs/orchestration-v2/orchestrator-mcp-server.md
+9
-6
@@ -390,12 +390,15 @@ and `creationSource: "mcp"`; provider output uses `creationSource: "provider"`.
390
Actor and ingress are separate so agent-authored user-role messages remain
391
distinguishable from human-authored messages.
392
393
-Agents mention another thread as `[title](t3-thread://v1/<threadId>)`. Thread
394
-results carry this ready-made as `link`, so agents never format the id. The
395
-link carries only the id. Clients first resolve it in the message's environment,
396
-then use a unique match in another enabled environment. Ambiguous matches stay
397
-unresolved. Web and desktop show the resolved thread’s current title. Mobile
398
-relabels local matches; cross-environment links can retain the written label.
393
+Agents mention another thread by the `link` its result carries,
394
+`<t3-thread://v2/<environmentId>/<threadId>>`, so they never format an id or
395
+write a title, which goes stale when the user renames the thread. The
396
+environment that owns the thread builds the link, so forwarded results and tasks
397
+delegated to a linked environment name that environment. Clients open only that
398
+environment's thread and show its current title; a link to a thread they do not
399
+know renders as a label that opens nothing. Older `t3-thread://v1/<threadId>`
400
+links name no environment: clients resolve them in the message's environment,
401
+then by a unique match in another enabled environment.
402
403
List and read results report `snoozed` and `snoozedUntil`, and
404
`t3_thread_list` filters on `snoozed`. The server's `isSnoozed` follows the
evals/mcp-tool-use/cases/orchestration.ndjson
+5
-4
@@ -13,9 +13,10 @@
13
{"id": "debate-drops-second-model", "area": "orchestration", "kind": "bad", "pattern": "missed requested delegate; polling", "experience": "Asked to argue with GPT-6.1 Sol and Muse Wonder Full, the agent only delegated to Sol (twice), never mentioned Muse, and blocked the turn with 7 task_status and 3 t3_thread_wait calls.", "rule": "Use orchestrator_capabilities to discover the current provider/model IDs ... (intended: one delegate per requested model; end the turn after async delegates)", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default", "task_status": "default", "t3_thread_wait": {"threadId": "44444444-4444-4444-8444-000000000001", "status": "running", "timedOut": true}, "WebSearch": "Hostco status page: Major outage. Deploys and new builds are unavailable in all regions. Started 17 hours ago. Running apps and databases are not affected. Next update in 60 minutes."}, "world": {"files": {"infra/README.md": "# Hosting\n\nProduction runs on Hostco: the web service, a worker, and managed Postgres, all in us-east. The app needs the database in the same region for latency.\n", "infra/hostco.yaml": "services:\n - name: web\n plan: standard\n - name: worker\n plan: starter\ndatabases:\n - name: main\n plan: pro-4gb\n"}}}, "prompt": "Our hosting provider has been down for SEVENTEEN HOURS and I can't deploy. The DB has to stay colocated with compute, probably on the same platform. Rethink our options and research more. Argue with GPT-6.1 Sol and Muse Wonder Full about it. Don't bother me until you actually understand what is going on and have a real plan.", "expect": {"calls": [{"tool": "delegate_task", "args": {"target.model": "gpt-6.1-sol"}}, {"tool": "delegate_task", "args": {"target.model": "muse-wonder-full"}}], "order": ["orchestrator_capabilities", "delegate_task"], "maxCalls": {"t3_thread_wait": 0, "task_status": 1}}, "notes": "'Don't bother me until...' is the pressure toward blocking waits. Real model id replaced with the fixture 'muse-wonder-full'.", "maxSteps": 12}
14
{"id": "file-watcher-after-async-delegates", "area": "orchestration", "kind": "bad", "pattern": "polling after async delegate_task (shell watcher)", "experience": "After async delegates, the agent ran background 'until [ -f file ]; do sleep 15; done' watchers. They caused empty wake turns ('That alert was the old plan-file watcher closing, so nothing changed').", "rule": "Keep polling/wait loops bounded, do not duplicate active work (intended: end the turn; completion wakes this thread)", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default", "task_status": "default"}, "world": {"files": {"infra/README.md": "# Services\n\nweb (Node), worker (queue consumer), Postgres, Redis. All on Hostco in one region.\n", "infra/web.yaml": "name: web\nenv:\n DATABASE_URL: from-db\n REDIS_URL: from-redis\n", "infra/worker.yaml": "name: worker\nenv:\n DATABASE_URL: from-db\n REDIS_URL: from-redis\n"}}}, "prompt": "We're starting a new repo that helps people move off our current host after today's outages. Do these, all with subagents:\n1. Inventory the services in infra/ and how they connect. Write .research/01-inventory.md.\n2. Survey the other hosting options. Write .research/02-alternatives.md.\n3. When 1 and 2 are done, propose a migration plan for the best two options in .research/03-plan.md.", "expect": {"notCalls": ["Monitor", "ScheduleWakeup"], "callsMustNot": [{"tool": "Agent", "args": {"run_in_background": true}}], "shellMustNot": ["\\bsleep\\b", "until \\[", "while \\[ ! -f", "inotifywait|fswatch"], "maxCalls": {"task_status": 1, "t3_thread_wait": 0}}, "notes": "Step 3 depends on 1 and 2, which is what pushed the agent to watch for files. Expected: start 1 and 2 as delegates, end the turn, start 3 on the wake."}
15
{"id": "worktree-add-for-parallel-pr-delegates", "area": "orchestration", "kind": "bad", "pattern": "worktree via git worktree add instead of isolation", "experience": "Asked for delegates that each make a separate PR, the agent ran git worktree add 12 times in the shell and told each delegate to work in its path.", "rule": "For a child task that needs a separate checkout, use delegate_task with isolation:\"worktree\" ... Asking an agent to run git worktree add or cd in its prompt does not update T3's thread binding.", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "What's left before we can ship 1.0? Give me a short list of blockers."}, {"role": "assistant", "text": "Three release blockers:\n1. A deploy can drop a table without confirmation.\n2. Auth tokens are sent in WebSocket URLs.\n3. Admin sessions never expire.", "toolCalls": [{"tool": "Bash", "input": {"command": "rg -n \"dropTable\" src/deploy"}, "result": "src/deploy/migrate.ts:3: await db.dropTable(name); // no confirmation"}, {"tool": "Bash", "input": {"command": "rg -n \"token=\" src/ws"}, "result": "src/ws/client.ts:2: return new WebSocket(`${base}?token=${token}`);"}, {"tool": "Bash", "input": {"command": "rg -n \"expires\" src/admin"}, "result": "Exit code 1\n"}, {"tool": "Read", "input": {"file_path": "/home/user/.t3/worktrees/t3code/t3-f8cdd940/src/admin/session.ts"}, "result": " 1\texport function createAdminSession(userId: string) {\n 2\t return { userId, createdAt: Date.now() }; // no expiresAt\n 3\t}"}]}], "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": {"taskId": "task-1", "childThreadId": "44444444-4444-4444-8444-000000000001", "childRunId": "run-child-1", "status": "running", "workState": "working", "providerInstanceId": "claudeAgent", "model": "claude-sonnet-5-5"}}, "world": {"files": {"src/deploy/migrate.ts": "export async function applyMigration(m: Migration) {\n for (const name of m.dropTables) {\n await db.dropTable(name); // no confirmation\n }\n}\n", "src/ws/client.ts": "export function connect(base: string, token: string) {\n return new WebSocket(`${base}?token=${token}`);\n}\n", "src/admin/session.ts": "export function createAdminSession(userId: string) {\n return { userId, createdAt: Date.now() }; // no expiresAt\n}\n"}}}, "prompt": "Sounds reasonable. Start the work. Spin up delegates to work on each of these as separate PRs.", "expect": {"calls": [{"tool": "delegate_task", "args": {"isolation": "worktree"}}], "notCalls": ["t3_thread_launch", "create_threads"], "shellMustNot": ["git worktree add"], "callsMustNot": [{"tool": "delegate_task", "args": {"task": "~git worktree add"}}]}, "notes": "Also guards pattern 1: the 'independent implementation in its own worktree' launch section can pull toward t3_thread_launch, which the user did not ask for."}
16
-{"id": "thread-id-not-read", "area": "orchestration", "kind": "bad", "pattern": "did not read a given thread id", "experience": "The user pasted a thread id and asked why 'this t3 code thread' kept mentioning pi. The agent answered from its own context. The user: 'Use the t3 code mcp to get that thread, that's the id lol'.", "rule": "Intended: read a given thread id with t3_thread_read, with a bounded size.", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "Is the Muse CLI just a fork or wrapper of the Pi agent?"}, {"role": "assistant", "text": "No. The installed Muse CLI is a native Rust binary built from its own source tree. I searched the provider code for 'pi' to check, and found only T3 Code's separate Pi provider docs.", "toolCalls": [{"tool": "Bash", "input": {"command": "rg -il '\\bpi\\b' src/providers"}, "result": "src/providers/pi/README.md"}, {"tool": "Bash", "input": {"command": "file \"$(which muse)\""}, "result": "/usr/local/bin/muse: ELF 64-bit LSB pie executable, x86-64, dynamically linked, Rust toolchain 1.91, stripped"}]}], "mocks": {"t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Muse CLI integration and ACP support", "link": "[Muse CLI integration and ACP support](t3-thread://v1/11111111-1111-4111-8111-111111111111)", "status": "idle"}, "items": [{"position": 494, "createdBy": "assistant", "text": "Pi already replays recorded transcripts in tests, so the Muse adapter copies that pattern."}], "nextPosition": 495, "hasMore": false}}, "world": {"files": {"src/providers/pi/README.md": "# Pi provider\n\nRuns the Pi agent through its RPC mode.\n", "src/providers/muse/adapter.ts": "export const museAdapter = makeAdapter({ binary: 'muse' });\n"}}}, "prompt": "11111111-1111-4111-8111-111111111111 why does this t3 code thread keep mentioning pi?", "expect": {"calls": [{"tool": "t3_thread_read", "args": {"threadId": "11111111-1111-4111-8111-111111111111"}}]}, "notes": "The prior turn mentions pi, which is what let the agent think 'this thread' meant itself. The same thread then read with limit 100 and got an 85k-char result (see gaps)."}
17
-{"id": "thread-mention-without-link-after-read", "area": "orchestration", "kind": "bad", "pattern": "thread mentioned without t3-thread link", "experience": "Asked to explain what went wrong in a given thread, the agent named it by id or title with no t3-thread:// link.", "rule": "To mention another thread to the user, link it as [title](t3-thread://v1/<threadId>) with its exact threadId.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix ultrafast pricing", "link": "[Fix ultrafast pricing](t3-thread://v1/11111111-1111-4111-8111-111111111111)", "status": "idle"}, "items": [{"position": 210, "createdBy": "assistant", "toolName": "t3_thread_send", "text": "t3_thread_send threadId=44444444-4444-4444-8444-000000000001 message='Round 2. Read only, as before...'"}, {"position": 214, "createdBy": "user", "text": "Use delegate_task please, this should not be a separate thread."}], "nextPosition": 215, "hasMore": false}}}, "prompt": "11111111-1111-4111-8111-111111111111 This thread used the wrong tool. Figure out why.", "expect": {"calls": [{"tool": "t3_thread_read", "args": {"threadId": "11111111-1111-4111-8111-111111111111"}}], "textMust": ["t3-thread://v1/[^)\\s]*11111111-1111-4111-8111-111111111111"]}, "notes": "Real agent was Codex before the 10-21 untruncation fix, when the link rule often did not reach Codex. May pass on Claude today; keep as a regression check for the rewrite.", "maxSteps": 10}
18
-{"id": "found-thread-mentioned-without-link", "area": "orchestration", "kind": "bad", "pattern": "thread mentioned without t3-thread link", "experience": "The agent found yesterday's thread by search and told the user where they left off, but did not link the thread.", "rule": "To mention another thread to the user, link it as [title](t3-thread://v1/<threadId>) with its exact threadId.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"t3_thread_search": {"matches": [{"threadId": "11111111-1111-4111-8111-111111111111", "projectId": "22222222-2222-4222-8222-222222222222", "title": "Fix macOS camera permission prompt", "snippet": "...the app never asks for camera permission on mac...", "messageCreatedAt": "2026-10-19T21:04:00Z"}]}, "t3_thread_list": {"threads": [{"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix macOS camera permission prompt", "status": "idle"}]}, "t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix macOS camera permission prompt", "link": "[Fix macOS camera permission prompt](t3-thread://v1/11111111-1111-4111-8111-111111111111)", "status": "idle"}, "items": [{"position": 88, "createdBy": "assistant", "text": "The fix is committed locally on branch fix/camera-entitlement in another clone. No PR is open yet."}], "nextPosition": 89, "hasMore": false}}, "shellMocks": [{"match": "gh pr list", "output": ""}]}, "prompt": "Did I ever make a PR to fix the issue where the app couldn't request camera permission on mac? I had a thread about it yesterday and forgot where we left off.", "expect": {"textMust": ["t3-thread://v1/[^)\\s]*11111111-1111-4111-8111-111111111111"]}, "notes": "Also seen in another thread ('Found the prior audits (Jul 21, Sep 1, Oct 3 threads ...)' with no links). Original prompt also said 'get it fixed full stop'; dropped to keep the case small."}
16
+{"id": "thread-id-not-read", "area": "orchestration", "kind": "bad", "pattern": "did not read a given thread id", "experience": "The user pasted a thread id and asked why 'this t3 code thread' kept mentioning pi. The agent answered from its own context. The user: 'Use the t3 code mcp to get that thread, that's the id lol'.", "rule": "Intended: read a given thread id with t3_thread_read, with a bounded size.", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "Is the Muse CLI just a fork or wrapper of the Pi agent?"}, {"role": "assistant", "text": "No. The installed Muse CLI is a native Rust binary built from its own source tree. I searched the provider code for 'pi' to check, and found only T3 Code's separate Pi provider docs.", "toolCalls": [{"tool": "Bash", "input": {"command": "rg -il '\\bpi\\b' src/providers"}, "result": "src/providers/pi/README.md"}, {"tool": "Bash", "input": {"command": "file \"$(which muse)\""}, "result": "/usr/local/bin/muse: ELF 64-bit LSB pie executable, x86-64, dynamically linked, Rust toolchain 1.91, stripped"}]}], "mocks": {"t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Muse CLI integration and ACP support", "link": "<t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>", "status": "idle"}, "items": [{"position": 494, "createdBy": "assistant", "text": "Pi already replays recorded transcripts in tests, so the Muse adapter copies that pattern."}], "nextPosition": 495, "hasMore": false}}, "world": {"files": {"src/providers/pi/README.md": "# Pi provider\n\nRuns the Pi agent through its RPC mode.\n", "src/providers/muse/adapter.ts": "export const museAdapter = makeAdapter({ binary: 'muse' });\n"}}}, "prompt": "11111111-1111-4111-8111-111111111111 why does this t3 code thread keep mentioning pi?", "expect": {"calls": [{"tool": "t3_thread_read", "args": {"threadId": "11111111-1111-4111-8111-111111111111"}}]}, "notes": "The prior turn mentions pi, which is what let the agent think 'this thread' meant itself. The same thread then read with limit 100 and got an 85k-char result (see gaps)."}
17
+{"id": "thread-mention-without-link-after-read", "area": "orchestration", "kind": "bad", "pattern": "thread mentioned without t3-thread link", "experience": "Asked to explain what went wrong in a given thread, the agent named it by id or title with no t3-thread:// link.", "rule": "To mention another thread to the user, write its `link` verbatim: <t3-thread://v2/<environmentId>/<threadId>>, with no title.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix ultrafast pricing", "link": "<t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>", "status": "idle"}, "items": [{"position": 210, "createdBy": "assistant", "toolName": "t3_thread_send", "text": "t3_thread_send threadId=44444444-4444-4444-8444-000000000001 message='Round 2. Read only, as before...'"}, {"position": 214, "createdBy": "user", "text": "Use delegate_task please, this should not be a separate thread."}], "nextPosition": 215, "hasMore": false}}}, "prompt": "11111111-1111-4111-8111-111111111111 This thread used the wrong tool. Figure out why.", "expect": {"calls": [{"tool": "t3_thread_read", "args": {"threadId": "11111111-1111-4111-8111-111111111111"}}], "textMust": ["t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111"], "textMustNot": ["t3-thread://v1/"]}, "notes": "Real agent was Codex before the 10-21 untruncation fix, when the link rule often did not reach Codex. May pass on Claude today; keep as a regression check for the rewrite.", "maxSteps": 10}
18
+{"id": "found-thread-mentioned-without-link", "area": "orchestration", "kind": "bad", "pattern": "thread mentioned without t3-thread link", "experience": "The agent found yesterday's thread by search and told the user where they left off, but did not link the thread.", "rule": "To mention another thread to the user, write its `link` verbatim: <t3-thread://v2/<environmentId>/<threadId>>, with no title.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"t3_thread_search": {"matches": [{"threadId": "11111111-1111-4111-8111-111111111111", "projectId": "22222222-2222-4222-8222-222222222222", "title": "Fix macOS camera permission prompt", "snippet": "...the app never asks for camera permission on mac...", "messageCreatedAt": "2026-10-19T21:04:00Z"}]}, "t3_thread_list": {"threads": [{"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix macOS camera permission prompt", "status": "idle"}]}, "t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix macOS camera permission prompt", "link": "<t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>", "status": "idle"}, "items": [{"position": 88, "createdBy": "assistant", "text": "The fix is committed locally on branch fix/camera-entitlement in another clone. No PR is open yet."}], "nextPosition": 89, "hasMore": false}}, "shellMocks": [{"match": "gh pr list", "output": ""}]}, "prompt": "Did I ever make a PR to fix the issue where the app couldn't request camera permission on mac? I had a thread about it yesterday and forgot where we left off.", "expect": {"textMust": ["t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111"], "textMustNot": ["t3-thread://v1/"]}, "notes": "Also seen in another thread ('Found the prior audits (Jul 21, Sep 1, Oct 3 threads ...)' with no links). Original prompt also said 'get it fixed full stop'; dropped to keep the case small."}
19
+{"id": "thread-link-rewritten-with-title", "area": "orchestration", "kind": "bad", "pattern": "thread link rewritten with a title", "experience": "Thread links carried the title the agent wrote, which went stale once the user renamed the thread. The app already shows each linked thread's current title, so maintainers asked that agents write only the stable link.", "rule": "To mention another thread to the user, write its `link` verbatim: <t3-thread://v2/<environmentId>/<threadId>>, with no title.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"t3_thread_list": {"threads": [{"threadId": "11111111-1111-4111-8111-111111111111", "title": "Fix flaky checkout test", "status": "running"}, {"threadId": "44444444-4444-4444-8444-000000000002", "title": "Upgrade Vite", "status": "idle"}]}}}, "prompt": "Which of my threads in this project are still running?", "expect": {"calls": [{"tool": "t3_thread_list"}], "textMust": ["<t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>"], "textMustNot": ["\\]\\(t3-thread://", "t3-thread://v1/"]}, "notes": "Source: maintainer request with the v2 thread link change. The old instructions carried a titled [title](t3-thread://v1/<exact id>) template for threads without a link."}
20
{"id": "cross-provider-delegates-with-options", "area": "orchestration", "kind": "guard", "pattern": "capabilities then cross-provider delegate_task with options", "experience": "Asked for Sol 'high' and Muse Wonder Full 'xhigh' delegates, the agent read capabilities and put effort in target.options.", "rule": "Read the selected model's descriptors from orchestrator_capabilities and put settings in target.options, not only in the prompt.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default"}}, "prompt": "I want this codebase reviewed by two different models. Spin up a delegate for GPT-6.1 Sol high in Codex and one for Muse Wonder Full at xhigh. Tell them both to explore the codebase and find interesting things, plus some easy wins.", "expect": {"order": ["orchestrator_capabilities", "delegate_task"], "calls": [{"tool": "delegate_task", "args": {"target.providerInstanceId": "codex", "target.model": "gpt-6.1-sol", "target.options.reasoningEffort": "high"}}, {"tool": "delegate_task", "args": {"target.providerInstanceId": "muse", "target.model": "muse-wonder-full", "target.options.reasoningEffort": "xhigh"}}], "notCalls": ["t3_thread_launch", "create_threads", "Agent"]}, "notes": "target.options may be an object or an [{id,value}] array. The runner must normalize arrays to an object before matching 'target.options.<id>'."}
21
{"id": "same-provider-delegate-with-effort", "area": "orchestration", "kind": "guard", "pattern": "model options force delegate_task over native", "experience": "Asked for an Opus 5.5 (xhigh) delegate from a Claude parent, the agent used delegate_task with target.options effort xhigh.", "rule": "When model options are requested ... use delegate_task even for native-supported models. Native subagents cannot reliably apply T3 model options.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default"}}, "prompt": "Spin up an Opus 5.5 delegate in Claude Code on xhigh to research why the update flow spams 'connected successfully' toasts. Have it write up the causes in priority order.", "expect": {"calls": [{"tool": "delegate_task", "args": {"target.providerInstanceId": "claudeAgent", "target.model": "claude-opus-5-5", "target.options.effort": "xhigh"}}], "notCalls": ["Agent", "Workflow"]}, "notes": "A shorter text that drops the options rule could send this to the native Agent tool with model 'opus' and lose xhigh."}
22
{"id": "async-delegate-then-end-turn", "area": "orchestration", "kind": "guard", "pattern": "async delegate then end turn", "experience": "After starting an async Sol review the agent said its completion would wake the thread and ended the turn.", "rule": "Prefer mode='async' for long work ... the task's completion still wakes this thread. (intended: end the turn; no sleep or task_status loops)", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default", "task_status": "default"}, "world": {"branch": "fix/session-stop", "commits": [{"sha": "3e8d1f0", "subject": "fix(server): stop clears an orphaned task row"}], "diff": "diff --git a/src/session.ts b/src/session.ts\n--- a/src/session.ts\n+++ b/src/session.ts\n@@ -10,1 +10,1 @@\n- if (task.status !== \"running\") return;\n+ if (task.status === \"cancelled\") return emitTaskRow(task);\n", "prs": [{"number": 123, "title": "fix(server): stop clears an orphaned task row", "headRefName": "fix/session-stop"}]}}, "prompt": "Have a GPT-6.1 Sol delegate review the diff on this branch (https://github.com/acme/app/pull/123) before I merge it.", "expect": {"calls": [{"tool": "delegate_task", "args": {"target.model": "gpt-6.1-sol"}}], "maxCalls": {"task_status": 0, "t3_thread_wait": 0}, "shellMustNot": ["\\bsleep\\b"]}, "notes": ""}
@@ -24,7 +25,7 @@
25
{"id": "opus-review-too-via-delegate", "area": "orchestration", "kind": "guard", "pattern": "same-provider review via delegate_task", "experience": "'Have Opus review the things too' from a Claude parent with no extra settings runs a native Opus subagent the parent waits for.", "rule": "Use your native tool when the child uses your provider, a model it offers, and no settings beyond yours, and you need it only in this turn.", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "Get a Sol review on https://github.com/acme/app/pull/123 before we file anything else."}, {"role": "assistant", "text": "Sol approved PR 123 after one fix to its description.", "toolCalls": [{"tool": "delegate_task", "input": {"title": "Sol review PR 123", "mode": "async", "clientRequestId": "sol-123-r1", "target": {"providerInstanceId": "codex", "model": "gpt-6.1-sol", "options": {"reasoningEffort": "high"}}, "task": "Review https://github.com/acme/app/pull/123. Read only."}, "result": {"taskId": "task-1", "childThreadId": "44444444-4444-4444-8444-000000000001", "childRunId": "run-child-1", "status": "running", "workState": "working", "providerInstanceId": "codex", "model": "gpt-6.1-sol"}}, {"tool": "task_status", "input": {"taskId": "task-1"}, "result": {"taskId": "task-1", "childThreadId": "44444444-4444-4444-8444-000000000001", "status": "completed", "workState": "result_available", "summary": "APPROVE after S1 (description wording)."}}]}], "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default"}, "world": {"prs": [{"number": 123, "title": "fix(web): keep scroll position on thread switch", "headRefName": "fix/scroll"}]}, "harness": "claude"}, "prompt": "Have Opus review the things too, not just Sol", "expect": {"calls": [{"tool": "Agent", "args": {"model": "~opus"}}], "notCalls": ["delegate_task", "t3_thread_send"], "callsMustNot": [{"tool": "Agent", "args": {"run_in_background": true}}]}, "notes": "T3's 'prefer native for same-provider' line pulls toward the native Agent tool here; this stayed correct in the real thread."}
26
{"id": "delegates-then-new-thread-with-model", "area": "orchestration", "kind": "guard", "pattern": "new thread asked: t3_thread_launch with model", "experience": "'Spin up 2 Opus delegates ... then start a new thread using Grok 4.7 to implement' gave 2 delegate_task calls and 1 t3_thread_launch on Grok.", "rule": "t3_thread_launch and create_threads ... Use them only when the user explicitly asks for separate/new/top-level threads.", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "Spin up 2 Opus 5.5 delegates to explore performance wins in this app."}, {"role": "assistant", "text": "Both Opus delegates are done.\n- Client: the thread list re-renders every row on each streamed token.\n- Server: each event write runs a full projection rebuild.", "toolCalls": [{"tool": "delegate_task", "input": {"title": "Opus: client performance", "mode": "wait", "clientRequestId": "perf-client", "target": {"providerInstanceId": "claudeAgent", "model": "claude-opus-5-5"}, "task": "Find concrete client performance wins. Read only."}, "result": {"taskId": "task-1", "childThreadId": "44444444-4444-4444-8444-000000000001", "childRunId": "run-child-1", "status": "completed", "workState": "result_available", "providerInstanceId": "claudeAgent", "model": "claude-opus-5-5", "summary": "Client: the thread list re-renders every row on each streamed token. Memoize rows by thread id and select only the active thread's stream."}}, {"tool": "delegate_task", "input": {"title": "Opus: server performance", "mode": "wait", "clientRequestId": "perf-server", "target": {"providerInstanceId": "claudeAgent", "model": "claude-opus-5-5"}, "task": "Find concrete server performance wins. Read only."}, "result": {"taskId": "task-2", "childThreadId": "44444444-4444-4444-8444-000000000002", "childRunId": "run-child-2", "status": "completed", "workState": "result_available", "providerInstanceId": "claudeAgent", "model": "claude-opus-5-5", "summary": "Server: each event write runs a full projection rebuild. Apply events to the projection incrementally."}}]}], "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "t3_thread_launch": {"threadId": "11111111-1111-4111-8111-111111111111", "projectId": "22222222-2222-4222-8222-222222222222", "modelSelection": {"instanceId": "grok", "model": "grok-4.7"}, "status": "starting"}}}, "prompt": "Summarize their thoughts, then start a new thread using Grok 4.7 to implement your findings.", "expect": {"calls": [{"tool": "t3_thread_launch", "args": {"modelSelection.model": "~grok"}}], "notCalls": ["delegate_task", "create_threads"]}, "notes": "Pattern 2 (new thread asked but delegate used) had only 1-2 real cases in 40 asks, so this is a guard. Check the arg path against the current t3_thread_launch schema."}
27
{"id": "subagent-ask-no-new-threads", "area": "orchestration", "kind": "guard", "pattern": "subagent asked: no t3_thread_launch/create_threads", "experience": "'Have Haiku 5.5 subagents do the exploration' must give child tasks, not top-level threads. 0 of 98 subagent asks went wrong, and the user still warns about it.", "rule": "Never use them merely because the user said \"subagent\" or requested parallel delegated work.", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default"}, "world": {"files": {"package.json": "{\n \"name\": \"app\",\n \"private\": true,\n \"packageManager\": \"pnpm@10.4.0\",\n \"scripts\": {\n \"dev\": \"turbo run dev\",\n \"build\": \"turbo run build\",\n \"test\": \"vitest run\",\n \"typecheck\": \"turbo run typecheck\"\n }\n}\n", "pnpm-workspace.yaml": "packages:\n - apps/*\n - packages/*\n", "turbo.json": "{\n \"tasks\": {\n \"build\": { \"outputs\": [\"dist/**\"] },\n \"typecheck\": {},\n \"dev\": { \"cache\": false }\n }\n}\n", "apps/web/package.json": "{ \"name\": \"@app/web\", \"scripts\": { \"dev\": \"vite\", \"build\": \"vite build\" } }\n", "apps/server/package.json": "{ \"name\": \"@app/server\", \"scripts\": { \"dev\": \"tsx watch src/index.ts\", \"build\": \"tsc\" } }\n", ".github/workflows/ci.yml": "name: ci\non: [push, pull_request]\njobs:\n test:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - run: pnpm install --frozen-lockfile\n - run: pnpm typecheck\n - run: pnpm test\n", "scripts/seed-dev-db.ts": "import { db } from '../apps/server/src/db';\n\n// Seeds the dev database with 20 fake users.\nfor (let i = 0; i < 20; i++) await db.insert('users', { name: `user${i}` });\n", "apps/web/src/main.tsx": "import { createRoot } from 'react-dom/client';\nimport { App } from './App';\n\ncreateRoot(document.getElementById('root')!).render(<App />);\n", "apps/web/src/App.tsx": "export function App() {\n return <ThreadList />;\n}\n", "apps/server/src/index.ts": "import { createServer } from './server';\n\ncreateServer().listen(Number(process.env.PORT ?? 3773));\n", "apps/server/src/db.ts": "import { Database } from 'better-sqlite3';\n\nexport const db = new Database(process.env.DB_PATH ?? 'dev.sqlite');\n"}}}, "prompt": "I want your honest thoughts on this project. Do a deep dive and really read through it so you know it well. Have Haiku 5.5 subagents do the exploration.", "expect": {"notCalls": ["t3_thread_launch", "create_threads"]}, "notes": "Narrow on purpose: native vs delegate is graded in the bad cases. The user's preemptive guard: 'Please don't make new threads with the T3 Code MCP, only create delegates, workflows, subagents etc.'."}
27
-{"id": "thread-send-to-named-top-level-thread", "area": "orchestration", "kind": "guard", "pattern": "t3_thread_send to a top-level thread the user names", "experience": "Given another top-level thread id to talk to, the agent used t3_thread_send on it and linked it in the reply.", "rule": "To mention another thread to the user, link it as [title](t3-thread://v1/<threadId>).", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "The other agent disagreed:\n\nTheirs is the better plan to execute. Mine is the wider survey. Start from theirs and graft three items from mine.\n\nTheir 5 points: 1) cache tsc output per package, 2) split the web typecheck into two projects, 3) drop the duplicate lint step in CI, 4) run typecheck only for changed packages in CI (memo), 5) measure before and after on main."}, {"role": "assistant", "text": "We now agree on almost everything. I accept points 1, 2, 3, and 5. I disagree with one detail of the memo in point 4: CI must also typecheck the packages that depend on a changed package, not only the changed ones. From my plan I would graft: project references, a warm tsc cache restored in CI, and a per-package timing report."}], "mocks": {"t3_thread_send": {"threadId": "11111111-1111-4111-8111-111111111111", "messageId": "msg-1", "runId": "run-1", "queued": true}, "t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Faster type checking", "link": "[Faster type checking](t3-thread://v1/11111111-1111-4111-8111-111111111111)", "status": "idle"}, "items": [{"position": 41, "createdBy": "assistant", "text": "Plan: 1) cache tsc output per package, 2) split the web typecheck, 3) drop the duplicate lint step, 4) memo: typecheck only changed packages in CI, 5) measure on main."}, {"position": 42, "createdBy": "user", "text": "Another agent has a wider survey. I'll bring its answer back here."}], "nextPosition": 43, "hasMore": false}}}, "prompt": "That thread is on this machine, you can talk to it directly with t3 code: 11111111-1111-4111-8111-111111111111", "expect": {"calls": [{"tool": "t3_thread_send", "args": {"threadId": "11111111-1111-4111-8111-111111111111"}}], "notCalls": ["delegate_task", "t3_thread_launch"], "textMust": ["t3-thread://v1/[^)\\s]*11111111-1111-4111-8111-111111111111"]}, "notes": "Keeps a rewrite from over-banning t3_thread_send. The ban is only for delegated childThreadIds."}
28
+{"id": "thread-send-to-named-top-level-thread", "area": "orchestration", "kind": "guard", "pattern": "t3_thread_send to a top-level thread the user names", "experience": "Given another top-level thread id to talk to, the agent used t3_thread_send on it and linked it in the reply.", "rule": "To mention another thread to the user, write its `link` verbatim: <t3-thread://v2/<environmentId>/<threadId>>, with no title.", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "The other agent disagreed:\n\nTheirs is the better plan to execute. Mine is the wider survey. Start from theirs and graft three items from mine.\n\nTheir 5 points: 1) cache tsc output per package, 2) split the web typecheck into two projects, 3) drop the duplicate lint step in CI, 4) run typecheck only for changed packages in CI (memo), 5) measure before and after on main."}, {"role": "assistant", "text": "We now agree on almost everything. I accept points 1, 2, 3, and 5. I disagree with one detail of the memo in point 4: CI must also typecheck the packages that depend on a changed package, not only the changed ones. From my plan I would graft: project references, a warm tsc cache restored in CI, and a per-package timing report."}], "mocks": {"t3_thread_send": {"threadId": "11111111-1111-4111-8111-111111111111", "messageId": "msg-1", "runId": "run-1", "queued": true}, "t3_thread_read": {"thread": {"threadId": "11111111-1111-4111-8111-111111111111", "title": "Faster type checking", "link": "<t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>", "status": "idle"}, "items": [{"position": 41, "createdBy": "assistant", "text": "Plan: 1) cache tsc output per package, 2) split the web typecheck, 3) drop the duplicate lint step, 4) memo: typecheck only changed packages in CI, 5) measure on main."}, {"position": 42, "createdBy": "user", "text": "Another agent has a wider survey. I'll bring its answer back here."}], "nextPosition": 43, "hasMore": false}}}, "prompt": "That thread is on this machine, you can talk to it directly with t3 code: 11111111-1111-4111-8111-111111111111", "expect": {"calls": [{"tool": "t3_thread_send", "args": {"threadId": "11111111-1111-4111-8111-111111111111"}}], "notCalls": ["delegate_task", "t3_thread_launch"], "textMust": ["<t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>"]}, "notes": "Keeps a rewrite from over-banning t3_thread_send. The ban is only for delegated childThreadIds."}
29
{"id": "too-many-delegates-cancel-extras", "area": "orchestration", "kind": "guard", "pattern": "volume complaint: cancel, do not add", "experience": "After 'You're doing too much man, we have like 6+ delegates going', the agent stopped the stale review tasks and made the next fix without a new round.", "rule": "none (task_cancel description covers the action)", "privacy": "commit-safe", "setup": {"role": "top", "priorTurns": [{"role": "user", "text": "Take over https://github.com/acme/app/pull/123. Have Sol and Opus delegates audit it hard."}, {"role": "assistant", "text": "Five audits are running on the PR: three Sol (error handling, concurrency, API surface) and two Opus (tests, migration safety).", "toolCalls": [{"tool": "delegate_task", "input": {"title": "Sol audit: error handling", "mode": "async", "clientRequestId": "pr123-sol-error", "target": {"providerInstanceId": "codex", "model": "gpt-6.1-sol", "options": {"reasoningEffort": "high"}}, "task": "Audit https://github.com/acme/app/pull/123 for error handling problems. Report each with file:line. Read only."}, "result": {"taskId": "task-1", "childThreadId": "44444444-4444-4444-8444-000000000001", "childRunId": "run-child-1", "status": "running", "workState": "working", "providerInstanceId": "codex", "model": "gpt-6.1-sol"}}, {"tool": "delegate_task", "input": {"title": "Sol audit: concurrency", "mode": "async", "clientRequestId": "pr123-sol-concurrency", "target": {"providerInstanceId": "codex", "model": "gpt-6.1-sol", "options": {"reasoningEffort": "high"}}, "task": "Audit https://github.com/acme/app/pull/123 for concurrency problems. Report each with file:line. Read only."}, "result": {"taskId": "task-2", "childThreadId": "44444444-4444-4444-8444-000000000002", "childRunId": "run-child-2", "status": "running", "workState": "working", "providerInstanceId": "codex", "model": "gpt-6.1-sol"}}, {"tool": "delegate_task", "input": {"title": "Sol audit: API surface", "mode": "async", "clientRequestId": "pr123-sol-api", "target": {"providerInstanceId": "codex", "model": "gpt-6.1-sol", "options": {"reasoningEffort": "high"}}, "task": "Audit https://github.com/acme/app/pull/123 for API surface problems. Report each with file:line. Read only."}, "result": {"taskId": "task-3", "childThreadId": "44444444-4444-4444-8444-000000000003", "childRunId": "run-child-3", "status": "running", "workState": "working", "providerInstanceId": "codex", "model": "gpt-6.1-sol"}}, {"tool": "delegate_task", "input": {"title": "Opus audit: tests", "mode": "async", "clientRequestId": "pr123-opus-tests", "target": {"providerInstanceId": "claudeAgent", "model": "claude-opus-5-5"}, "task": "Audit https://github.com/acme/app/pull/123 for tests problems. Report each with file:line. Read only."}, "result": {"taskId": "task-4", "childThreadId": "44444444-4444-4444-8444-000000000004", "childRunId": "run-child-4", "status": "running", "workState": "working", "providerInstanceId": "claudeAgent", "model": "claude-opus-5-5"}}, {"tool": "delegate_task", "input": {"title": "Opus audit: migration safety", "mode": "async", "clientRequestId": "pr123-opus-migration", "target": {"providerInstanceId": "claudeAgent", "model": "claude-opus-5-5"}, "task": "Audit https://github.com/acme/app/pull/123 for migration safety problems. Report each with file:line. Read only."}, "result": {"taskId": "task-5", "childThreadId": "44444444-4444-4444-8444-000000000005", "childRunId": "run-child-5", "status": "running", "workState": "working", "providerInstanceId": "claudeAgent", "model": "claude-opus-5-5"}}]}], "mocks": {"task_status": {"status": "running", "workState": "working"}, "task_cancel": {"status": "cancel_requested"}}, "world": {"prs": [{"number": 123, "title": "feat(server): resumable uploads", "headRefName": "feat/resumable-uploads"}]}}, "prompt": "You're doing too much man, we have like 6+ delegates going. We don't need to go that hard.", "expect": {"calls": [{"tool": "task_cancel"}], "maxCalls": {"delegate_task": 0}, "notCalls": ["t3_thread_interrupt"]}, "notes": "Pairs with review-round-per-bot-nit."}
30
{"id": "control-new-thread-view-wording", "area": "orchestration", "kind": "control", "pattern": "'new thread' as product text", "experience": "A UI bug report that says 'new thread view' needs a code fix, not a new T3 thread or delegate.", "rule": "t3_thread_launch and create_threads ... only when the user explicitly asks for separate/new/top-level threads.", "privacy": "commit-safe", "setup": {"role": "top", "world": {"files": {"apps/mobile/src/Sidebar.tsx": "export function Sidebar() {\n return (\n <View style={styles.sidebar} pointerEvents={isFoldable ? 'box-none' : 'auto'}>\n <ThreadList onPress={openThread} />\n </View>\n );\n}\n", "apps/mobile/src/NewThreadView.tsx": "export function NewThreadView() {\n return <View style={StyleSheet.absoluteFill}>{/* composer */}</View>;\n}\n"}}}, "prompt": "On Android foldables the sidebar is visible but tapping threads does nothing in some places, like the new thread view or settings. It makes the sidebar feel broken. Fix it.", "expect": {"notCalls": ["t3_thread_launch", "create_threads", "delegate_task", "orchestrator_capabilities"]}, "notes": ""}
31
{"id": "control-subagent-label-bug-wording", "area": "orchestration", "kind": "control", "pattern": "'subagent' as product text", "experience": "A bug report about how subagent models are labeled is a code task. It needs no delegation.", "rule": "none", "privacy": "commit-safe", "setup": {"role": "top", "world": {"commits": [{"sha": "61b0e9d", "subject": "fix(web): label subagent messages with the subagent's model"}], "files": {"apps/web/src/subagentLabel.ts": "export function subagentModelLabel(run: Run, parent: Thread) {\n return run.model ?? parent.model;\n}\n"}}}, "prompt": "I recently fixed a bug where models were labeled wrong inside subagents that run through Claude Code. I think it came back in a different form. A Sol subagent shows the parent's model name in the UI. Find the cause and fix it.", "expect": {"notCalls": ["delegate_task", "orchestrator_capabilities", "t3_thread_launch", "create_threads", "Workflow"]}, "notes": ""}
evals/mcp-tool-use/run.test.ts
+3
-3
@@ -104,7 +104,7 @@ it("passes a good run and names every rule a bad run breaks", () => {
104
maxCalls: { task_status: 0 },
105
endsTurnAfter: "delegate_task",
106
shellMustNot: ["\\bsleep\\b"],
107
- textMust: ["t3-thread://v1/"],
107
+ textMust: ["t3-thread://v2/"],
108
textMustNot: ["Paste .*token"],
109
linked: ["~/pull/124"],
110
};
@@ -117,7 +117,7 @@ it("passes a good run and names every rule a bad run breaks", () => {
117
input: { task: "Prior findings: ...", target: { options: { reasoningEffort: "max" } } },
118
},
119
],
120
- text: "Started [Review](t3-thread://v1/11111111-1111-4111-8111-111111111111). Do not paste a token.",
120
+ text: "Started <t3-thread://v2/eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee/11111111-1111-4111-8111-111111111111>. Do not paste a token.",
121
stopReason: "end_turn",
122
linked: ["https://github.com/acme/app/pull/124"],
123
};
@@ -146,7 +146,7 @@ it("passes a good run and names every rule a bad run breaks", () => {
146
"maxCalls task_status <= 0",
147
"endsTurnAfter delegate_task",
148
"shellMustNot /\\bsleep\\b/",
149
- "textMust /t3-thread://v1//",
149
+ "textMust /t3-thread://v2//",
150
"textMustNot /Paste .*token/",
151
"linked ~/pull/124",
152
]);
evals/mcp-tool-use/run.ts
+14
-3
@@ -33,7 +33,7 @@ import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
33
import { taskPrompt } from "../../apps/server/src/mcp/delegatedTaskModes.ts";
34
import * as McpInvocationContext from "../../apps/server/src/mcp/McpInvocationContext.ts";
35
import { advertisedJsonSchema } from "../../apps/server/src/mcp/advertisedJsonSchema.ts";
36
-import { ORCHESTRATOR_MCP_RUNNING_TASK_NEXT } from "@t3tools/contracts";
36
+import { EnvironmentId, ORCHESTRATOR_MCP_RUNNING_TASK_NEXT, ThreadId } from "@t3tools/contracts";
37
import { projectComposerContextForProvider } from "@t3tools/shared/composerContextReferences";
38
import { formatThreadLink } from "@t3tools/shared/threadLinks";
39
import { buildCodexAdditionalContext } from "../../apps/server/src/provider/CodexDeveloperInstructions.ts";
@@ -893,14 +893,24 @@ const t3Default = (sample: Sample, name: string, input: Readonly<Record<string,
893
}
894
};
895
896
+/** The machine the fake threads live on. */
897
+const EVAL_ENVIRONMENT_ID = EnvironmentId.make("eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee");
898
+
899
/** Fields T3 adds to real thread and task results, applied to mocks and defaults alike. */
900
const withProductFields = (name: string, value: unknown, child: boolean): unknown => {
901
if (!isRecord(value)) return value;
902
const linked = (thread: unknown, idKey = "threadId") => {
903
if (!isRecord(thread) || thread.link !== undefined) return thread;
904
const id = thread[idKey] ?? thread.id;
902
- const title = valueText(thread.title) || "Thread";
903
- return typeof id === "string" ? { ...thread, link: formatThreadLink(id, title) } : thread;
905
+ return typeof id === "string"
906
+ ? {
907
+ ...thread,
908
+ link: formatThreadLink({
909
+ environmentId: EVAL_ENVIRONMENT_ID,
910
+ threadId: ThreadId.make(id),
911
+ }),
912
+ }
913
+ : thread;
914
};
915
const listed = (key: string) =>
916
Array.isArray(value[key]) ? { ...value, [key]: value[key].map((item) => linked(item)) } : value;
@@ -915,6 +925,7 @@ const withProductFields = (name: string, value: unknown, child: boolean): unknow
925
return { ...value, thread: linked(value.thread) };
926
case "t3_thread_launch":
927
case "t3_thread_send":
928
+ case "run_scheduled_task_now":
929
return linked(value);
930
case "t3_thread_list":
931
case "create_threads":
packages/provider-core/src/server/orchestrationInstructions.ts
+1
-1
@@ -15,7 +15,7 @@ Ordinary coding tasks need no T3 tools.
15
- Given a thread id, \`t3_thread_read\` it before you answer about it.
16
- Another machine: \`t3_environment_links\` lists linked ones. Pass its \`environmentId\` to a T3 tool to act there. Ids are then that machine's, so pass \`threadId\`.
17
- A machine the user names that is not linked ("delegate this to my vps"): call \`t3_environment_link\` with a \`hint\` from their words. Never ask for a pairing code in chat.
18
-- In your reply, a thread's first mention is its \`link\` verbatim. No \`link\`: \`[title](t3-thread://v1/<exact id>)\`. Never a plain title or bare id. A thread on a linked machine: its title and machine, not its link.
18
+- In your reply, mention a thread by its \`link\`, verbatim. Never a plain title or bare id.
19
- A secret: call \`request_secret\` yourself. Pass its \`secretRef\` to a T3 tool, or use \`delivery: "file"\` for a shell command. Never ask in chat or invent one. When asked only to schedule, \`schedule_task\` without running its prompt.
20
- T3 tools may load late. Try the name once before you call it absent.`,
21
`### Visuals and preview
packages/shared/src/markdownPipeline.test.ts
+12
-2
@@ -12,7 +12,7 @@ it("preserves in-app thread links through the shared Markdown sanitizer", () =>
12
.use(CHAT_MARKDOWN_REHYPE_PLUGINS);
13
const tree = processor.runSync(
14
processor.parse(
15
- '[Open thread](t3-thread://v1/environment/thread)\n\n<a href="javascript:alert(1)">Unsafe</a>',
15
+ '[Open thread](t3-thread://v1/thread)\n\n<t3-thread://v2/environment/thread:a%3A1>\n\n<a href="javascript:alert(1)">Unsafe</a>',
16
),
17
);
18
expect(tree.children[0]).toMatchObject({
@@ -20,11 +20,21 @@ it("preserves in-app thread links through the shared Markdown sanitizer", () =>
20
children: [
21
{
22
tagName: "a",
23
- properties: { href: "t3-thread://v1/environment/thread" },
23
+ properties: { href: "t3-thread://v1/thread" },
24
children: [{ type: "text", value: "Open thread" }],
25
},
26
],
27
});
28
+ expect(tree.children[2]).toMatchObject({
29
+ tagName: "p",
30
+ children: [
31
+ {
32
+ tagName: "a",
33
+ properties: { href: "t3-thread://v2/environment/thread:a%3A1" },
34
+ children: [{ type: "text", value: "t3-thread://v2/environment/thread:a%3A1" }],
35
+ },
36
+ ],
37
+ });
38
expect(JSON.stringify(tree)).not.toContain("javascript:");
39
});
40
packages/shared/src/threadLinks.test.ts
+92
-45
@@ -1,53 +1,69 @@
1
import { describe, expect, it } from "vite-plus/test";
2
-import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2
+import { EnvironmentId, ThreadId, type ScopedThreadRef } from "@t3tools/contracts";
3
4
import {
5
formatThreadLink,
6
+ guessThreadLinkRef,
7
parseThreadLinkHref,
8
relabelThreadLinks,
8
- resolveThreadLinkRef,
9
+ threadLinkCandidates,
10
+ threadLinkRefs,
11
} from "./threadLinks.ts";
12
13
const ref = (environmentId: string, threadId = "chat-1") => ({
14
environmentId: EnvironmentId.make(environmentId),
15
threadId: ThreadId.make(threadId),
16
});
17
+const v1 = (threadId: string) => ({ environmentId: null, threadId: ThreadId.make(threadId) });
18
+const local = EnvironmentId.make("local");
19
+const titlesIn =
20
+ (titles: Record<string, Record<string, string>>) =>
21
+ ({ environmentId, threadId }: ScopedThreadRef) =>
22
+ titles[environmentId]?.[threadId];
23
24
describe("thread link destinations", () => {
17
- it("prefers the local literal id, then the local decoded id, over remote matches", () => {
18
- const source = ref("local", "provider%3A1");
19
- const decoded = ref("local", "provider:1");
20
- const remote = ref("remote", "provider%3A1");
21
- expect(resolveThreadLinkRef(source, [remote, decoded, source])).toEqual(source);
22
- expect(resolveThreadLinkRef(source, [remote, decoded])).toEqual(decoded);
25
+ it("names a v1 link's thread in the message's environment, as written and then decoded", () => {
26
+ expect(threadLinkCandidates(v1("provider%3A1"), local)).toEqual([
27
+ ref("local", "provider%3A1"),
28
+ ref("local", "provider:1"),
29
+ ]);
30
});
31
25
- it("opens the unique matching chat in another environment", () => {
32
+ it("opens the unique matching chat in another environment for a v1 link", () => {
33
const destination = ref("remote");
27
- expect(resolveThreadLinkRef(ref("local"), [ref("local", "other-chat"), destination])).toEqual(
34
+ expect(guessThreadLinkRef(v1("chat-1"), [ref("local", "other-chat"), destination])).toEqual(
35
destination,
36
);
37
});
38
39
+ it("opens a v2 link only in its own environment", () => {
40
+ const there = ref("there", "a%3A1");
41
+ expect(threadLinkCandidates(there, local)).toEqual([there, ref("there", "a:1")]);
42
+ expect(guessThreadLinkRef(there, [ref("elsewhere", "a%3A1"), ref("elsewhere", "a:1")])).toBe(
43
+ null,
44
+ );
45
+ });
46
+
47
it("leaves ambiguous or missing destinations unresolved", () => {
33
- const source = ref("local", "provider%3A1");
48
+ const link = v1("provider%3A1");
49
const literal = ref("remote", "provider%3A1");
50
const decoded = ref("remote", "provider:1");
51
expect(
37
- resolveThreadLinkRef(source, [literal, ref("other-remote", literal.threadId), decoded]),
38
- ).toBeNull();
39
- expect(
40
- resolveThreadLinkRef(source, [decoded, ref("other-remote", decoded.threadId)]),
52
+ guessThreadLinkRef(link, [literal, ref("other-remote", literal.threadId), decoded]),
53
).toBeNull();
42
- expect(resolveThreadLinkRef(source, [ref("remote", "other-chat")])).toBeNull();
54
+ expect(guessThreadLinkRef(link, [decoded, ref("other-remote", decoded.threadId)])).toBeNull();
55
+ expect(guessThreadLinkRef(link, [ref("remote", "other-chat")])).toBeNull();
56
});
57
});
58
59
describe("thread links", () => {
47
- it("takes the thread id verbatim, percent escapes included", () => {
48
- expect(parseThreadLinkHref("t3-thread://v1/mcp:1234")).toBe("mcp:1234");
49
- expect(parseThreadLinkHref("t3-thread://v1/thread:delegated-task:mcp%3A1")).toBe(
50
- "thread:delegated-task:mcp%3A1",
60
+ it("takes the ids verbatim, percent escapes included", () => {
61
+ expect(parseThreadLinkHref("t3-thread://v1/mcp:1234")).toEqual(v1("mcp:1234"));
62
+ expect(parseThreadLinkHref("t3-thread://v1/thread:delegated-task:mcp%3A1")).toEqual(
63
+ v1("thread:delegated-task:mcp%3A1"),
64
+ );
65
+ expect(parseThreadLinkHref("t3-thread://v2/env-1/thread:a/b%3A1")).toEqual(
66
+ ref("env-1", "thread:a/b%3A1"),
67
);
68
});
69
@@ -55,59 +71,90 @@ describe("thread links", () => {
71
expect(parseThreadLinkHref("https://t3.codes")).toBeNull();
72
expect(parseThreadLinkHref("t3-thread://v1/")).toBeNull();
73
expect(parseThreadLinkHref("t3-thread://v1/ ")).toBeNull();
74
+ expect(parseThreadLinkHref("t3-thread://v2/env-1")).toBeNull();
75
+ expect(parseThreadLinkHref("t3-thread://v2/env-1/")).toBeNull();
76
+ expect(parseThreadLinkHref("t3-thread://v2//chat-1")).toBeNull();
77
});
78
79
it("resolves a percent-encoded id when the id as written names no thread", () => {
61
- const titles = new Map([
62
- ["thread:project:1", "Decoded"],
63
- ["provider%3A1", "Literal escape"],
64
- ]);
80
+ const title = titlesIn({ local: { "thread:project:1": "Decoded", "provider%3A1": "Literal" } });
81
expect(
82
relabelThreadLinks(
83
"[a](t3-thread://v1/thread%3Aproject%3A1) [b](t3-thread://v1/provider%3A1)",
68
- (threadId) => titles.get(threadId),
84
+ local,
85
+ title,
86
),
70
- ).toBe(
71
- "[Decoded](t3-thread://v1/thread:project:1) [Literal escape](t3-thread://v1/provider%3A1)",
87
+ ).toBe("[Decoded](t3-thread://v1/thread:project:1) [Literal](t3-thread://v1/provider%3A1)");
88
+ const untitled = titlesIn({ local: { "a%3A1": "", "a:1": "Other" } });
89
+ expect(relabelThreadLinks("[Kept](t3-thread://v1/a%3A1)", local, untitled)).toBe(
90
+ "[Kept](t3-thread://v1/a%3A1)",
91
);
73
- const untitled = new Map([
74
- ["a%3A1", ""],
75
- ["a:1", "Other"],
76
- ]);
92
+ });
93
+
94
+ it("titles a v2 link from its own environment and writes it with that title", () => {
95
+ const title = titlesIn({ local: { t1: "Here" }, there: { t1: "There" } });
96
+ expect(
97
+ relabelThreadLinks(
98
+ "<t3-thread://v2/there/t1> and [old](t3-thread://v2/local/t1)",
99
+ local,
100
+ title,
101
+ ),
102
+ ).toBe("[There](t3-thread://v2/there/t1) and [Here](t3-thread://v2/local/t1)");
103
+ });
104
+
105
+ it("turns a v2 link it cannot resolve into plain text, never the raw link", () => {
106
expect(
78
- relabelThreadLinks("[Kept](t3-thread://v1/a%3A1)", (threadId) => untitled.get(threadId)),
79
- ).toBe("[Kept](t3-thread://v1/a%3A1)");
107
+ relabelThreadLinks(
108
+ "<t3-thread://v2/there/t1>, <t3-thread://v2/local/t1>, [Old title](t3-thread://v2/there/t1)",
109
+ local,
110
+ () => undefined,
111
+ ),
112
+ ).toBe("Thread on another machine, Thread no longer available, Old title");
113
+ expect(relabelThreadLinks("[Old](t3-thread://v1/t1)", local, () => undefined)).toBe(
114
+ "[Old](t3-thread://v1/t1)",
115
+ );
116
});
117
118
it("leaves links inside code spans and fences as written", () => {
119
const markdown = [
120
"Live [old](t3-thread://v1/t1), literal `[old](t3-thread://v1/t1)`.",
121
"```md",
86
- "[old](t3-thread://v1/t1)",
122
+ "<t3-thread://v2/local/t1>",
123
"```",
88
- "After [old](t3-thread://v1/t1)",
124
+ "After <t3-thread://v2/local/t1>",
125
].join("\n");
90
- expect(relabelThreadLinks(markdown, () => "New")).toBe(
126
+ expect(relabelThreadLinks(markdown, local, () => "New")).toBe(
127
[
128
"Live [New](t3-thread://v1/t1), literal `[old](t3-thread://v1/t1)`.",
129
"```md",
94
- "[old](t3-thread://v1/t1)",
130
+ "<t3-thread://v2/local/t1>",
131
"```",
96
- "After [New](t3-thread://v1/t1)",
132
+ "After [New](t3-thread://v2/local/t1)",
133
].join("\n"),
134
);
135
});
136
101
- it("writes the thread id verbatim so the link opens that exact thread", () => {
102
- const link = formatThreadLink("thread:delegated-task:mcp%3A1", "Fix");
103
- expect(link).toBe("[Fix](t3-thread://v1/thread:delegated-task:mcp%3A1)");
104
- expect(parseThreadLinkHref(link.slice(link.indexOf("](") + 2, -1))).toBe(
105
- "thread:delegated-task:mcp%3A1",
137
+ it("lists the threads a message's links can name, outside code", () => {
138
+ expect(
139
+ threadLinkRefs(
140
+ "<t3-thread://v2/there/t1> [a](t3-thread://v1/t%3A2) `<t3-thread://v2/code/t3>`",
141
+ local,
142
+ ),
143
+ ).toEqual([ref("there", "t1"), ref("local", "t%3A2"), ref("local", "t:2")]);
144
+ });
145
+
146
+ it("writes a titleless autolink that opens that exact thread", () => {
147
+ const link = formatThreadLink(ref("env-1", "thread:delegated-task:mcp%3A1"));
148
+ expect(link).toBe("<t3-thread://v2/env-1/thread:delegated-task:mcp%3A1>");
149
+ expect(parseThreadLinkHref(link.slice(1, -1))).toEqual(
150
+ ref("env-1", "thread:delegated-task:mcp%3A1"),
151
);
152
});
153
154
it("formats a label that would otherwise break the Markdown link", () => {
110
- expect(formatThreadLink("t1", "Fix [ci] \\ build")).toBe("[Fix ci build](t3-thread://v1/t1)");
111
- expect(formatThreadLink("t1", " ] ")).toBe("[t1](t3-thread://v1/t1)");
155
+ expect(formatThreadLink(ref("e", "t1"), "Fix [ci] \\ build")).toBe(
156
+ "[Fix ci build](t3-thread://v2/e/t1)",
157
+ );
158
+ expect(formatThreadLink(ref("e", "t1"), " ] ")).toBe("<t3-thread://v2/e/t1>");
159
});
160
});
packages/shared/src/threadLinks.ts
+101
-29
@@ -1,19 +1,36 @@
1
-import { ThreadId, type ScopedThreadRef } from "@t3tools/contracts";
1
+import { EnvironmentId, ThreadId, type ScopedThreadRef } from "@t3tools/contracts";
2
import * as Option from "effect/Option";
3
import * as Schema from "effect/Schema";
4
5
export const THREAD_LINK_PROTOCOL = "t3-thread";
6
-const THREAD_LINK_HREF_PREFIX = `${THREAD_LINK_PROTOCOL}://v1/`;
6
+const V1_PREFIX = `${THREAD_LINK_PROTOCOL}://v1/`;
7
+const V2_PREFIX = `${THREAD_LINK_PROTOCOL}://v2/`;
8
// Code comes first in the alternation so a link written inside a code span or fence is skipped.
9
const THREAD_LINK_OUTSIDE_CODE =
9
- /(?<fence>(`{3,}|~{3,})[\s\S]*?(?:\2|$))|(?<span>(`+)[^\n]*?\4)|\[[^\]\n]*\]\((?<href>t3-thread:\/\/v1\/[^\s)]+)\)/g;
10
+ /(?<fence>(`{3,}|~{3,})[\s\S]*?(?:\2|$))|(?<span>(`+)[^\n]*?\4)|\[(?<label>[^\]\n]*)\]\((?<href>t3-thread:\/\/v[12]\/[^\s)]+)\)|<(?<autolink>t3-thread:\/\/v[12]\/[^\s<>]+)>/g;
11
12
const decodeThreadId = Schema.decodeUnknownOption(ThreadId);
13
+const decodeEnvironmentId = Schema.decodeUnknownOption(EnvironmentId);
14
13
-/** The id as written. Thread ids can hold percent escapes of their own, so it is not decoded. */
14
-export function parseThreadLinkHref(href: string): ThreadId | null {
15
- if (!href.startsWith(THREAD_LINK_HREF_PREFIX)) return null;
16
- return Option.getOrNull(decodeThreadId(href.slice(THREAD_LINK_HREF_PREFIX.length)));
15
+/** A v1 link names no environment; the message's own, or a unique match, stands in. */
16
+export interface ThreadLink {
17
+ readonly environmentId: EnvironmentId | null;
18
+ readonly threadId: ThreadId;
19
+}
20
+
21
+/** The ids as written. Thread ids can hold percent escapes of their own, so they are not decoded. */
22
+export function parseThreadLinkHref(href: string): ThreadLink | null {
23
+ if (href.startsWith(V1_PREFIX)) {
24
+ const threadId = Option.getOrNull(decodeThreadId(href.slice(V1_PREFIX.length)));
25
+ return threadId === null ? null : { environmentId: null, threadId };
26
+ }
27
+ if (!href.startsWith(V2_PREFIX)) return null;
28
+ const path = href.slice(V2_PREFIX.length);
29
+ const slash = path.indexOf("/");
30
+ if (slash < 0) return null;
31
+ const environmentId = Option.getOrNull(decodeEnvironmentId(path.slice(0, slash)));
32
+ const threadId = Option.getOrNull(decodeThreadId(path.slice(slash + 1)));
33
+ return environmentId === null || threadId === null ? null : { environmentId, threadId };
34
}
35
36
export function percentDecodedThreadLinkId(threadId: ThreadId): ThreadId | null {
@@ -25,19 +42,25 @@ export function percentDecodedThreadLinkId(threadId: ThreadId): ThreadId | null
42
}
43
}
44
28
-export function resolveThreadLinkRef(
29
- source: ScopedThreadRef,
45
+/** The threads a link can name, in its own environment or else the message's: as written, then decoded. */
46
+export function threadLinkCandidates(
47
+ link: ThreadLink,
48
+ messageEnvironmentId: EnvironmentId,
49
+): ReadonlyArray<ScopedThreadRef> {
50
+ const environmentId = link.environmentId ?? messageEnvironmentId;
51
+ const decodedId = percentDecodedThreadLinkId(link.threadId);
52
+ const written = { environmentId, threadId: link.threadId };
53
+ return decodedId === null ? [written] : [written, { environmentId, threadId: decodedId }];
54
+}
55
+
56
+/** A v1 link its message's environment lacks opens a unique match elsewhere; a v2 link never does. */
57
+export function guessThreadLinkRef(
58
+ link: ThreadLink,
59
refs: ReadonlyArray<ScopedThreadRef>,
60
): ScopedThreadRef | null {
32
- const decodedId = percentDecodedThreadLinkId(source.threadId);
33
- const ids = decodedId === null ? [source.threadId] : [source.threadId, decodedId];
34
- for (const threadId of ids) {
35
- const local = refs.find(
36
- (ref) => ref.environmentId === source.environmentId && ref.threadId === threadId,
37
- );
38
- if (local) return local;
39
- }
40
- for (const threadId of ids) {
61
+ if (link.environmentId !== null) return null;
62
+ const decodedId = percentDecodedThreadLinkId(link.threadId);
63
+ for (const threadId of decodedId === null ? [link.threadId] : [link.threadId, decodedId]) {
64
let match: ScopedThreadRef | null = null;
65
for (const ref of refs) {
66
if (ref.threadId !== threadId) continue;
@@ -49,34 +72,83 @@ export function resolveThreadLinkRef(
72
return null;
73
}
74
52
-export function formatThreadLink(threadId: string, label: string): string {
75
+function threadLinkHref(link: ThreadLink): string {
76
+ return link.environmentId === null
77
+ ? `${V1_PREFIX}${link.threadId}`
78
+ : `${V2_PREFIX}${link.environmentId}/${link.threadId}`;
79
+}
80
+
81
+/** Without a label, an autolink: clients show the thread's current title. */
82
+export function formatThreadLink(ref: ThreadLink, label?: string): string {
83
const cleaned = label
54
- .replace(/[[\]\\\r\n]/g, " ")
84
+ ?.replace(/[[\]\\\r\n]/g, " ")
85
.replace(/\s+/g, " ")
86
.trim();
57
- return `[${cleaned || threadId}](${THREAD_LINK_HREF_PREFIX}${threadId})`;
87
+ return cleaned ? `[${cleaned}](${threadLinkHref(ref)})` : `<${threadLinkHref(ref)}>`;
88
}
89
90
export function hasThreadLinks(markdown: string): boolean {
61
- return markdown.includes(`](${THREAD_LINK_HREF_PREFIX}`);
91
+ return markdown.includes(`${THREAD_LINK_PROTOCOL}://v`);
92
}
93
94
+/** Every thread the markdown's links can name, so their titles are keyed reads. */
95
+export function threadLinkRefs(
96
+ markdown: string,
97
+ messageEnvironmentId: EnvironmentId,
98
+): ReadonlyArray<ScopedThreadRef> {
99
+ const refs = new Map<string, ScopedThreadRef>();
100
+ for (const match of markdown.matchAll(THREAD_LINK_OUTSIDE_CODE)) {
101
+ const href = match.groups?.href ?? match.groups?.autolink;
102
+ const link = href === undefined ? null : parseThreadLinkHref(href);
103
+ if (link === null) continue;
104
+ for (const ref of threadLinkCandidates(link, messageEnvironmentId)) {
105
+ refs.set(`${ref.environmentId}/${ref.threadId}`, ref);
106
+ }
107
+ }
108
+ return [...refs.values()];
109
+}
110
+
111
+export function unknownThreadLinkLabel(
112
+ link: ThreadLink,
113
+ messageEnvironmentId: EnvironmentId,
114
+): string {
115
+ return link.environmentId === null || link.environmentId === messageEnvironmentId
116
+ ? "Thread no longer available"
117
+ : "Thread on another machine";
118
+}
119
+
120
+/**
121
+ * Writes each link with its thread's current title. A link `title` cannot resolve becomes plain
122
+ * text, its written label or a neutral one, except a labeled v1 link, which may open elsewhere.
123
+ */
124
export function relabelThreadLinks(
125
markdown: string,
66
- title: (threadId: ThreadId) => string | undefined,
126
+ messageEnvironmentId: EnvironmentId,
127
+ title: (ref: ScopedThreadRef) => string | undefined,
128
): string {
129
if (!hasThreadLinks(markdown)) return markdown;
130
return markdown.replace(THREAD_LINK_OUTSIDE_CODE, (source, ...args) => {
70
- const href = (args.at(-1) as { href?: string }).href;
131
+ const groups = args.at(-1) as { href?: string; autolink?: string; label?: string };
132
+ const href = groups.href ?? groups.autolink;
133
if (href === undefined) return source;
134
const written = parseThreadLinkHref(href);
135
if (written === null) return source;
74
- const decoded = percentDecodedThreadLinkId(written);
136
+ const environmentId = written.environmentId ?? messageEnvironmentId;
137
+ const decoded = percentDecodedThreadLinkId(written.threadId);
138
const threadId =
76
- title(written) === undefined && decoded !== null && title(decoded) !== undefined
139
+ title({ environmentId, threadId: written.threadId }) === undefined &&
140
+ decoded !== null &&
141
+ title({ environmentId, threadId: decoded }) !== undefined
142
? decoded
78
- : written;
79
- const label = title(threadId)?.trim();
80
- return label ? formatThreadLink(threadId, label) : source;
143
+ : written.threadId;
144
+ const current = title({ environmentId, threadId });
145
+ if (current === undefined) {
146
+ if (groups.href !== undefined && written.environmentId === null) return source;
147
+ return groups.label?.trim() || unknownThreadLinkLabel(written, messageEnvironmentId);
148
+ }
149
+ return formatThreadLink(
150
+ { environmentId: written.environmentId, threadId },
151
+ current.trim() || groups.label || threadId,
152
+ );
153
});
154
}