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
fix(api): fix addon invocation completion and rate limit UX (#113)
- Auto-complete invocations by default (opt-in to async with X-TMI-Callback header)
- Increase default max active invocations from 1 to 3
- Add detailed 429 response with blocking invocation info and Retry-After header
- Auto-infer server base URL for callback URLs if not configured
- Update addon and webhook documentation
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
suggestion:=fmt.Sprintf("Wait for an existing invocation to complete, or retry after %d seconds when the oldest will timeout.", retryAfter)
84
+
56
85
return&RequestError{
57
86
Status: 429,
58
87
Code: "rate_limit_exceeded",
59
-
Message: fmt.Sprintf("You already have an active add-on invocation. Please wait for it to complete. (Limit: %d concurrent invocation)", quota.MaxActiveInvocations),
Copy file name to clipboardExpand all lines: docs/developer/addons/addon-development-guide.md
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,12 +162,42 @@ def handle_invocation():
162
162
task_queue.enqueue(process_invocation, payload)
163
163
164
164
# Respond immediately
165
-
return'', 200# TMI marks as in_progress
165
+
return'', 200# TMI auto-completes the invocation
166
166
```
167
167
168
-
### Step 4: Update Status During Processing
168
+
### Callback Modes
169
169
170
-
Call back to TMI to update progress:
170
+
TMI supports two callback modes, controlled by the `X-TMI-Callback` response header:
171
+
172
+
**Auto-Complete Mode (Default)**
173
+
174
+
When your webhook returns a 2xx response without the `X-TMI-Callback` header (or with any value other than `async`), TMI automatically marks the invocation as `completed`. Use this mode when:
When your webhook returns the `X-TMI-Callback: async` header, TMI marks the invocation as `in_progress` and expects your service to call back with status updates. Use this mode when:
187
+
- Your processing takes significant time
188
+
- You want to report progress percentages
189
+
- You need to report success or failure after processing
190
+
191
+
```python
192
+
# Async callback mode - you must call back with status updates
193
+
return'', 200, {'X-TMI-Callback': 'async'}
194
+
```
195
+
196
+
**Important:** If you use async mode but never call back, the invocation will timeout after 15 minutes of inactivity and be marked as `failed`.
197
+
198
+
### Step 4: Update Status During Processing (Async Mode Only)
199
+
200
+
If using async callback mode, call back to TMI to update progress:
0 commit comments