Skip to content

bug(kiro): model routing ignored without origin, parallel tool results rejected, kiro-cli social logins unsupported; Agent run failed loses its cause #6166

Description

@nijuyr

Description

Using the built-in kiro provider with a Kiro Power subscription on a Google (social) login surfaced several transport/auth defects beyond #6164 and #6158, plus an unrelated diagnosability gap where Error: Agent run failed. discards its cause. All findings below were verified with live requests against the real service (0.18.1 release and 0.18.3 source, macOS arm64). A fix branch exists locally; I can open a PR.

Already tracked elsewhere, same root causes I hit:

New findings

  1. origin is required for model selection. Without userInputMessage.origin: "AI_EDITOR" the service ignores modelId and answers every request with auto (the modelId field in every response frame is auto). Selecting kiro/claude-opus-5.5 silently has no effect. Adding origin makes the response frames report the requested model.
  2. Parallel tool results are split → HTTP 400 TOOL_USE_RESULT_MISMATCH. The OAuth transport puts only the last toolResult in currentMessage and leaves earlier results of the same parallel batch as a separate history entry. Kiro rejects the next turn:
    messages.4: tool_use ids were found without tool_result blocks immediately after … (TOOL_USE_RESULT_MISMATCH). All trailing consecutive toolResult messages must travel together in currentMessage.userInputMessageContext.toolResults.
  3. Kiro-cli social logins cannot be used. Users whose subscription is on a Google/GitHub Kiro login have no supported path: Builder ID (gjc auth-broker login kiro) is a different Kiro account (in my case Q_DEVELOPER_STANDALONE_FREE vs. …_POWER on the Google login), and KIRO_API_KEY (ksk_) hits per-account ThrottlingException 429s. Verified facts for supporting it:
    • kiro-cli stores the token in data.sqlite3 → table auth_kv, key kirocli:social:token → {access_token, refresh_token, expires_at, profile_arn, provider} (macOS: ~/Library/Application Support/kiro-cli/).
    • Refresh: POST https://prod.us-east-1.auth.desktop.kiro.dev/refreshToken with {"refreshToken": …} → {accessToken, refreshToken, expiresIn: 3600, profileArn}. The refresh token was not rotated. Invalid token → 401 {"message":"Bad credentials"}. SSO OIDC CreateToken does not work for these tokens.
    • profileArn must be sent in conversationState and in ListAvailableModels for social credentials.
    • ListAvailableModels and GetUsageLimits accept the same OAuth bearer on codewhisperer.<region>.amazonaws.com.
  4. Reasoning effort is not forwarded on the OAuth transport. Kiro takes the thinking budget as a prompt prefix <thinking_mode>enabled</thinking_mode><max_thinking_length>N</max_thinking_length> and streams inline <thinking>…</thinking> text, which currently lands in the answer text.

Separate: Error: Agent run failed. has no recorded cause

packages/agent/src/agent.ts replaces every thrown run failure with Agent run failed. (intentional — keeps provider text out of transcripts), but the cause is not logged anywhere, so these failures cannot be diagnosed. I saw 15 of them over 3 days on anthropic/claude-opus-5-5, all at or before stream start, no HTTP status, errorName: Error. Twice, two different sessions failed in the same millisecond, which points at shared state rather than one session. In the same window one Anthropic credential failed refresh 220× with invalid_grant: Refresh token not found or invalid yet stayed active (usage-path refresh failures never disable the row), and there were OAuth token refresh ownership remained ambiguous / SQLiteError: database is locked entries with ~11 concurrent gjc processes. Either would produce exactly this shape if thrown from getApiKey — not confirmed.

Suggested minimum: log the redacted cause (e.g. via redactCrashSecrets) at warn in that catch block, transcript/SDK surfaces unchanged.

Steps to Reproduce

  1. Kiro Power subscription on a Google login; OAuth bearer from that login.
  2. gjc --model kiro/claude-opus-5.5 -p "…" → response frames report modelId: auto (finding 1).
  3. Any prompt that makes the model issue ≥2 parallel tool calls → next request fails with 400 TOOL_USE_RESULT_MISMATCH (finding 2).

Expected Behavior

Selected model is honored; parallel tool turns continue; kiro-cli social logins are importable and refreshable; failed runs leave a diagnosable cause in the log.

Environment

macOS 27 (arm64), gjc 0.18.1 (release) and 0.18.3 (source, dev-based branch), bun 1.4.2. Provider: kiro (OAuth), also anthropic for the run-failure part.

Proposed fix (local branch, can PR)

  • fix(ai): send all trailing parallel tool results in currentMessage; set origin; send profileArn; forward reasoning as thinking budget and split inline <thinking> into thinking content; content-type check with the redacted body (overlaps bug(kiro): non-eventstream 200 body is masked as eventstream: truncated message #6158).
  • feat(ai)!: import kiro-cli social logins via gjc setup credentials / startup auto-import, refresh via the Kiro auth service; remove the KIRO_API_KEY path.
  • fix(agent): log the redacted cause behind Agent run failed.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions