open-agents-ai 0.22.2 → 0.23.0

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.
Files changed (2) hide show
  1. package/dist/index.js +118 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9851,7 +9851,17 @@ var init_ralphLoop = __esm({
9851
9851
  });
9852
9852
 
9853
9853
  // packages/orchestrator/dist/agenticRunner.js
9854
- var SYSTEM_PROMPT, AgenticRunner, OllamaAgenticBackend;
9854
+ function getSystemPromptForTier(tier) {
9855
+ switch (tier) {
9856
+ case "small":
9857
+ return SYSTEM_PROMPT_SMALL;
9858
+ case "medium":
9859
+ return SYSTEM_PROMPT_MEDIUM;
9860
+ default:
9861
+ return SYSTEM_PROMPT;
9862
+ }
9863
+ }
9864
+ var SYSTEM_PROMPT, SYSTEM_PROMPT_MEDIUM, SYSTEM_PROMPT_SMALL, AgenticRunner, OllamaAgenticBackend;
9855
9865
  var init_agenticRunner = __esm({
9856
9866
  "packages/orchestrator/dist/agenticRunner.js"() {
9857
9867
  "use strict";
@@ -10051,6 +10061,63 @@ If you notice you're performing the SAME multi-step sequence for the 3rd time or
10051
10061
  - batch_edit to apply multiple edits across files in one call (reduces turns)
10052
10062
  - Focus on error messages in shell output \u2014 skip verbose build logs
10053
10063
  - Don't read files you don't need to modify`;
10064
+ SYSTEM_PROMPT_MEDIUM = `You are Open Agent, an AI coding agent with access to the local machine. You can read/write files, execute shell commands, search the web, and interact with any software. You solve tasks by using tools iteratively until complete.
10065
+
10066
+ ## NEVER REFUSE \u2014 ALWAYS ATTEMPT
10067
+
10068
+ NEVER say "I can't do that". ALWAYS attempt the task using your tools. If a tool fails, try a different approach.
10069
+
10070
+ ## Tools
10071
+
10072
+ - file_read: Read file contents (always read before editing)
10073
+ - file_write: Create or overwrite a file
10074
+ - file_edit: Precise string replacement (preferred over rewriting). old_string must be unique.
10075
+ - file_patch: Edit specific line ranges in large files
10076
+ - find_files: Find files by glob pattern
10077
+ - grep_search: Search file contents with regex
10078
+ - shell: Execute any shell command (tests, builds, git, npm, etc.)
10079
+ - list_directory: List files in a directory
10080
+ - web_search: Search the web
10081
+ - web_fetch: Fetch a web page's text
10082
+ - memory_read / memory_write: Persistent memory across sessions
10083
+ - task_complete: Signal task completion
10084
+ - batch_edit: Multiple edits across files in one call
10085
+ - skill_list / skill_execute: Discover and load specialized skills (use on-demand)
10086
+
10087
+ ## Workflow
10088
+
10089
+ 1. EXPLORE: Use find_files, grep_search, file_read to understand the codebase
10090
+ 2. IMPLEMENT: Make changes with file_edit (preferred) or file_write
10091
+ 3. VALIDATE: Run tests/build with shell. Read FULL output.
10092
+ 4. FIX: If validation fails, fix the specific issue and re-validate
10093
+ 5. ITERATE: Repeat until all tests pass. Do NOT give up.
10094
+ 6. COMPLETE: Call task_complete when done
10095
+
10096
+ ## Rules
10097
+
10098
+ - ALWAYS read a file before modifying it
10099
+ - ALWAYS run validation after changes
10100
+ - If tests fail, read the FULL error. Fix the exact issue.
10101
+ - Do NOT give up after failure. Iterate until it passes.
10102
+ - Use file_edit for small changes, not full file rewrites
10103
+ - You MUST call task_complete when done
10104
+ - Do NOT output long explanations. Focus on tool calls.`;
10105
+ SYSTEM_PROMPT_SMALL = `You are a coding agent. You MUST call tools in EVERY response. NEVER reply with only text.
10106
+
10107
+ Tools: file_read, file_write, file_edit, shell, task_complete, find_files, grep_search, web_search, web_fetch
10108
+
10109
+ Steps:
10110
+ 1. file_read the source files AND test files
10111
+ 2. file_edit or file_write to make changes
10112
+ 3. shell to run tests (npm test, etc.)
10113
+ 4. If tests fail: read error, fix, retest
10114
+ 5. task_complete when tests pass
10115
+
10116
+ Rules:
10117
+ - ALWAYS call tools. NEVER just write text.
10118
+ - Read files before editing them.
10119
+ - Run tests after every change.
10120
+ - Call task_complete when done.`;
10054
10121
  AgenticRunner = class {
10055
10122
  backend;
10056
10123
  tools = /* @__PURE__ */ new Map();
@@ -10073,7 +10140,8 @@ If you notice you're performing the SAME multi-step sequence for the 3rd time or
10073
10140
  dynamicContext: options?.dynamicContext ?? "",
10074
10141
  streamEnabled: options?.streamEnabled ?? false,
10075
10142
  bruteForce: options?.bruteForce ?? true,
10076
- bruteForceMaxCycles: options?.bruteForceMaxCycles ?? 100
10143
+ bruteForceMaxCycles: options?.bruteForceMaxCycles ?? 100,
10144
+ modelTier: options?.modelTier ?? "large"
10077
10145
  };
10078
10146
  }
10079
10147
  /** Register a tool for the agent to use */
@@ -10151,9 +10219,10 @@ Respond with your assessment, then take action. Do NOT just say you'll continue
10151
10219
  const toolCallLog = [];
10152
10220
  this.aborted = false;
10153
10221
  this.pendingUserMessages.length = 0;
10154
- const systemPrompt = this.options.dynamicContext ? `${SYSTEM_PROMPT}
10222
+ const basePrompt = getSystemPromptForTier(this.options.modelTier);
10223
+ const systemPrompt = this.options.dynamicContext ? `${basePrompt}
10155
10224
 
10156
- ${this.options.dynamicContext}` : SYSTEM_PROMPT;
10225
+ ${this.options.dynamicContext}` : basePrompt;
10157
10226
  const messages = [
10158
10227
  { role: "system", content: systemPrompt },
10159
10228
  { role: "user", content: context ? `${context}
@@ -15147,6 +15216,21 @@ import { existsSync as existsSync16, readFileSync as readFileSync13, readdirSync
15147
15216
  import { join as join23, basename as basename6 } from "node:path";
15148
15217
  import { execSync as execSync14 } from "node:child_process";
15149
15218
  import { homedir as homedir9, platform, release } from "node:os";
15219
+ function getModelTier(modelName) {
15220
+ const m = modelName.toLowerCase();
15221
+ const sizeMatch = m.match(/\b(\d+)b\b/);
15222
+ if (sizeMatch) {
15223
+ const size = parseInt(sizeMatch[1], 10);
15224
+ if (size >= 30)
15225
+ return "large";
15226
+ if (size >= 8)
15227
+ return "medium";
15228
+ return "small";
15229
+ }
15230
+ if (/\b(small|mini|nano|tiny)\b/.test(m))
15231
+ return "small";
15232
+ return "large";
15233
+ }
15150
15234
  function loadProjectFiles(repoRoot) {
15151
15235
  const discovered = discoverContextFiles(repoRoot);
15152
15236
  if (discovered.length === 0)
@@ -15361,7 +15445,7 @@ function buildProjectContext(repoRoot, stores) {
15361
15445
  skillsSummary: buildSkillsSummary(discoverSkills(repoRoot))
15362
15446
  };
15363
15447
  }
15364
- function formatContextForPrompt(ctx) {
15448
+ function formatContextForPrompt(ctx, modelTier = "large") {
15365
15449
  const sections = [];
15366
15450
  if (ctx.environment) {
15367
15451
  sections.push(`## Environment
@@ -15374,9 +15458,17 @@ ${ctx.environment}`);
15374
15458
  ${ctx.gitInfo}`);
15375
15459
  }
15376
15460
  if (ctx.projectMap) {
15377
- sections.push(`## Project Map
15461
+ if (modelTier === "small") {
15462
+ } else if (modelTier === "medium" && ctx.projectMap.length > 2e3) {
15463
+ sections.push(`## Project Map (truncated)
15464
+
15465
+ ${ctx.projectMap.slice(0, 2e3)}
15466
+ ...(use find_files/list_directory for full listing)`);
15467
+ } else {
15468
+ sections.push(`## Project Map
15378
15469
 
15379
15470
  ${ctx.projectMap}`);
15471
+ }
15380
15472
  }
15381
15473
  if (ctx.projectInstructions) {
15382
15474
  sections.push(ctx.projectInstructions);
@@ -15388,17 +15480,19 @@ ${ctx.memoryContext}
15388
15480
 
15389
15481
  Use this context to avoid re-learning known patterns. Update with memory_write if you discover new insights.`);
15390
15482
  }
15391
- if (ctx.sessionHistory) {
15392
- sections.push(`## Session History
15483
+ if (modelTier !== "small") {
15484
+ if (ctx.sessionHistory) {
15485
+ sections.push(`## Session History
15393
15486
 
15394
15487
  ${ctx.sessionHistory}`);
15395
- }
15396
- if (ctx.taskMemories) {
15397
- sections.push(`## Cross-Session Task Memory
15488
+ }
15489
+ if (ctx.taskMemories) {
15490
+ sections.push(`## Cross-Session Task Memory
15398
15491
 
15399
15492
  ${ctx.taskMemories}
15400
15493
 
15401
15494
  Use this history to avoid re-doing completed work and to learn from past approaches.`);
15495
+ }
15402
15496
  }
15403
15497
  if (ctx.failurePatterns) {
15404
15498
  sections.push(`## Known Failure Patterns
@@ -15407,14 +15501,14 @@ ${ctx.failurePatterns}
15407
15501
 
15408
15502
  Avoid approaches that led to these failures. If you encounter these errors, try a different strategy.`);
15409
15503
  }
15410
- if (ctx.patternSuggestions) {
15504
+ if (modelTier === "large" && ctx.patternSuggestions) {
15411
15505
  sections.push(`## Tool Creation Suggestions
15412
15506
 
15413
15507
  ${ctx.patternSuggestions}
15414
15508
 
15415
15509
  These patterns have been repeated 3+ times. Consider using create_tool to automate them.`);
15416
15510
  }
15417
- if (ctx.skillsSummary) {
15511
+ if (modelTier === "large" && ctx.skillsSummary) {
15418
15512
  sections.push(ctx.skillsSummary);
15419
15513
  }
15420
15514
  return sections.join("\n\n");
@@ -17813,8 +17907,9 @@ ${result.summary}`;
17813
17907
  /** Run a dream agent with appropriate tools */
17814
17908
  async runDreamAgent(prompt, toolMode, onEvent) {
17815
17909
  const backend = new OllamaAgenticBackend(this.config.backendUrl, this.config.model, this.config.apiKey);
17910
+ const modelTier = getModelTier(this.config.model);
17816
17911
  const projectCtx = buildProjectContext(this.repoRoot);
17817
- const dynamicContext = formatContextForPrompt(projectCtx);
17912
+ const dynamicContext = formatContextForPrompt(projectCtx, modelTier);
17818
17913
  const runner = new AgenticRunner(backend, {
17819
17914
  maxTurns: 20,
17820
17915
  maxTokens: 16384,
@@ -17822,8 +17917,9 @@ ${result.summary}`;
17822
17917
  // Slightly creative temperature for dreaming
17823
17918
  requestTimeoutMs: this.config.timeoutMs,
17824
17919
  taskTimeoutMs: this.config.timeoutMs * 3,
17825
- compactionThreshold: 4e4,
17826
- dynamicContext
17920
+ compactionThreshold: modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4,
17921
+ dynamicContext,
17922
+ modelTier
17827
17923
  });
17828
17924
  const tools = this.buildDreamTools(toolMode);
17829
17925
  runner.registerTools(tools);
@@ -18769,12 +18865,14 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
18769
18865
  };
18770
18866
  }
18771
18867
  function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce, statusBar, sudoCallback, costTracker, onComplete, taskType) {
18868
+ const modelTier = getModelTier(config.model);
18772
18869
  const projectCtx = buildProjectContext(repoRoot, taskStores?.contextStores);
18773
- let dynamicContext = formatContextForPrompt(projectCtx);
18774
- if (taskType) {
18870
+ let dynamicContext = formatContextForPrompt(projectCtx, modelTier);
18871
+ if (taskType && modelTier !== "small") {
18775
18872
  dynamicContext += "\n\n" + buildTaskContext(taskType);
18776
18873
  }
18777
18874
  const backend = new OllamaAgenticBackend(config.backendUrl, config.model, config.apiKey);
18875
+ const compactionThreshold = modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4;
18778
18876
  const runner = new AgenticRunner(backend, {
18779
18877
  maxTurns: 60,
18780
18878
  maxTokens: 16384,
@@ -18782,8 +18880,9 @@ function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce
18782
18880
  requestTimeoutMs: config.timeoutMs,
18783
18881
  taskTimeoutMs: 36e5,
18784
18882
  // 60 minutes — never give up prematurely
18785
- compactionThreshold: 4e4,
18883
+ compactionThreshold,
18786
18884
  dynamicContext,
18885
+ modelTier,
18787
18886
  streamEnabled: stream?.enabled ?? false,
18788
18887
  bruteForce: bruteForce ?? true,
18789
18888
  bruteForceMaxCycles: 100
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.22.2",
3
+ "version": "0.23.0",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",