@getmegabrain/cli 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,7 +22,18 @@ cells and everything runs locally on the user's machine. Use run_python to write
22
22
  code and iterate on its output, and search_literature to find and cite real papers (arXiv,
23
23
  OpenAlex, PubMed) when the task calls for surveying prior work. Prefer small, verifiable
24
24
  steps. When you have the answer, stop calling tools and give a concise final summary of
25
- what you did and found.`;
25
+ what you did and found.
26
+
27
+ Be proactive — act, don't stall. When a request is broad (e.g. "map the recent literature
28
+ of your subfield"), do NOT reply by asking the user to narrow it down. Infer a reasonable
29
+ scope from the project context below and immediately call search_literature (run several
30
+ focused queries if useful), then present what you found. Only ask a clarifying question
31
+ when you genuinely cannot proceed at all. "Your subfield", "your project", and similar
32
+ phrases refer to the project context below — not to you as an AI; you have no personal
33
+ research field, so interpret them as the project's topic.
34
+
35
+ You retain this session's full message history, so you DO remember earlier turns in this
36
+ conversation — never claim you have no memory of what was said earlier in the session.`;
26
37
  const MAX_TURNS = 16;
27
38
  export class AgentSession {
28
39
  model;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Builds the project-grounding context string injected into the agent's system prompt.
3
+ * Grounding broad tasks ("map the recent literature of your subfield") in the project's
4
+ * name/description and the researcher profile is what lets the agent resolve "your subfield"
5
+ * to a concrete topic instead of stalling to ask the user.
6
+ */
7
+ export function buildAgentContext(input) {
8
+ const clean = (v) => (v ?? '').trim();
9
+ const name = clean(input.projectName);
10
+ const description = clean(input.projectDescription);
11
+ const context = clean(input.agentContext);
12
+ const profile = clean(input.profile);
13
+ return [
14
+ name ? `Project: ${name}` : '',
15
+ description ? `Project description: ${description}` : '',
16
+ context,
17
+ profile ? `Researcher profile: ${profile}` : '',
18
+ ]
19
+ .filter(Boolean)
20
+ .join('\n');
21
+ }
@@ -9,6 +9,7 @@ import { homePage, loginPage, nonceInvalidPage, nonceLandingPage, projectPage, s
9
9
  import { FEATURED_CONNECTORS, NETWORK_CATEGORIES, WorkspaceStore } from './store.js';
10
10
  import { KernelManager } from './kernel.js';
11
11
  import { AgentSession, pythonTool } from './agent/agent.js';
12
+ import { buildAgentContext } from './agent/context.js';
12
13
  import { ArxivClient, literatureTool, MultiSourceClient } from './agent/literature.js';
13
14
  import { OpenAlexClient } from './agent/openalex.js';
14
15
  import { PubMedClient } from './agent/pubmed.js';
@@ -286,10 +287,18 @@ export async function startScienceServer(host = '127.0.0.1') {
286
287
  const session = store.getSession(sid);
287
288
  const project = session ? store.getProject(session.projectId) : null;
288
289
  store.touchSession(sid, session && !session.summary ? { summary: prompt } : undefined);
290
+ // Ground the agent in the project + researcher profile so broad tasks like
291
+ // "map the recent literature of your subfield" resolve to a concrete topic.
292
+ const agentContext = buildAgentContext({
293
+ projectName: project?.name,
294
+ projectDescription: project?.description,
295
+ agentContext: project?.agentContext,
296
+ profile: store.getSettings().profile,
297
+ });
289
298
  const agent = new AgentSession(new GatewayModel({ apiKey: token, model }), [
290
299
  pythonTool(kernels.get(sid)),
291
300
  literatureTool(new MultiSourceClient([new ArxivClient(), new OpenAlexClient(), new PubMedClient()])),
292
- ], evt => fanout(sid, 'agent', evt), project?.agentContext ?? '', store.getMessages(sid));
301
+ ], evt => fanout(sid, 'agent', evt), agentContext, store.getMessages(sid));
293
302
  try {
294
303
  await agent.run(prompt);
295
304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getmegabrain/cli",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "MegaBrain CLI — sign in once, then code from your terminal via OpenCode wired to the MegaBrain Gateway, or run `megabrain science` for the local research workbench.",
5
5
  "license": "MIT",
6
6
  "type": "module",