Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

runtimeInstructions.ts

25 lines2.5 KB

1const PULL_REQUEST_LINKING_INSTRUCTIONS = `<pull_request_linking>
2When the t3-code MCP server exposes link_pull_request, you must use it to register every pull request you create or work on for this thread. Call link_pull_request with the full PR URL immediately after creating a PR or starting work on an existing PR. For a stack, call it for every layer, not just the current branch or the top PR. This applies when creating or updating PRs through your host's CLI (including its stack commands) or its API: those operations do not register the PRs with this thread. Linking an already-linked PR is safe. Before finishing PR work, call list_thread_pull_requests and link any PR from your work that is missing. Do not link unrelated PRs mentioned only as background. If a linking call fails, report that failure instead of claiming the PR is linked. As a delegated child task, do not watch or poll PRs; return PR URLs, head SHA, and pending review/check state to your parent. Otherwise, when asked to monitor, watch, or babysit a PR and watch_pull_request is available, call it and end your turn: T3 Code wakes you when checks finish, someone else comments, or the branch conflicts, so do not poll or run your own watcher. When monitoring is done and you hand the work back to the user, call unwatch_pull_request first so the thread returns to their inbox.
3</pull_request_linking>`;
4​
5/** Omit model and effort when the harness manages them dynamically. */
6export function buildRuntimeInstructions(runtime: {
7 readonly harness: string;
8 readonly model?: string | undefined;
9 readonly modelName?: string | undefined;
10 readonly reasoningEffort?: string | undefined;
11}): string {
12 const harness = toSingleLine(runtime.harness);
13 const model = toSingleLine(runtime.model ?? "");
14 const modelName = toSingleLine(runtime.modelName ?? "");
15 const effort = toSingleLine(runtime.reasoningEffort ?? "");
16 const modelLabel =
17 modelName && modelName !== model ? `${modelName} (model slug: ${model})` : model;
18 const modelInfo = model && model !== "auto" && model !== "default" ? `, as ${modelLabel}` : "";
19 const effortInfo = effort ? ` with ${effort} reasoning effort` : "";
20 return `<runtime_info>In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths.</runtime_info>\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`;
22​
23function toSingleLine(value: string): string {
24 return value.replaceAll(/\s+/g, " ").trim();