MCPcopy Index your code
hub / github.com/coder/mux / readToolInstructions

Function readToolInstructions

src/node/services/systemMessage.ts:291–313  ·  view source on GitHub ↗
(
  metadata: WorkspaceMetadata,
  runtime: Runtime,
  workspacePath: string,
  modelString: string,
  agentInstructions?: readonly string[]
)

Source from the content-addressed store, hash-verified

289 * @returns Map of tool names to their additional instructions
290 */
291export async function readToolInstructions(
292 metadata: WorkspaceMetadata,
293 runtime: Runtime,
294 workspacePath: string,
295 modelString: string,
296 agentInstructions?: readonly string[]
297): Promise<Record<string, string>> {
298 // Tool instructions read the same `AGENTS.md` files as the system prompt;
299 // anchor at the workspace root so sub-project workspaces still see parent
300 // project tool sections (see `loadInstructionSources` doc).
301 const workspaceRootPath = subProjectAwareWorkspaceRoot(metadata, runtime, workspacePath);
302 const sources = await loadInstructionSources(metadata, runtime, workspaceRootPath);
303 const globalContents = collectInstructionContents([sources.global]);
304 const contextContents = collectInstructionContents(sources.context);
305
306 return extractToolInstructions(globalContents, contextContents, modelString, {
307 ...getToolAvailabilityOptions({
308 workspaceId: metadata.id,
309 parentWorkspaceId: metadata.parentWorkspaceId,
310 }),
311 agentInstructions,
312 });
313}
314
315/**
316 * For sub-project workspaces, callers typically pass the execution path

Callers 2

streamMessageMethod · 0.90

Calls 5

loadInstructionSourcesFunction · 0.85
extractToolInstructionsFunction · 0.85

Tested by

no test coverage detected