[Bug][SuperAgent] A provider 429 posts the raw runtime error into the source chat, exposing the model id and request id
Summary
When a model turn fails, SuperAgent can reply to the conversation the input came from with the raw runtime error. In the case below the text contained the model id and the provider request id, and it was posted into a Lark group thread where the failed message was being handled. The failure was a provider-side 429 (TPM rate limit) that should have been treated as transient and reported to the owner only.
Checked against feat/vika at b9bbb0e309b23a297b92b1e7691c56bbf6cdff39.
What was posted
The bot posted this as a threaded reply to the message whose turn had failed (model id and request id redacted here; both were present in the group):
⚠️ 这一轮处理异常:pi stop: error: 429: {"code":"<provider-code>","message":"TPM (Tokens Per Minute) limit of the model <model-id> is exceeded. Please try again later Request id: <request-id>","param":"","type":"TooManyRequests"}
(消息不会自动重试;可再发一次,或用 /effort、/model 调整后重试)
The turn was not retried, and no owner-only notice was sent. notifyRuntimeFailure already exists for exactly this case and says "Runtime 处理失败,未向原用户暴露异常" — it was bypassed.
Why this error takes the "tell the conversation" path
pi.mjs:750turnsmessage_end.stopReason === 'error'intonew Error('pi stop: error: ' + errorMessage). The provider's 429 JSON survives only as message text; theErrorhas nostatus,codeor response body.classifyModelErrorreads structured fields throughhttpStatusOf. With a bareErrornone are found, and the message does not matchMODEL_UNAVAILABLE_TEXT, so it returns{ kind: null, retryable: false }.classifyRuntimeFailurefalls back to a prose regex. The provider saysTooManyRequests(no space) andTPM … limit … is exceeded, which does not matchtoo many requests,rate limitorquota exceeded. Result:{ blocked: false, recoverable: false }.onTurnFailedsends recoverable failures to the owner-onlynotifyRuntimeFailure; this one goes tonotifyTurnFailure, which interpolates the raw error into the notice (notices.mjs:305) and replies to the source conversation (notices.mjs:315).
So the owner-only boundary for runtime faults depends on a prose regex. Any provider wording it does not anticipate moves internal error text into the chat.
The second half of the problem is independent of classification: notifyTurnFailure is still the path for non-recoverable faults (auth, tool errors, etc.), and it always sends ${error} to the conversation. Even a correct 429 classification leaves that leak in place.
Reproduction
Unit level, with the exported classifier:
import { classifyRuntimeFailure } from './superagent/packages/daemon/src/notices.mjs';
const err = new Error(
'pi stop: error: 429: {"code":"<provider-code>",'
+ '"message":"TPM (Tokens Per Minute) limit of the model <model-id> is exceeded. '
+ 'Please try again later Request id: <request-id>","param":"","type":"TooManyRequests"}',
);
console.log(classifyRuntimeFailure(err));
// actual: { blocked: false, recoverable: false }
// expected for a 429: recoverable (owner-only notice, no chat reply)
End to end: configure the pi runtime against a provider that returns this 429 body (TPM limit), then send a message in a Lark group. The turn ends as failed and the notice above is threaded onto that message.
Existing coverage only exercises prose that matches the regex ('quota exceeded', '5-hour limit' — see notices.test.mjs "sends recoverable faults only to the owner" and "keeps a recoverable fault private when the runtime switch fails"), so this nested-JSON shape is not covered.
Suggested fix
- Never put raw runtime/provider text in a conversation. Send every turn or runtime failure diagnostic to the owner, as
notifyRuntimeFailurealready does; the source chat gets nothing or a fixed generic line with no model id, request id or provider payload. - Keep the provider error structured in the pi adapter. If
errorMessagecarries a status/code/type, attach them to theErrorinstead of flattening to a string, soclassifyModelErrorsees 429 and marks it transient. - Widen the prose fallback anyway (e.g.
TooManyRequests,TPM … limit … exceeded) and apply a redaction pass for request ids/model ids to any text bound for a chat. - Add a regression test with this nested-JSON 429 shape: owner is notified once, the source conversation stays untouched.
This issue reports the behavior only; no fix is included.
Relation to #7963
#7963 added the owner-only path (notifyRuntimeFailure), and it works for the failures its classifier recognizes. This report is not asking to redo that: the path is skipped here because the 429 is invisible to the classifier, and the non-recoverable path still pastes raw provider text into the conversation regardless of classification.