{"_id":"@agentxin-ai/plugin-model-retry","name":"@agentxin-ai/plugin-model-retry","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.5":{"name":"@agentxin-ai/plugin-model-retry","version":"0.0.5","author":{"name":"AgentXinAI","url":"https://agentxinai.cn"},"license":"AGPL-3.0","repository":{"type":"git","url":"git+https://github.com/agentxin-ai/agentxin-plugins.git"},"bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"@agentxin-plugins-starter/source":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"dependencies":{"tslib":"^2.3.0"},"peerDependencies":{"zod":"3.25.67","@agentxin-ai/plugin-sdk":"^3.8.1","chalk":"4.1.2","@nestjs/common":"^11.1.6","@nestjs/cqrs":"^11.0.3","@metad/contracts":"^3.8.1","@langchain/core":"0.3.72"},"_id":"@agentxin-ai/plugin-model-retry@0.0.5","description":"`@agentxin-ai/plugin-model-retry` adds retry logic around AgentXin agent model calls. It keeps LangChain-style retry semantics while exposing only JSON-serializable configuration that can be edited in the AgentXin middleware UI.","homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-V1/K1BEcVOYzpntXoB9/HuWvNuStuYuzXWgSPQ/ZjqKqeoMnkZU8G8ZZkDDi+aQcQu4F4tuFe4HXeImHk4Q6Qg==","shasum":"be180b6655534429a94ac014086f7d29720ce444","tarball":"https://registry.npmjs.org/@agentxin-ai/plugin-model-retry/-/plugin-model-retry-0.0.5.tgz","fileCount":2,"unpackedSize":5169,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCHv4eyBbQnmkbjlsvHJYPUIeARKLl/3DiTuk208916HwIhAN7IO2++imp44amF+VY2HwwvS4+XSQntuk7y4KFgQ4T7"}]},"_npmUser":{"name":"agentxin-ai","email":"1304040880@qq.com"},"directories":{},"maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-model-retry_0.0.5_1773917381641_0.28823642968747465"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-19T10:49:41.534Z","0.0.5":"2026-03-19T10:49:41.773Z","modified":"2026-03-19T10:49:41.994Z"},"maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"description":"`@agentxin-ai/plugin-model-retry` adds retry logic around AgentXin agent model calls. It keeps LangChain-style retry semantics while exposing only JSON-serializable configuration that can be edited in the AgentXin middleware UI.","homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","repository":{"type":"git","url":"git+https://github.com/agentxin-ai/agentxin-plugins.git"},"author":{"name":"AgentXinAI","url":"https://agentxinai.cn"},"bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"license":"AGPL-3.0","readme":"# AgentXin Plugin: Model Retry Middleware\n\n`@agentxin-ai/plugin-model-retry` adds retry logic around AgentXin agent model calls. It keeps LangChain-style retry semantics while exposing only JSON-serializable configuration that can be edited in the AgentXin middleware UI.\n\n## Key Features\n\n- Retries failed model calls with configurable retry count, exponential backoff, max delay, and optional jitter.\n- Supports platform-safe retry matching by error name, HTTP status code, and message substring.\n- Returns an `AIMessage` when retries are exhausted in `continue` mode, or rethrows the last error in `error` mode.\n- Wraps retry attempts with `WrapWorkflowNodeExecutionCommand` so middleware-level execution tracking remains visible in AgentXin.\n- Registers as a global middleware plugin so the strategy is available across the platform.\n- Treats `AIMessage.response_metadata.finish_reason === \"network_error\"` as a retryable model failure, even when the provider returns a message instead of throwing.\n- Treats empty `AIMessage` results with no `tool_calls` and no `invalid_tool_calls` as retryable model failures.\n\n## Installation\n\n```bash\npnpm add @agentxin-ai/plugin-model-retry\n# or\nnpm install @agentxin-ai/plugin-model-retry\n```\n\n## Quick Start\n\n1. Register the plugin:\n   ```sh\n   PLUGINS=@agentxin-ai/plugin-model-retry\n   ```\n2. Add a middleware entry using strategy `ModelRetryMiddleware`.\n3. Configure retries:\n   ```json\n   {\n     \"type\": \"ModelRetryMiddleware\",\n     \"options\": {\n       \"maxRetries\": 2,\n       \"initialDelayMs\": 1000,\n       \"backoffFactor\": 2,\n       \"maxDelayMs\": 60000,\n       \"jitter\": true,\n       \"retryAllErrors\": false,\n       \"retryableErrorNames\": [\"RateLimitError\"],\n       \"retryableStatusCodes\": [429, 503],\n       \"retryableMessageIncludes\": [\"timeout\", \"temporarily unavailable\"],\n       \"onFailure\": \"continue\"\n     }\n   }\n   ```\n\n## Configuration\n\n| Field | Type | Description | Default |\n| ----- | ---- | ----------- | ------- |\n| `maxRetries` | number | Number of retry attempts after the initial failure. `0` disables retries. | `2` |\n| `initialDelayMs` | number | Delay before the first retry attempt, in milliseconds. | `1000` |\n| `backoffFactor` | number | Exponential multiplier applied per retry attempt. `0` keeps a constant delay. | `2` |\n| `maxDelayMs` | number | Upper bound for the computed retry delay. | `60000` |\n| `jitter` | boolean | Adds a bounded random factor to each delay to reduce synchronized retries. | `true` |\n| `retryAllErrors` | boolean | Retry every thrown error when `true`. | `true` |\n| `retryableErrorNames` | string[] | Retry only matching `error.name` values when `retryAllErrors=false`. | `[]` |\n| `retryableStatusCodes` | number[] | Retry matching HTTP-style status codes from `status`, `statusCode`, or `response.status`. | `[]` |\n| `retryableMessageIncludes` | string[] | Retry when the error message contains any configured fragment. Matching is case-insensitive. | `[]` |\n| `onFailure` | `\"continue\"` \\| `\"error\"` | Return an `AIMessage` or rethrow after retries are exhausted. | `\"continue\"` |\n\n## LangChain Differences\n\n- Function-based `retryOn` and `onFailure` are intentionally not supported because AgentXin middleware configuration must remain serializable.\n- Retry matching uses declarative JSON fields instead of runtime classes or callback functions.\n- Retry attempts are execution-tracked with AgentXin workflow commands, but no model client is recreated during retries.\n- Provider responses that finish with `network_error` are normalized into an internal `ModelNetworkError` and routed through the same retry policy.\n- Provider responses with empty content and no tool call payload are normalized into an internal `ModelEmptyResponseError` and routed through the same retry policy.\n\n## Development & Testing\n\n```bash\nNX_DAEMON=false pnpm -C /path/to/agentxin-plugins/agentxinai exec nx build @agentxin-ai/plugin-model-retry\nNX_DAEMON=false pnpm -C /path/to/agentxin-plugins/agentxinai exec nx test @agentxin-ai/plugin-model-retry\n```\n\nTypeScript output is emitted to `middlewares/model-retry/dist`.\n","readmeFilename":"README.md","_rev":"1-e2d362c5bfd3c8c27ff45ed658d8e757"}