@agentxin-ai/plugin-tool-retry 0.0.4

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/README.md +77 -0
  2. package/package.json +44 -0
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # AgentXin Plugin: Tool Retry Middleware
2
+
3
+ `@agentxin-ai/plugin-tool-retry` retries failed tool executions for AgentXin agents using JSON-serializable middleware configuration. It preserves the core LangChain retry behavior while fitting AgentXin's UI-driven plugin model.
4
+
5
+ ## Key Features
6
+
7
+ - Retries tool failures with configurable retry count, exponential backoff, bounded jitter, and declarative error matching.
8
+ - Can target all tools or only a configured set of tool names.
9
+ - Returns a `ToolMessage` with `status: "error"` in `continue` mode so the agent can react gracefully.
10
+ - Rethrows the last error in `error` mode after retries are exhausted.
11
+ - Registers as a global middleware plugin so the strategy is available platform-wide.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add @agentxin-ai/plugin-tool-retry
17
+ # or
18
+ npm install @agentxin-ai/plugin-tool-retry
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ 1. Register the plugin:
24
+ ```sh
25
+ PLUGINS=@agentxin-ai/plugin-tool-retry
26
+ ```
27
+ 2. Add a middleware entry using strategy `ToolRetryMiddleware`.
28
+ 3. Configure retries:
29
+ ```json
30
+ {
31
+ "type": "ToolRetryMiddleware",
32
+ "options": {
33
+ "toolNames": ["search_database", "query_sales_report"],
34
+ "maxRetries": 2,
35
+ "initialDelayMs": 1000,
36
+ "backoffFactor": 2,
37
+ "maxDelayMs": 60000,
38
+ "jitter": true,
39
+ "retryAllErrors": false,
40
+ "retryableErrorNames": ["TimeoutError"],
41
+ "retryableStatusCodes": [500, 503],
42
+ "retryableMessageIncludes": ["temporarily unavailable"],
43
+ "onFailure": "continue"
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Configuration
49
+
50
+ | Field | Type | Description | Default |
51
+ | ----- | ---- | ----------- | ------- |
52
+ | `toolNames` | string[] | Tool names to retry. Empty means all tools. | `[]` |
53
+ | `maxRetries` | number | Number of retry attempts after the initial failure. `0` disables retries. | `2` |
54
+ | `initialDelayMs` | number | Delay before the first retry attempt, in milliseconds. | `1000` |
55
+ | `backoffFactor` | number | Exponential multiplier applied per retry attempt. `0` keeps a constant delay. | `2` |
56
+ | `maxDelayMs` | number | Upper bound for the computed retry delay. | `60000` |
57
+ | `jitter` | boolean | Adds a bounded random factor to each delay to reduce synchronized retries. | `true` |
58
+ | `retryAllErrors` | boolean | Retry every thrown error when `true`. | `true` |
59
+ | `retryableErrorNames` | string[] | Retry only matching `error.name` values when `retryAllErrors=false`. | `[]` |
60
+ | `retryableStatusCodes` | number[] | Retry matching HTTP-style status codes from `status`, `statusCode`, or `response.status`. | `[]` |
61
+ | `retryableMessageIncludes` | string[] | Retry when the error message contains any configured fragment. Matching is case-insensitive. | `[]` |
62
+ | `onFailure` | `"continue"` \| `"error"` | Return a `ToolMessage` or rethrow after retries are exhausted. | `"continue"` |
63
+
64
+ ## LangChain Differences
65
+
66
+ - Function-based `retryOn`, function-based `onFailure`, and BaseTool instance filtering are not supported in v1.
67
+ - Tool selection is done with plain tool-name strings so middleware configuration stays serializable.
68
+ - Retry attempts directly re-invoke the tool handler; no extra workflow execution wrapper is added because the SDK does not expose a tool-attempt tracking primitive.
69
+
70
+ ## Development & Testing
71
+
72
+ ```bash
73
+ NX_DAEMON=false pnpm -C /path/to/agentxin-plugins/agentxinai exec nx build @agentxin-ai/plugin-tool-retry
74
+ NX_DAEMON=false pnpm -C /path/to/agentxin-plugins/agentxinai exec nx test @agentxin-ai/plugin-tool-retry
75
+ ```
76
+
77
+ TypeScript output is emitted to `middlewares/tool-retry/dist`.
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@agentxin-ai/plugin-tool-retry",
3
+ "version": "0.0.4",
4
+ "author": {
5
+ "name": "AgentXinAI",
6
+ "url": "https://agentxinai.cn"
7
+ },
8
+ "license": "AGPL-3.0",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/agentxin-ai/agentxin-plugins.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/agentxin-ai/agentxin-plugins/issues"
15
+ },
16
+ "type": "module",
17
+ "main": "./dist/index.js",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ "./package.json": "./package.json",
22
+ ".": {
23
+ "@agentxin-plugins-starter/source": "./src/index.ts",
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "!**/*.tsbuildinfo"
32
+ ],
33
+ "dependencies": {
34
+ "tslib": "^2.3.0"
35
+ },
36
+ "peerDependencies": {
37
+ "zod": "3.25.67",
38
+ "@agentxin-ai/plugin-sdk": "^3.8.0",
39
+ "chalk": "4.1.2",
40
+ "@nestjs/common": "^11.1.6",
41
+ "@metad/contracts": "^3.8.0",
42
+ "@langchain/core": "0.3.72"
43
+ }
44
+ }