@iinm/plain-agent 1.14.1 → 1.14.2

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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Plain Agent
2
2
 
3
3
  [![CodeQL](https://github.com/iinm/plain-agent/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/iinm/plain-agent/actions/workflows/github-code-scanning/codeql)
4
- [![Socket Badge](https://badge.socket.dev/npm/package/@iinm/plain-agent/1.14.1)](https://socket.dev/npm/package/@iinm/plain-agent)
4
+ [![Socket Badge](https://badge.socket.dev/npm/package/@iinm/plain-agent/1.14.2)](https://socket.dev/npm/package/@iinm/plain-agent)
5
5
  [![install size](https://packagephobia.com/badge?p=@iinm/plain-agent)](https://packagephobia.com/result?p=@iinm/plain-agent)
6
6
 
7
7
  A lightweight terminal-based coding agent focused on safety and low token cost
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iinm/plain-agent",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "description": "A lightweight terminal-based coding agent focused on safety and low token cost",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/agentLoop.mjs CHANGED
@@ -109,6 +109,7 @@ export function createAgentLoop({
109
109
  let thinkingLoops = 0;
110
110
  const maxThinkingLoops = 5;
111
111
  let turnsAfterCompactPrompt = -1;
112
+ let turnsSinceSubagentReminder = 0;
112
113
  while (true) {
113
114
  // Check if auto-approve was paused by Ctrl-C during tool execution
114
115
  if (pauseSignal.isPaused()) {
@@ -262,6 +263,9 @@ export function createAgentLoop({
262
263
  stateManager.appendMessages([{ role: "user", content: toolResults }]);
263
264
  }
264
265
 
266
+ // Subagent reminder: every 5 turns, remind the model of its subagent role
267
+ let autoCompactFired = false;
268
+
265
269
  // Auto-compact: insert prompt if context exceeds soft limit
266
270
  if (contextSoftLimit && inputTokensKeys && providerTokenUsage) {
267
271
  const inputTokens = extractInputTokenCount(
@@ -286,6 +290,7 @@ export function createAgentLoop({
286
290
  },
287
291
  ]);
288
292
  turnsAfterCompactPrompt = 0;
293
+ autoCompactFired = true;
289
294
  console.error(
290
295
  styleText(
291
296
  "yellow",
@@ -295,6 +300,27 @@ export function createAgentLoop({
295
300
  }
296
301
  }
297
302
  }
303
+
304
+ if (!subagentManager.isSubagentActive()) {
305
+ turnsSinceSubagentReminder = 0;
306
+ } else if (!autoCompactFired) {
307
+ turnsSinceSubagentReminder += 1;
308
+ // Inject reminder every 5 turns (fires when counter reaches 5, 10, 15, ...)
309
+ if (turnsSinceSubagentReminder % 5 === 0) {
310
+ const activeSubagent = subagentManager.getActiveSubagent();
311
+ stateManager.appendMessages([
312
+ {
313
+ role: "user",
314
+ content: [
315
+ {
316
+ type: "text",
317
+ text: `System: You are subagent "${activeSubagent?.name}". Call "switch_to_main_agent" when your goal is done.`,
318
+ },
319
+ ],
320
+ },
321
+ ]);
322
+ }
323
+ }
298
324
  }
299
325
  }
300
326