Skip to content

Kiro second account disappears shortly after successful login #4435

Closed

Description

@ren-min-wan-sui

Client or integration

OpenCodex dashboard

Area

Authentication and account pool

Summary

When adding a second Kiro account through the OpenCodex dashboard, the login succeeds and both Kiro accounts briefly appear.

However, after a few seconds, the newly added account disappears and only the original Kiro account remains.

I later verified the persisted state separately: ocx account list kiro --quota shows only the original account, and ~/.opencodex/auth.json also contains only that account, so this does not appear to be only a dashboard display issue.

I expected both Kiro accounts to remain in the account pool, since they have different profileArn values.

This is reproducible on OpenCodex 2.52.0.

Reproduction

  1. Open the OpenCodex dashboard.

  2. Make sure one Kiro account/provider is already configured and working.

  3. Add another Kiro account/provider through the dashboard.

  4. The second account is added successfully and may briefly appear alongside the first one.

  5. After a short time, the newly added account disappears, and only the original Kiro account remains.

  6. Repeating the process produces the same behavior: adding another Kiro account effectively replaces or gets overwritten by the existing account instead of keeping both accounts in the account pool.

I later verified the persisted state separately and found that ~/.opencodex/auth.json also ends up containing only one Kiro account, so this does not appear to be only a dashboard display issue.

Version

2.52.0

Operating system

macOS 27.0 (Apple Silicon, M5 MacBook Pro)

Provider and model

Kiro — multi-account authentication/account pool (model not applicable)

Logs or error output

OAuth refresh started provider=kiro
OAuth credentials rotated and persisted provider=kiro

These messages were observed during later troubleshooting around the time the second Kiro account disappeared. The original issue was reproduced through the OpenCodex dashboard without any CLI commands.

Error: A login for kiro is already in progress

This error occurred during an earlier Kiro login attempt and may or may not be related.

Screenshots and supporting files

No response

Redacted configuration

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    bug
    on Sep 12, 2026
  2. added
    account-pool
    on Sep 12, 2026
  3. lidge-jun commented on Sep 12, 2026

    @lidge-jun
    Owner

    리뷰 · 우선순위 64 / 80

    설명
    이 이슈는 OpenCodex 대시보드에서 Kiro 계정을 두 번째로 추가하면, 로그인은 성공한 것처럼 보이고 잠깐 두 계정이 함께 보이는데, 몇 초 뒤에 새로 추가한 쪽만 사라지고 원래 Kiro 계정만 남는다는 버그다. 보고자는 화면만의 깜빡임이 아니라고 따로 확인했다. ocx account list kiro --quota와 ~/.opencodex/auth.json 둘 다 결국 계정 하나만 남는다. 기대는 서로 다른 profileArn이면 account pool에 둘 다 남는 것이다. 재현 환경은 OpenCodex 2.52.0, macOS Apple Silicon이다.

    지금 dev HEAD(dcd13b435, package 2.53.0) 기준으로 Kiro는 “한 슬롯만 되는 프로바이더”가 아니다. src/oauth/store.ts의 SINGLE_SLOT_PROVIDERS에는 chatgpt만 들어 있고, Kiro는 multi-account 경로를 탄다. 대시보드에서 “계정 추가”는 src/server/management/oauth-account-routes.ts가 addAccount: true(또는 reauth)일 때 forceLogin: true를 넘긴다. 그러면 src/oauth/index.ts의 runLogin이 saveCredential(..., { preserveIdentityless: true })로 저장하고, src/oauth/kiro.ts의 loginKiro({ forceLogin: true })는 kiro-cli를 logout→login으로 한 번 갈아 끼운 뒤 새 세션을 import한다. 주석도 “Account-add login deliberately asks kiro-cli to switch identities”라고 적혀 있다. 즉 설계 의도상 두 번째 Kiro 계정은 붙어야 한다.

    슬롯을 구분하는 열쇠는 saveCredential이 쓰는 신원(accountId ?? email)이다. Kiro import 경로(oauthCredentialFromImported)는 SQLite/whoami에서 잡은 profileArn을 accountId로 넣고, 이메일이 있으면 email도 넣는다. Builder ID용 고정 ARN(src/adapters/kiro-constants.ts의 KIRO_BUILDER_ID_SERVICE_PROFILE_ARN)은 요청에만 쓰고, 계정 신원·KiroOAuthMetadata에는 넣지 말라고 코드가 못 박아 두었다. 그래서 보고자가 말한 “서로 다른 profileArn이면 둘 다 남아야 한다”는 현재 dev 모델과 같다. 그런데도 auth.json에 하나뿐이면, UI 버그가 아니라 저장·신원 매칭·강제 로그인 정산·리프레시 중 어딘가에서 새 슬롯이 덮이거나 롤백되는 쪽을 먼저 봐야 한다.

    이슈에 적힌 로그도 그 축과 맞는다. OAuth refresh started provider=kiro / OAuth credentials rotated and persisted provider=kiro는 src/oauth/index.ts refreshGenericAccountWithLock이 해당 accountId 슬롯만 mergeAccountCredential로 갱신할 때 찍힌다. 정상 경로라면 다른 슬롯을 지우면 안 된다. 반대로 A login for kiro is already in progress는 같은 파일의 kiroLoginSettling 가드다. 강제 로그인 직후·정산 중에 또 로그인을 겹치면 이런 메시지가 난다. 또한 Kiro CLI 쪽 세션은 기기당 사실상 하나라, add-account가 CLI를 새 신원으로 바꾼 뒤 예전 슬롯 리프레시가 400을 맞고 matchingRotatedKiroCliCredential로 CLI의 새 토큰을 잘못 붙잡는 경우도 이론상 있다(신원 profileArn/accountId가 일치할 때만 허용). 2.52.0 → 현재 dev 2.53.0 사이에 이 증상을 정면으로 고친 Kiro multi-account 커밋은 보이지 않으므로, 현재 HEAD에서도 열린 버그로 취급하는 편이 맞다. 지금 dev 핫 열차(Muse OAuth, Devin effort/WS, quota-avoid, credits 문서)와 파일은 겹치지만, account-pool 라벨 실사용 버그라 우선순위는 중상이다.

    경로 src/server/management/oauth-account-routes.ts addAccount/reauth → forceLogin - 대시보드 “두 번째 계정 추가”가 실제로 강제 로그인 분기를 타는지부터 재현 로그로 확인해야 한다. forceLogin 없이 import-only로 들어가면 CLI에 남은 세션만 다시 읽어 활성 슬롯을 갱신하는 쪽으로 기울 수 있다.
    경로 src/oauth/kiro.ts loginKiro / oauthCredentialFromImported / bindMatchingLegacyIdentitylessKiroAccounts - 새 슬롯의 accountId(profileArn)와 email이 첫 슬롯과 겹치면 saveCredential이 append가 아니라 같은 신원 upsert가 된다. whoami 레이스(세션 토큰 불일치 시 identity 비움)와 legacy identity-less 바인딩이 재현에 끼는지 봐야 한다.
    경로 src/oauth/store.ts saveCredential / mergeAccountCredential / mutateStore - 신원 있는 append vs 신원 없는 active 교체 vs 세대 안전 merge. auth.json에 계정이 하나뿐이면 UI가 아니라 이 계층의 최종 persist 결과를 증거로 삼아야 한다.
    경로 src/oauth/index.ts runLogin + rollbackForcedKiroAccountWrite + settleKiroLoginTransaction + kiroLoginSettling - 강제 로그인 실패 시에만 새 슬롯을 걷어 내고, 성공 시 CLI recovery를 버린다. “잠깐 두 개 → 곧 하나”가 낙관적 UI 후 실패 롤백인지, 성공 persist 후 다른 쓰기인지 타임라인으로 가른다.
    경로 src/oauth/kiro.ts refreshKiroToken / matchingRotatedKiroCliCredential - add 직후 CLI는 새 계정인데 예전 슬롯 리프레시가 CLI 회전 토큰을 흡수하면, 증상은 “새 계정이 사라짐”보다 “두 슬롯이 같은 토큰/신원으로 수렴”에 가깝다. auth.json 스냅샷으로 구분한다.
    경로 src/adapters/kiro-constants.ts KIRO_BUILDER_ID_SERVICE_PROFILE_ARN - 이 값은 계정 신원에 쓰면 안 된다. Builder ID 두 계정이 잘못 같은 accountId로 저장되는지 점검 포인트다(보고자는 profileArn이 다르다고 했으므로 IdC 계정 쪽 가능성이 더 큼).

    메인테이너의 판단이 필요한 지점

    • 재현 시 두 계정이 IdC(계정 스코프 profileArn)인지 Builder ID(이메일 신원)인지, add 직후/사라짐 직후 auth.json의 accounts[].credential.accountId·email·kiro.profileArn 쌍을 받을지.
    • “잠깐 두 개”가 대시보드 낙관적 목록인지, 디스크에 실제로 두 줄이 쓰였다가 지워진 것인지(가능하면 add 전후 auth.json mtime·내용).
    • 수정 방향을 (1) 신원 충돌/upsert 가시화·거부, (2) forceLogin 정산·동시 로그인 가드, (3) CLI 단일 세션과 pool 리프레시 격리 중 어디에 둘지.
    • account-pool 실사용 버그로 지금 열차에 끼울지, 재현 픽스처(강제 로그인 + 이중 신원) 준비 후 독립 PR로 받을지.

    너의 추천
    열린 버그로 두고 bug/account-pool을 유지한다. 작성자에게 비밀 가린 add 직후·사라짐 직후 auth.json의 kiro accounts 배열(토큰 값은 길이만)과, 대시보드가 addAccount: true로 호출했는지, forceLogin 구간 전후 로그 순서를 요청한다. 재현이 “서로 다른 profileArn인데도 같은 accountId/email로 upsert”이면 saveCredential 신원 규칙을 고치고, “디스크에 두 줄이 생겼다가 롤백/다른 persist로 사라짐”이면 runLogin 정산·동시 로그인·리프레시 쪽을 본다. types/config 분할에 잡아먹힐 PR이 아니므로 닫지 말고, 현재 Muse/Devin/quota 기차에는 끼우지 말고 재현 확인 후 짧은 독립 수정으로 받는 편이 안전하다. 2.52.0 사용자에게는 dev/2.53.0에서도 동일 계열로 보인다고 안내하면 된다.

    이 댓글은 grok-bot이 작성했습니다

  4. added a commit that references this issue on Sep 13, 2026
  5. lidge-jun commented on Sep 13, 2026

    @lidge-jun
    Owner

    Fixed on dev via #4482 (merge commit 990cd8c).

    The second account was not being lost on login. A leftover CLI profile ARN collapsed it onto the first account, which is why it appeared to vanish shortly after a successful sign-in.

    Cross-platform CI run 34745142783 concluded success on the exact merged head. Closing manually because this merges into dev rather than the default branch.

  6. added a commit that references this issue on Sep 13, 2026
    f496a32
  7. added 2 commits that reference this issue on Sep 17, 2026
    c216775
    8648ba5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolbug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions