You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementations **should** use this table as the default `retryable` value for each error subclass. Callers may override the default on a per-instance basis.
3402
3464
3403
-
> **Note:** The following error codes are forward-declared for future features and do not yet have exception classes or retryability defaults: `GENERAL_NOT_IMPLEMENTED`, `DEPENDENCY_NOT_FOUND`, `MIDDLEWARE_CHAIN_ERROR`. Implementations **should** assign retryability defaults when the corresponding exception classes are introduced.
3465
+
> **Note:** The following error codes are forward-declared for future features and do not yet have exception classes or retryability defaults: `GENERAL_NOT_IMPLEMENTED`, `DEPENDENCY_NOT_FOUND`. Implementations **should** assign retryability defaults when the corresponding exception classes are introduced.
3404
3466
3405
3467
Retry middleware (if implemented) **should**:
3406
3468
- Only retry errors marked as retryable
@@ -3433,18 +3495,22 @@ ModuleError (base error for all framework errors)
Each error class carries a `code` attribute set to the corresponding error code string (e.g., `MODULE_NOT_FOUND`). Implementations **must** ensure all framework-thrown errors are instances of `ModuleError`. Module custom errors **should** also extend `ModuleError` directly.
> **NOTE:** The interface contracts above use the original theoretical names. See the mapping table in §10.3 for the actual extension point names used in SDK implementations (`discoverer`, `middleware`, `acl`, `span_exporter`, `module_validator`).
4099
+
> **NOTE:** The interface contracts above use the original theoretical names. See the mapping table in §11.3 for the actual extension point names used in SDK implementations (`discoverer`, `middleware`, `acl`, `span_exporter`, `module_validator`).
4034
4100
4035
4101
### 11.7 Extension Loading Order
4036
4102
@@ -4091,7 +4157,7 @@ Implementations **must** handle middleware edge cases according to the following
4091
4157
4092
4158
**Note**:
4093
4159
- Timeout timer should start at first `before()` call
4094
-
- Timeout enforcement algorithm see §11.7.4 and algorithms.md A22
4160
+
- Timeout enforcement algorithm see §12.7.4 and algorithms.md A22
@@ -4286,14 +4352,14 @@ All SDKs **MUST** export these event names as named constants (e.g., TypeScript:
4286
4352
4287
4353
#### Error Code Constants Export Requirement
4288
4354
4289
-
All SDKs **MUST** export the framework error codes defined in Section 7 as enumerated constants. This prevents magic string dependencies and enables IDE autocomplete.
4355
+
All SDKs **MUST** export the framework error codes defined in Section 8 as enumerated constants. This prevents magic string dependencies and enables IDE autocomplete.
This section defines apcore's concurrency model and thread safety requirements, ensuring SDK implementers correctly implement the framework in multi-threaded/coroutine environments.
4463
4529
4464
-
#### 11.7.1 Module Instance Lifecycle
4530
+
#### 12.7.1 Module Instance Lifecycle
4465
4531
4466
4532
**Singleton Model (MUST)**:
4467
4533
@@ -4506,7 +4572,7 @@ class CounterModule:
4506
4572
|`execute()`| 0..N times |**Multi-thread**| Business logic |
4507
4573
|`on_unload()`| 0..1 time | Single-thread | Resource cleanup |
Copy file name to clipboardExpand all lines: docs/api/executor-api.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -410,6 +410,27 @@ except ModuleError as e:
410
410
)
411
411
```
412
412
413
+
### 5.3 AI Error Guidance Fields
414
+
415
+
All `ModuleError` instances carry four optional guidance fields (see PROTOCOL_SPEC §8.1.1) that enable AI agents to programmatically understand and respond to errors without parsing human-readable messages:
416
+
417
+
| Field | Type | Purpose |
418
+
|-------|------|---------|
419
+
|`retryable`|`bool \| None`| Whether retrying the same call may succeed. Each error code has a default (see §8.6). `None` means "depends on context". |
420
+
|`ai_guidance`|`str \| None`| Machine-readable hint for AI agents, e.g. `"validate input schema before retry"`. |
421
+
|`user_fixable`|`bool \| None`| Whether the end-user (not developer) can fix the issue. |
422
+
|`suggestion`|`str \| None`| Actionable suggestion for resolving the error. |
423
+
424
+
Fields with `None` values are omitted from serialized output (sparse serialization).
425
+
426
+
```python
427
+
except SchemaValidationError as e:
428
+
print(e.retryable) # False (default for this error code)
429
+
print(e.user_fixable) # True — user can fix their input
430
+
print(e.suggestion) # "Table names must use only lowercase letters and underscores"
431
+
print(e.ai_guidance) # "validate input against schema before retry"
Copy file name to clipboardExpand all lines: docs/concepts.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ apcore organizes module metadata into a coherent lifecycle that guides an Agent
19
19
1.**Discovery (Identity) — `description`**: Helps the Agent find the right tool for its intent.
20
20
2.**Strategy (Wisdom) — `metadata`**: Teaches the Agent *when* and *how* to use the tool correctly (e.g., `x-when-to-use`, `x-common-mistakes`).
21
21
3.**Governance (Safety) — `requires_approval`**: Sets the safety boundary for sensitive operations.
22
-
4.**Recovery (Resilience) — `ai_guidance`**: Provides a clear path for the Agent to fix errors autonomously.
22
+
4.**Recovery (Resilience) — error guidance fields**: Every `ModuleError` carries optional fields that enable AI agents to recover autonomously: `retryable` (can the call be retried?), `ai_guidance` (machine-readable recovery hint), `user_fixable` (can the end-user fix it?), and `suggestion` (actionable fix). See PROTOCOL_SPEC §8.1.1.
23
23
24
24
---
25
25
@@ -384,6 +384,26 @@ class SendEmailModule(Module):
**Recommended AI Intent Metadata Keys** (PROTOCOL_SPEC §4.6):
388
+
389
+
The following `x-*` keys are conventions for guiding AI agents. They are not enforced by the framework but provide tactical wisdom in the Extension Layer:
390
+
391
+
| Key | Purpose | Example |
392
+
|-----|---------|---------|
393
+
| `x-when-to-use` | Scenarios where this module is the right choice | `"Use when the user wants to send transactional email"` |
394
+
| `x-when-not-to-use` | Scenarios where a different module should be used | `"Do not use for marketing/bulk emails"` |
395
+
| `x-common-mistakes` | Known pitfalls AI agents frequently encounter | `"Forgetting to set reply_to; passing HTML in plain text field"` |
396
+
| `x-workflow-hints` | Suggested pre/post steps or related modules | `"Call validate-email first to verify recipient exists"` |
397
+
398
+
```yaml
399
+
# In module metadata or schema x-* fields
400
+
metadata:
401
+
x-when-to-use: "Use when the user wants to send transactional email"
402
+
x-when-not-to-use: "Do not use for marketing/bulk emails"
403
+
x-common-mistakes: "Forgetting to set reply_to; passing HTML in plain text field"
404
+
x-workflow-hints: "Call validate-email first to verify recipient exists"
0 commit comments