Skip to content

Conversation

@jhaynie
Copy link
Member

@jhaynie jhaynie commented Jan 20, 2026

org id should always respect the env and preferences

Summary by CodeRabbit

  • Improvements
    • Enhanced cloud operations configuration with flexible organization ID resolution, now supporting environment variables and configuration preferences as fallback options.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Multiple utility functions updated to include Config type in imports and extend createStorageAdapter context parameter with config: Config | null property. Organization ID resolution enhanced with fallback mechanisms using environment variables and configuration preferences.

Changes

Cohort / File(s) Summary
Cloud Storage Adapter Utilities
packages/cli/src/cmd/cloud/keyvalue/util.ts, packages/cli/src/cmd/cloud/vector/util.ts
Added Config type to imports from ../../../types; extended createStorageAdapter context parameter to include config: Config | null property; enhanced organization ID resolution to fallback to AGENTUITY_CLOUD_ORG_ID environment variable or ctx.config?.preferences?.orgId when not provided via project or options
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@jhaynie jhaynie force-pushed the task/org-id-not-respecting-preference branch from 6c48d63 to d1989c8 Compare January 20, 2026 04:25
@github-actions
Copy link

📦 Canary Packages Published

version: 0.1.21-d1989c8

Packages
Package Version URL
@agentuity/evals 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-evals-0.1.21-d1989c8.tgz
@agentuity/react 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-react-0.1.21-d1989c8.tgz
@agentuity/workbench 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-workbench-0.1.21-d1989c8.tgz
@agentuity/schema 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-schema-0.1.21-d1989c8.tgz
@agentuity/runtime 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-runtime-0.1.21-d1989c8.tgz
@agentuity/auth 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-auth-0.1.21-d1989c8.tgz
@agentuity/server 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-server-0.1.21-d1989c8.tgz
@agentuity/frontend 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-frontend-0.1.21-d1989c8.tgz
@agentuity/opencode 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-opencode-0.1.21-d1989c8.tgz
@agentuity/cli 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-cli-0.1.21-d1989c8.tgz
@agentuity/core 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-core-0.1.21-d1989c8.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/evals": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-evals-0.1.21-d1989c8.tgz",
    "@agentuity/react": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-react-0.1.21-d1989c8.tgz",
    "@agentuity/workbench": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-workbench-0.1.21-d1989c8.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-schema-0.1.21-d1989c8.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-runtime-0.1.21-d1989c8.tgz",
    "@agentuity/auth": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-auth-0.1.21-d1989c8.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-server-0.1.21-d1989c8.tgz",
    "@agentuity/frontend": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-frontend-0.1.21-d1989c8.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-opencode-0.1.21-d1989c8.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-cli-0.1.21-d1989c8.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-core-0.1.21-d1989c8.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-evals-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-react-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-workbench-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-schema-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-runtime-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-auth-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-server-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-frontend-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-opencode-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-cli-0.1.21-d1989c8.tgz
bun add https://agentuity-sdk-objects.t3.storage.dev/npm/0.1.21-d1989c8/agentuity-core-0.1.21-d1989c8.tgz
CLI Executables
Platform Version URL
darwin-arm64 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/binary/0.1.21-d1989c8/agentuity-darwin-arm64.gz
linux-x64 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/binary/0.1.21-d1989c8/agentuity-linux-x64.gz
linux-arm64 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/binary/0.1.21-d1989c8/agentuity-linux-arm64.gz
darwin-x64 0.1.21-d1989c8 https://agentuity-sdk-objects.t3.storage.dev/binary/0.1.21-d1989c8/agentuity-darwin-x64.gz
Run Canary CLI
agentuity canary 0.1.21-d1989c8 [command] [...args]

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/cli/src/cmd/cloud/keyvalue/util.ts`:
- Around line 14-17: The orgId precedence currently assigns ctx.project?.orgId
before environment or saved preferences; change the evaluation order for the
orgId constant so environment (process.env.AGENTUITY_CLOUD_ORG_ID) and config
preferences (ctx.config?.preferences?.orgId) and explicit CLI options
(ctx.options.orgId) are checked before falling back to ctx.project?.orgId;
update the orgId expression (the orgId constant in util.ts) to reorder the
nullish/coalescing checks so env and preferences take precedence over
project.orgId.

In `@packages/cli/src/cmd/cloud/vector/util.ts`:
- Around line 14-17: The orgId precedence currently uses ctx.project?.orgId
first; change the selection logic so the CLI flag (ctx.options.orgId) is checked
first, then environment and preferences (process.env.AGENTUITY_CLOUD_ORG_ID or
ctx.config?.preferences?.orgId), and finally fall back to the project value
(ctx.project?.orgId). Update the expression that sets orgId to reflect this
order and ensure all referenced symbols (ctx.options.orgId,
process.env.AGENTUITY_CLOUD_ORG_ID, ctx.config?.preferences?.orgId,
ctx.project?.orgId) are evaluated in that new precedence.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f83d7d6 and d1989c8.

📒 Files selected for processing (2)
  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
🧰 Additional context used
📓 Path-based instructions (3)
packages/cli/src/cmd/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

packages/cli/src/cmd/**/*.ts: Use tui.* helpers for formatted output instead of raw console logs
Use ctx.logger for logging; call logger.fatal() to log and exit with code 1

Files:

  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
packages/cli/src/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use Prettier formatter with tabs (width 3), single quotes, and semicolons for TypeScript files
Use TypeScript strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
🧠 Learnings (2)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
📚 Learning: 2026-01-13T04:32:02.691Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 565
File: packages/cli/src/cmd/cloud/region-lookup.ts:14-26
Timestamp: 2026-01-13T04:32:02.691Z
Learning: Enforce sandbox identifier prefixes in new code within the CLI cloud region lookup: new sandboxes must use the sbx_ prefix. The snbx_ prefix may appear in legacy code or examples, but do not use snbx_ for new sandboxes. When reviewing changes in packages/cli/src/cmd/cloud/, ensure any created sandbox identifiers use sbx_ and remove or migrate any snbx_ usages in newly added code.

Applied to files:

  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
🧬 Code graph analysis (2)
packages/cli/src/cmd/cloud/keyvalue/util.ts (2)
packages/cli/src/cmd/cloud/vector/util.ts (1)
  • createStorageAdapter (6-37)
packages/cli/src/types.ts (5)
  • Logger (12-12)
  • AuthData (275-279)
  • ProjectConfig (321-321)
  • Config (67-67)
  • GlobalOptions (281-296)
packages/cli/src/cmd/cloud/vector/util.ts (2)
packages/cli/src/cmd/cloud/keyvalue/util.ts (1)
  • createStorageAdapter (6-37)
packages/cli/src/types.ts (5)
  • Logger (12-12)
  • AuthData (275-279)
  • ProjectConfig (321-321)
  • Config (67-67)
  • GlobalOptions (281-296)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: SDK Integration Test Suite

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +14 to +17
const orgId =
ctx.project?.orgId ??
ctx.options.orgId ??
(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Org ID precedence still ignores env/preferences when a project orgId exists.

Same issue as in vector util: project.orgId currently overrides env/preferences. If env or preference should always be respected, move them ahead of project.

🔧 Proposed fix
-const orgId =
-	ctx.project?.orgId ??
-	ctx.options.orgId ??
-	(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
+const orgId =
+	ctx.options.orgId ??
+	process.env.AGENTUITY_CLOUD_ORG_ID ??
+	ctx.config?.preferences?.orgId ??
+	ctx.project?.orgId;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const orgId =
ctx.project?.orgId ??
ctx.options.orgId ??
(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
const orgId =
ctx.options.orgId ??
process.env.AGENTUITY_CLOUD_ORG_ID ??
ctx.config?.preferences?.orgId ??
ctx.project?.orgId;
🤖 Prompt for AI Agents
In `@packages/cli/src/cmd/cloud/keyvalue/util.ts` around lines 14 - 17, The orgId
precedence currently assigns ctx.project?.orgId before environment or saved
preferences; change the evaluation order for the orgId constant so environment
(process.env.AGENTUITY_CLOUD_ORG_ID) and config preferences
(ctx.config?.preferences?.orgId) and explicit CLI options (ctx.options.orgId)
are checked before falling back to ctx.project?.orgId; update the orgId
expression (the orgId constant in util.ts) to reorder the nullish/coalescing
checks so env and preferences take precedence over project.orgId.

Comment on lines +14 to +17
const orgId =
ctx.project?.orgId ??
ctx.options.orgId ??
(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Org ID precedence still ignores env/preferences when a project orgId exists.

The current order prefers project.orgId over env/preferences, which can override the “always respect env and preferences” objective when running inside a project. Consider prioritizing CLI flag, then env/preferences, then project.

🔧 Proposed fix
-const orgId =
-	ctx.project?.orgId ??
-	ctx.options.orgId ??
-	(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
+const orgId =
+	ctx.options.orgId ??
+	process.env.AGENTUITY_CLOUD_ORG_ID ??
+	ctx.config?.preferences?.orgId ??
+	ctx.project?.orgId;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const orgId =
ctx.project?.orgId ??
ctx.options.orgId ??
(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
const orgId =
ctx.options.orgId ??
process.env.AGENTUITY_CLOUD_ORG_ID ??
ctx.config?.preferences?.orgId ??
ctx.project?.orgId;
🤖 Prompt for AI Agents
In `@packages/cli/src/cmd/cloud/vector/util.ts` around lines 14 - 17, The orgId
precedence currently uses ctx.project?.orgId first; change the selection logic
so the CLI flag (ctx.options.orgId) is checked first, then environment and
preferences (process.env.AGENTUITY_CLOUD_ORG_ID or
ctx.config?.preferences?.orgId), and finally fall back to the project value
(ctx.project?.orgId). Update the expression that sets orgId to reflect this
order and ensure all referenced symbols (ctx.options.orgId,
process.env.AGENTUITY_CLOUD_ORG_ID, ctx.config?.preferences?.orgId,
ctx.project?.orgId) are evaluated in that new precedence.

@jhaynie jhaynie merged commit 9e088db into main Jan 20, 2026
14 checks passed
@jhaynie jhaynie deleted the task/org-id-not-respecting-preference branch January 20, 2026 04:37
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