Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Disable the selection of help mode by default #2184

Merged
merged 2 commits into from
Jan 13, 2025
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
6 changes: 5 additions & 1 deletion packages/cli/src/cmds/sequenceDiagram/browserRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export default class BrowserRenderer {
const puppeteer = require('puppeteer');

if (verbose()) console.warn(`Preparing browser for PNG rendering`);
this._browser = await puppeteer.launch({ timeout: 120 * 1000, headless: !this.showBrowser });
this._browser = await puppeteer.launch({
timeout: 120 * 1000,
headless: !this.showBrowser,
args: ['--no-sandbox'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up skipping the test that broke instead of disabling the sandbox. It's in main now, but feel free to replace it with this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ruby action is fixed as well. I'm not sure why these decided to break all of a sudden.

});
}
}
2 changes: 1 addition & 1 deletion packages/navie/src/agents/generate-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const GENERATE_AGENT_PROMPT = `**Task: Generation of Code**

Your name is Navie. You are code generation AI created and maintained by AppMap Inc, and are available to AppMap users as a service.

Your job is to generate code and test cases. Like a senior developer or architect, you have a deep understanding of the codebase.
Your job is to generate code. Like a senior developer or architect, you have a deep understanding of the codebase.

**About the user**

Expand Down
43 changes: 1 addition & 42 deletions packages/navie/src/services/agent-selection-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ type AgentModeResult = {
selectionMessage?: string;
};

const HELP_AGENT_SELECTED_MESSAGE = `It looks like you are asking for help using AppMap, so
I'm activating \`@help\` mode and basing my answer primarily on AppMap documentation. To disable this
behavior, re-ask your question and start with the option \`/nohelp\` or with a mode selector such as \`@explain\`.`;

const MODE_PREFIXES = {
'@explain ': AgentMode.Explain,
'@search ': AgentMode.Search,
Expand Down Expand Up @@ -126,49 +122,12 @@ export default class AgentSelectionService {
}
};

const classifierSelections: {
name: ContextV2.ContextLabelName;
mode: AgentMode;
disableOption?: string;
message?: string;
}[] = [
{
name: ContextV2.ContextLabelName.HelpWithAppMap,
mode: AgentMode.Help,
disableOption: 'help',
message: HELP_AGENT_SELECTED_MESSAGE,
},
];

const classifierMode = (): AgentModeResult | undefined => {
const classifierSelection = classifierSelections.find((selection) =>
classification.some(
(label) =>
label.name === selection.name &&
label.weight === ContextV2.ContextLabelWeight.High &&
(!selection.disableOption || userOptions.booleanValue(selection.disableOption, true))
)
);
if (classifierSelection) {
const { mode } = classifierSelection;
this.history.log(`[mode-selection] Activating agent due to classifier: ${mode}`);
const agent = buildAgent[mode]();
return {
agentMode: mode,
question,
agent,
selectedByClassifier: true,
selectionMessage: classifierSelection.message,
};
}
};

const defaultMode = () => {
this.history.log(`[mode-selection] Using default mode: ${AgentMode.Explain}`);
return { agentMode: AgentMode.Explain, question, agent: explainAgent() };
};

const result = questionPrefixMode() || classifierMode() || defaultMode();
const result = questionPrefixMode() || defaultMode();
this.history.addEvent(new AgentSelectionEvent(result.agentMode));
return result;
}
Expand Down
26 changes: 5 additions & 21 deletions packages/navie/test/services/agent-selection-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('AgentSelectionService', () => {
let fileChangeExtractorService: FileChangeExtractorService;
let techStackService: TechStackService;
let mermaidFixerService: MermaidFixerService;
let genericQuestion = 'How does user management work?';
let helpAgentQueston = '@help How to make a diagram?';
const genericQuestion = 'How does user management work?';
const helpAgentQueston = '@help How to make a diagram?';
const emptyUserOptions = new UserOptions(new Map());

function buildAgentSelectionService() {
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('AgentSelectionService', () => {
expect(agent).toBeInstanceOf(HelpAgent);
});
it('emits the agent selection event', () => {
const { agent } = invokeAgent();
invokeAgent();
expect(agentSelectionEvent()?.metadata).toEqual({
agent: 'help',
type: 'agentSelection',
Expand All @@ -82,7 +82,7 @@ describe('AgentSelectionService', () => {
});

describe('when the question is classified as help-with-appmap', () => {
it('creates a Help agent', () => {
it('creates an explain agent', () => {
const { agent } = buildAgentSelectionService().selectAgent(
genericQuestion,
[
Expand All @@ -93,23 +93,7 @@ describe('AgentSelectionService', () => {
],
emptyUserOptions
);
expect(agent).toBeInstanceOf(HelpAgent);
});

describe('but /nohelp is specified', () => {
it('creates an Explain agent', () => {
const { agent } = buildAgentSelectionService().selectAgent(
genericQuestion,
[
{
name: ContextV2.ContextLabelName.GenerateDiagram,
weight: ContextV2.ContextLabelWeight.High,
},
],
new UserOptions(new Map([['help', false]]))
);
expect(agent).toBeInstanceOf(ExplainAgent);
});
expect(agent).toBeInstanceOf(ExplainAgent);
});
});
});
Loading