@gajae-code/agent-core 0.12.21 → 0.13.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.
@@ -469,4 +469,9 @@ export declare class Agent {
469
469
  * Continue from current context (used for retries and resuming queued messages).
470
470
  */
471
471
  continue(options?: AgentPromptOptions): Promise<void>;
472
+ /**
473
+ * Continue by consuming queued steering/follow-up messages without replaying
474
+ * the current non-assistant tail.
475
+ */
476
+ continueQueuedMessages(options?: AgentPromptOptions): Promise<void>;
472
477
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/agent-core",
4
- "version": "0.12.21",
4
+ "version": "0.13.0",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -32,9 +32,9 @@
32
32
  "fmt": "biome format --write ."
33
33
  },
34
34
  "dependencies": {
35
- "@gajae-code/ai": "0.12.21",
36
- "@gajae-code/natives": "0.12.21",
37
- "@gajae-code/utils": "0.12.21",
35
+ "@gajae-code/ai": "0.13.0",
36
+ "@gajae-code/natives": "0.13.0",
37
+ "@gajae-code/utils": "0.13.0",
38
38
  "@opentelemetry/api": "^1.9.0"
39
39
  },
40
40
  "devDependencies": {
package/src/agent-loop.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  type Context,
11
11
  classifyContextOverflow,
12
12
  classifyFallbackTrigger,
13
+ EMPTY_RESPONSE_PROVIDER_CODE,
13
14
  EventStream,
14
15
  isZodSchema,
15
16
  streamSimple,
@@ -175,6 +176,23 @@ function managedRetryableFailure(failure: unknown): boolean {
175
176
  return trigger.class === "rate_limit" || trigger.class === "quota" || trigger.class === "server";
176
177
  }
177
178
 
179
+ function promoteTypedEmptyResponseStop(message: AssistantMessage): void {
180
+ if (
181
+ message.stopReason !== "stop" ||
182
+ message.content.length !== 0 ||
183
+ message.usage.input !== 0 ||
184
+ message.usage.output !== 0 ||
185
+ message.usage.cacheRead !== 0 ||
186
+ message.usage.cacheWrite !== 0 ||
187
+ message.usage.totalTokens !== 0 ||
188
+ managedTransportFailure(message)?.providerCode?.toLowerCase() !== EMPTY_RESPONSE_PROVIDER_CODE
189
+ ) {
190
+ return;
191
+ }
192
+ message.stopReason = "error";
193
+ message.errorMessage = "Provider returned an empty response with zero token usage";
194
+ }
195
+
178
196
  /**
179
197
  * Neutralize leaked reserved control tokens in-place across the outgoing
180
198
  * history so a re-send no longer carries the poison that triggered
@@ -2420,6 +2438,7 @@ async function streamAssistantResponse(
2420
2438
  const finalMessage = config.fallbackManaged
2421
2439
  ? managedAssistantShell(await finishResponse(), config.model)
2422
2440
  : await finishResponse();
2441
+ promoteTypedEmptyResponseStop(finalMessage);
2423
2442
  if (addedPartial) {
2424
2443
  context.messages[context.messages.length - 1] = finalMessage;
2425
2444
  } else {
package/src/agent.ts CHANGED
@@ -1428,6 +1428,26 @@ export class Agent {
1428
1428
 
1429
1429
  await this.#runLoop(undefined, options);
1430
1430
  }
1431
+ /**
1432
+ * Continue by consuming queued steering/follow-up messages without replaying
1433
+ * the current non-assistant tail.
1434
+ */
1435
+ async continueQueuedMessages(options?: AgentPromptOptions): Promise<void> {
1436
+ if (this.#state.isStreaming) {
1437
+ throw new AgentBusyError();
1438
+ }
1439
+ const queuedSteering = this.#dequeueSteeringMessages();
1440
+ if (queuedSteering.length > 0) {
1441
+ await this.#runLoop(queuedSteering, { ...options, skipInitialSteeringPoll: true });
1442
+ return;
1443
+ }
1444
+ const queuedFollowUp = this.#dequeueFollowUpMessages();
1445
+ if (queuedFollowUp.length > 0) {
1446
+ await this.#runLoop(queuedFollowUp, options);
1447
+ return;
1448
+ }
1449
+ throw new Error("No queued messages to continue");
1450
+ }
1431
1451
 
1432
1452
  /**
1433
1453
  * Run the agent loop.