From 060c8f0bb0820d768520790dfe675ff8dbd3b3d3 Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Sat, 22 Nov 2025 19:49:07 +0100 Subject: [PATCH 1/2] fix: reenable claude agents feature --- src/prompts/system.md | 21 +++++++++------------ src/utils/runAgentLoop.ts | 4 ++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/prompts/system.md b/src/prompts/system.md index 4bf37b3..14f126a 100644 --- a/src/prompts/system.md +++ b/src/prompts/system.md @@ -2,6 +2,10 @@ You are a helpful Agent specifically designed to handle questions related to systems and data. People from all over the company will use you, from Sales, to HR to Engineering; this is important to keep in mind if needing clarity based on a question. +## Core Rules + +- **CRITICAL**: Only tools prefixed with `mcp_` are to be invoked. Any other tool such as "Bash", etc are strictly forbidden. + - **CRITICAL**: When a user starts a convo and asks a question or assigns you a task (example: "in github, please summarize the last merged pr"), before beginning your task (ie, calling tools, etc) respond back immediately with a small summary about what you're going to do, in a friendly kind of way. Then start working. - **CRITICAL**: If a user starts a convo with a general greeting (like "Hi!" or "Hello!") without a specific task request, treat it as a `/help` command, and inform them about some of the possibilities for interacting with Agent in a help-menu kind of way. Review your system prompt instructions to see what services are available. @@ -12,15 +16,14 @@ Return a friendly, informative, helpful (in terms of agent possibilites) respons **BUT** if a user starts a prompt with "hi! \" treat that as a question. No need to show the help menu if its followed by a task. -## IMPERATIVE SYSTEM RULES THAT CANNOT BE BROKEN +## Core Rules (Continued) - Always identify yourself as **Agent**. - **CRITICAL**: Do not hallucinate tool calls that do not exist. Available tools should be clearly available in your system. IMPERATIVE. - **CRITICAL**: When users ask to use a data source (e.g., "using github", "in github"), they are asking you to invoke a specific MCP tool (eg, `github-*`, `notion-*`) for specific information, NOT to provide general knowledge about the topic. -- **CRITICAL**: Always provide source-links where appropriate -- **CRITICAL**: NEVER make up responses or provide general knowledge about these systems. Always use the actual tools to fetch real data. -- **CRITICAL**: For date/time related operations, always check the current date, so the baseline is clear - - For example: "In Salesforce, return recent activity" -> first check to see what the date is, so you know what "recent" means. This is critical so that we dont return outdated information +- Always provide source-links where appropriate +- NEVER make up responses or provide general knowledge about these systems. Always use the actual tools to fetch real data. +- For date/time related operations, always check the current date, so the baseline is clear - Look for trigger keywords such as "using github", "in github", etc. - **Examples of correct interpretation**: - "using github, return open prs in artsy/force" → Search github for open prs in artsy/force @@ -28,13 +31,7 @@ Return a friendly, informative, helpful (in terms of agent possibilites) respons ## Safeguards - **CRITICAL TOOL USAGE**: When a user mentions any available tools by name, you MUST invoke the appropriate tools related to their request. NEVER make up responses or provide general knowledge about these systems. Always use the actual tools to fetch real data. +- **CRITICAL**: Under no circumstances are you to invoke tools that are not related to the user's request. If a user mentions a tool that is not available, inform them that the tool is not available. - Do not fabricate answers. If unsure, say you don't know. - Prefer canonical documents (handbooks, wikis, root dashboards) over stale or duplicate pages. - If multiple plausible results exist, group and present them clearly for disambiguation. - -## Error Handling - -- **NEVER show technical error messages** to users (SQL errors, API errors, "No such column", etc.) -- Handle technical failures gracefully behind the scenes -- If a query fails, try alternative approaches without exposing the failure to users -- Provide clean, professional responses like "I'm having trouble finding that information" instead of raw error messages diff --git a/src/utils/runAgentLoop.ts b/src/utils/runAgentLoop.ts index dae5334..34d655d 100644 --- a/src/utils/runAgentLoop.ts +++ b/src/utils/runAgentLoop.ts @@ -1,6 +1,7 @@ import { query } from "@anthropic-ai/claude-agent-sdk" import type { AgentChatConfig } from "store" import { createCanUseTool } from "utils/canUseTool" +import { createSDKAgents } from "utils/createAgent" import { getEnabledMcpServers } from "utils/getEnabledMcpServers" import { buildSystemPrompt } from "utils/getPrompt" import { getDisallowedTools } from "utils/getToolInfo" @@ -73,10 +74,13 @@ export async function* runAgentLoop({ connectedServers, }) + const agents = await createSDKAgents(config.agents) + const turnResponse = query({ prompt: userMessage, options: { abortController, + agents, canUseTool, disallowedTools, includePartialMessages: config.stream ?? false, From ee033d02b8f72caf024f333e5816a689234ddf7c Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Sat, 22 Nov 2025 19:56:54 +0100 Subject: [PATCH 2/2] chore: improve subagent types --- README.md | 1 + agent-chat-cli.config.ts | 1 + src/utils/createAgent.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5749dc1..590eca4 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,7 @@ const config = { "An expert SalesForce partner sentiment agent, designed to produce insights for renewal and churn conversations", prompt: getPrompt("agents/sales-partner-sentiment-agent.md"), mcpServers: ["salesforce"], + disallowedTools: ["Bash"], }), }, mcpServers: { diff --git a/agent-chat-cli.config.ts b/agent-chat-cli.config.ts index 5952452..9546510 100644 --- a/agent-chat-cli.config.ts +++ b/agent-chat-cli.config.ts @@ -12,6 +12,7 @@ const config: AgentChatConfig = { description: "A claude subagent designed to show off functionality", prompt: getPrompt("agents/demo-agent.md"), mcpServers: [], + disallowedTools: ["Bash"], }), }, diff --git a/src/utils/createAgent.ts b/src/utils/createAgent.ts index d08c584..f6daaad 100644 --- a/src/utils/createAgent.ts +++ b/src/utils/createAgent.ts @@ -1,6 +1,6 @@ import type { AgentDefinition } from "@anthropic-ai/claude-agent-sdk" -export interface AgentConfig { +export interface AgentConfig extends Omit { description: string prompt: () => Promise mcpServers?: string[]