@caretakerai/agent 0.0.38-beta.1 → 0.0.38-beta.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.
Files changed (2) hide show
  1. package/dist/agent.js +13 -16
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -221,14 +221,9 @@ class Agent {
221
221
  const result = this.executor
222
222
  ? await this.executor(action.input)
223
223
  : await (0, graphql_1.graphql)({ schema: this.schema, source: action.input });
224
- // Add new observation to the iteration history
225
- outputHistory.push({
226
- kind: activity_1.ActivityKind.Observation,
227
- input: (0, yaml_1.stringify)(result),
228
- });
224
+ // Throw error if there are any errors and push the agent to retry generation
229
225
  if (result.errors) {
230
- retryErrors.push(...result.errors);
231
- break; // Stop executing further actions if one has errors
226
+ throw new AgentRetryError('Action error', result.errors.map(e => new Error(e.message))); // Stop executing further actions if one has errors
232
227
  }
233
228
  }
234
229
  catch (e) {
@@ -239,8 +234,14 @@ class Agent {
239
234
  });
240
235
  const message = `Retry ${i + 1} due to action error: ${err}`;
241
236
  this.logger.debug(message);
242
- retryErrors.push(err);
243
- break; // Stop executing further actions if one has errors
237
+ // Add errors to retry errors if they are not already present
238
+ if (err instanceof AgentRetryError) {
239
+ retryErrors.push(...err.errors);
240
+ }
241
+ else {
242
+ retryErrors.push(err);
243
+ }
244
+ throw err; // Stop executing further actions if one has errors
244
245
  }
245
246
  }
246
247
  }
@@ -251,13 +252,9 @@ class Agent {
251
252
  this.logger.debug(`Retry ${i + 1} due to malformed output: ${err.message}`);
252
253
  continue;
253
254
  }
254
- // If no action needs execution and last activity is not an action, finish iteration
255
- const finalHistory = [...history, ...outputHistory];
256
- if (finalHistory.at(-1)?.kind !== activity_1.ActivityKind.Action) {
257
- // Add iteration activities to the agent history and finish iteration
258
- this.addActivities(...outputHistory);
259
- return;
260
- }
255
+ // Add iteration activities to the agent history and finish iteration
256
+ this.addActivities(...outputHistory);
257
+ return;
261
258
  }
262
259
  throw new AgentRetryError('Max number of retries reached.', retryErrors);
263
260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caretakerai/agent",
3
- "version": "0.0.38-beta.1",
3
+ "version": "0.0.38-beta.2",
4
4
  "description": "Single framework for building text-agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",