Skip to content

fix(cli): sync sessions authenticated by KILO_API_KEY - #10751

Merged
lambertjosh merged 6 commits into
mainfrom
fix/session-ingest-env-auth
Jun 9, 2026
Merged

fix(cli): sync sessions authenticated by KILO_API_KEY#10751
lambertjosh merged 6 commits into
mainfrom
fix/session-ingest-env-auth

Conversation

@lambertjosh

@lambertjosh lambertjosh commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allow CLI sessions authenticated through KILO_API_KEY to bootstrap private session ingest when no persisted Kilo auth is present
  • preserve stored Kilo auth precedence and cover environment-only authentication plus precedence with regression tests
  • document that the behavior applies to both interactive CLI sessions and kilo run, including the KILO_DISABLE_SESSION_INGEST=1 opt-out

Why

Session ingest currently resolves its token only from persisted Kilo auth, while other CLI paths already accept KILO_API_KEY. A user or automation invoking the CLI with environment-based Kilo authentication can therefore complete inference successfully but never get a downloadable session record in the Kilo backend. This is an authentication-source issue, not a non-interactive-only issue.

Validation

  • bun test ./test/kilocode/kilo-sessions.test.ts
  • bun run typecheck from packages/opencode/
  • bun run script/check-opencode-annotations.ts
  • git diff --check

Also performed via Kilo Bench that sessions using this branch had session telemetry logged.

@kilo-code-bot

kilo-code-bot Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

The previous WARNING (inaccurate changeset description) has been resolved. The description now correctly states that KILO_API_KEY is used as a fallback "when no stored Kilo auth is present," which matches the implementation.

Files Reviewed (5 files)
  • .changeset/sync-api-key-sessions.md — previously flagged WARNING resolved
  • packages/kilo-docs/pages/code-with-ai/platforms/cli.md — clean
  • packages/opencode/src/kilo-sessions/kilo-sessions.ts — clean
  • packages/opencode/test/kilocode/kilo-sessions.test.ts — clean (new tests for KILO_API_KEY fallback behavior look correct)

Reviewed by claude-4.6-sonnet-20260217 · 188,625 tokens

Review guidance: REVIEW.md from base branch main

@lambertjosh lambertjosh changed the title fix(cli): sync headless sessions authenticated by API key fix(cli): sync sessions authenticated by KILO_API_KEY May 29, 2026
Comment thread packages/kilo-docs/pages/code-with-ai/platforms/cli.md Outdated
@lambertjosh

Copy link
Copy Markdown
Contributor Author

Validated with a kilo bench run that authenticates this way. Ran the bench and was still able to look it up.
image

if (auth?.type === "oauth" && auth.access.length > 0) return auth.access
if (auth?.type === "wellknown" && auth.token.length > 0) return auth.token

const key = process.env["KILO_API_KEY"]?.trim()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the the first priority.

Comment thread packages/kilo-docs/pages/code-with-ai/platforms/cli.md Outdated
Comment thread .changeset/sync-api-key-sessions.md Outdated
Comment thread .changeset/sync-api-key-sessions.md Outdated
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
@lambertjosh
lambertjosh merged commit 729c062 into main Jun 9, 2026
21 checks passed
@lambertjosh
lambertjosh deleted the fix/session-ingest-env-auth branch June 9, 2026 20:35
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…v-auth

fix(cli): sync sessions authenticated by KILO_API_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants