Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions agent-chat-cli.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}),
},

Expand Down
21 changes: 9 additions & 12 deletions src/prompts/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -12,29 +16,22 @@ Return a friendly, informative, helpful (in terms of agent possibilites) respons

**BUT** if a user starts a prompt with "hi! \<thing to do\>" 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

## 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
2 changes: 1 addition & 1 deletion src/utils/createAgent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AgentDefinition } from "@anthropic-ai/claude-agent-sdk"

export interface AgentConfig {
export interface AgentConfig extends Omit<AgentDefinition, "prompt"> {
description: string
prompt: () => Promise<string>
mcpServers?: string[]
Expand Down
4 changes: 4 additions & 0 deletions src/utils/runAgentLoop.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand Down