Skip to content

Commit 66d0cf1

Browse files
committed
fix(codex): 扩展线程限流错误兼容
将 Codex 的 rateLimitExceeded 兼容范围扩展至读取、恢复和回滚线程响应。 同步生成器规则与生成 schema,并新增三类响应的回归断言。 验证:schema 测试 3/3、effect-codex-app-server typecheck、格式检查通过。
1 parent e233527 commit 66d0cf1

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎packages/effect-codex-app-server/scripts/generate.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ function applyCodex0151DefinitionCompatibility(
199199
definitionName: string,
200200
definitionSchema: Schema.Json,
201201
): Schema.Json {
202+
const isThreadResponse =
203+
exportName === "V2ThreadReadResponse" ||
204+
exportName === "V2ThreadResumeResponse" ||
205+
exportName === "V2ThreadRollbackResponse";
202206
if (
203-
exportName !== "V2ThreadResumeResponse" ||
207+
!isThreadResponse ||
204208
definitionName !== "CodexErrorInfo" ||
205209
typeof definitionSchema !== "object"
206210
) {

‎packages/effect-codex-app-server/src/_generated/schema.gen.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16851,6 +16851,7 @@ export type V2ThreadReadResponse__CodexErrorInfo =
1685116851
| "badRequest"
1685216852
| "threadRollbackFailed"
1685316853
| "sandboxError"
16854+
| "rateLimitExceeded"
1685416855
| "other"
1685516856
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
1685616857
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -16874,6 +16875,7 @@ export const V2ThreadReadResponse__CodexErrorInfo = Schema.Union(
1687416875
"badRequest",
1687516876
"threadRollbackFailed",
1687616877
"sandboxError",
16878+
"rateLimitExceeded",
1687716879
"other",
1687816880
]),
1687916881
Schema.Struct({
@@ -17484,6 +17486,7 @@ export type V2ThreadRollbackResponse__CodexErrorInfo =
1748417486
| "badRequest"
1748517487
| "threadRollbackFailed"
1748617488
| "sandboxError"
17489+
| "rateLimitExceeded"
1748717490
| "other"
1748817491
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
1748917492
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -17507,6 +17510,7 @@ export const V2ThreadRollbackResponse__CodexErrorInfo = Schema.Union(
1750717510
"badRequest",
1750817511
"threadRollbackFailed",
1750917512
"sandboxError",
17513+
"rateLimitExceeded",
1751017514
"other",
1751117515
]),
1751217516
Schema.Struct({

‎packages/effect-codex-app-server/src/schema.test.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ it("accepts Codex 0.150 multi-agent values", () => {
7474
assert.equal(Schema.is(CodexSchema.V2ThreadResumeResponse)(resumeResponse), true);
7575
});
7676

77-
it("accepts Codex rate limit errors when resuming a thread", () => {
78-
assert.equal(
79-
Schema.is(CodexSchema.V2ThreadResumeResponse__CodexErrorInfo)("rateLimitExceeded"),
80-
true,
81-
);
77+
it("accepts Codex rate limit errors for thread responses", () => {
78+
const schemas = [
79+
CodexSchema.V2ThreadReadResponse__CodexErrorInfo,
80+
CodexSchema.V2ThreadResumeResponse__CodexErrorInfo,
81+
CodexSchema.V2ThreadRollbackResponse__CodexErrorInfo,
82+
];
83+
84+
for (const schema of schemas) {
85+
assert.equal(Schema.is(schema)("rateLimitExceeded"), true);
86+
}
8287
});
8388

8489
it("accepts Codex 0.150 account plan values", () => {

0 commit comments

Comments
 (0)