From 529744c7c76992f6a978719097d125a7feab47f6 Mon Sep 17 00:00:00 2001 From: cat Date: Wed, 15 Jul 2026 16:38:09 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix(openai):=20=E4=BF=AE=E5=A4=8D=20Agent?= =?UTF-8?q?=20Identity=20=E5=AF=BC=E5=85=A5=E8=BF=87=E6=9C=9F=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ccount_codex_agent_identity_import_test.go | 36 +++++++++++++++++++ .../handler/admin/account_codex_import.go | 6 ++++ 2 files changed, 42 insertions(+) diff --git a/backend/internal/handler/admin/account_codex_agent_identity_import_test.go b/backend/internal/handler/admin/account_codex_agent_identity_import_test.go index db55182b6b..85d1a21f4a 100644 --- a/backend/internal/handler/admin/account_codex_agent_identity_import_test.go +++ b/backend/internal/handler/admin/account_codex_agent_identity_import_test.go @@ -1,6 +1,7 @@ package admin import ( + "context" "crypto/ed25519" "crypto/rand" "crypto/x509" @@ -45,3 +46,38 @@ func TestNormalizeCodexImportEntryAcceptsAgentIdentityAuthJSON(t *testing.T) { require.NotContains(t, item.Credentials, "refresh_token") require.NotEmpty(t, item.WarningTexts) } + +func TestImportCodexSessionsCreatesAgentIdentityWithoutOAuthExpiry(t *testing.T) { + _, privateKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + der, err := x509.MarshalPKCS8PrivateKey(privateKey) + require.NoError(t, err) + + svc := newCodexImportMemoryAdminService(nil) + handler := NewAccountHandler(svc, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + result, err := handler.importCodexSessions(context.Background(), CodexSessionImportRequest{ + SkipDefaultGroupBind: boolPtr(true), + }, []codexImportEntry{{ + Index: 1, + Value: map[string]any{ + "auth_mode": "agentIdentity", + "agent_identity": map[string]any{ + "agent_runtime_id": "runtime-import", + "agent_private_key": base64.StdEncoding.EncodeToString(der), + "task_id": "task-import", + "account_id": "account-import", + "chatgpt_user_id": "user-import", + }, + }, + }}) + require.NoError(t, err) + require.Equal(t, 1, result.Created) + require.Zero(t, result.Failed) + require.Len(t, svc.createdAccounts, 1) + created := svc.createdAccounts[0] + require.Nil(t, created.ExpiresAt) + require.Nil(t, created.AutoPauseOnExpired) + require.Equal(t, service.OpenAIAuthModeAgentIdentity, created.Credentials["auth_mode"]) + require.NotContains(t, created.Credentials, "access_token") + require.NotContains(t, created.Credentials, "refresh_token") +} diff --git a/backend/internal/handler/admin/account_codex_import.go b/backend/internal/handler/admin/account_codex_import.go index 57b97f8476..aa471494f1 100644 --- a/backend/internal/handler/admin/account_codex_import.go +++ b/backend/internal/handler/admin/account_codex_import.go @@ -774,6 +774,12 @@ func resolveCodexImportExpiry(req CodexSessionImportRequest, item *codexImportAc if item == nil { return nil, nil, nil, nil, errors.New("导入项为空") } + // Agent Identity has no OAuth access-token lifetime. Its runtime/task + // lifecycle is handled by the upstream task recovery path, so it must not + // be rejected or auto-paused by the OAuth import expiry policy. + if item.IsAgentIdentity { + return nil, nil, nil, nil, nil + } var requestExpiresAt *time.Time if req.ExpiresAt != nil && *req.ExpiresAt > 0 { From 3b5072187a9717660e22e8cdb579bae81c1f8750 Mon Sep 17 00:00:00 2001 From: cat Date: Wed, 15 Jul 2026 17:51:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(openai):=20=E5=A2=9E=E5=8A=A0=20Agent?= =?UTF-8?q?=20Identity=20=E7=8B=AC=E7=AB=8B=E5=AF=BC=E5=85=A5=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/account/CreateAccountModal.vue | 112 ++++++++++++++++-- .../account/OAuthAuthorizationFlow.vue | 16 ++- .../__tests__/CreateAccountModal.spec.ts | 40 +++++++ .../src/i18n/locales/en/admin/accounts.ts | 15 ++- .../src/i18n/locales/zh/admin/accounts.ts | 15 ++- 5 files changed, 173 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index 206c1f1494..e5b29be95c 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -296,7 +296,7 @@
-
+
+ + + + - - - -