Skip to content

feat(review): Add thinking effort to code reviews#732

Open
alex-alecu wants to merge 14 commits intomainfrom
feat/thinking-effort-code-reviews
Open

feat(review): Add thinking effort to code reviews#732
alex-alecu wants to merge 14 commits intomainfrom
feat/thinking-effort-code-reviews

Conversation

@alex-alecu
Copy link
Contributor

No description provided.

Harden all variant/thinkingEffort Zod schemas with regex(/^[a-zA-Z]+$/)
to prevent shell injection via the CLI --variant flag in cloud-agent v1.
Also rename 'xhigh' display label from 'Xhigh' to 'Extra High'.
@alex-alecu alex-alecu self-assigned this Mar 2, 2026
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 2, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/db/src/schema-types.ts 290 thinking_effort field in CodeReviewAgentConfigSchema lacks .regex(/^[a-zA-Z]+$/) validation that all other variant schemas in this PR include. This value flows to shell command interpolation in cloud-agent/src/streaming.ts. Defense-in-depth gap.

SUGGESTION

File Line Issue
src/lib/code-reviews/core/model-variants.ts 13 getAvailableThinkingEfforts duplicates provider-matching logic from getModelVariants in recommended-models.ts with no sync mechanism. Consider adding a unit test that asserts both functions return the same variant names for representative model slugs.
Files Reviewed (21 files)
  • cloud-agent-next/src/execution/orchestrator.ts - 0 issues (field reorder only)
  • cloud-agent-next/src/execution/types.ts - 0 issues (field reorder only)
  • cloud-agent-next/src/kilo/wrapper-client.ts - 0 issues (field reorder only)
  • cloud-agent-next/src/persistence/CloudAgentSession.ts - 0 issues (field reorder only)
  • cloud-agent-next/src/persistence/schemas.ts - 0 issues (regex added correctly)
  • cloud-agent-next/src/router/schemas.ts - 0 issues (regex added correctly)
  • cloud-agent-next/wrapper/src/kilo-client.ts - 0 issues (field reorder + plumbing)
  • cloud-agent-next/wrapper/src/server.ts - 0 issues (field reorder)
  • cloud-agent/src/router/handlers/session-init.ts - 0 issues (variant plumbing)
  • cloud-agent/src/router/schemas.ts - 0 issues (regex added correctly)
  • cloud-agent/src/session-service.ts - 0 issues (variant plumbing)
  • cloud-agent/src/streaming.ts - 0 issues (variant flag added to CLI command; protected by upstream regex)
  • cloudflare-code-review-infra/src/types.ts - 0 issues (type addition)
  • packages/db/src/schema-types.ts - 1 issue
  • src/components/code-reviews/ReviewConfigForm.tsx - 0 issues (UI wiring correct)
  • src/lib/code-reviews/core/model-variants.ts - 1 issue
  • src/lib/code-reviews/triggers/prepare-review-payload.ts - 0 issues (variant plumbing)
  • src/routers/cloud-agent-next-schemas.ts - 0 issues (regex added correctly)
  • src/routers/cloud-agent-schemas.ts - 0 issues (regex added correctly)
  • src/routers/code-reviews-router.ts - 0 issues (thinking_effort plumbing)
  • src/routers/organizations/organization-code-reviews-router.ts - 0 issues (thinking_effort plumbing)

Fix these issues in Kilo Cloud

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 2, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
src/routers/organizations/organization-code-reviews-router.ts 178 Avoid as type assertion (null as string | null) — use satisfies instead
Other Observations (not in diff)

No issues found outside the diff.

Files Reviewed (22 files)
  • cloud-agent-next/src/execution/orchestrator.ts - 0 issues (property reorder only)
  • cloud-agent-next/src/execution/types.ts - 0 issues (property reorder only)
  • cloud-agent-next/src/kilo/wrapper-client.ts - 0 issues (property reorder only)
  • cloud-agent-next/src/persistence/CloudAgentSession.ts - 0 issues (property reorder only)
  • cloud-agent-next/src/persistence/schemas.ts - 0 issues (regex validation added)
  • cloud-agent-next/src/router/schemas.ts - 0 issues (regex validation added)
  • cloud-agent-next/wrapper/src/kilo-client.ts - 0 issues (property reorder + variant plumbing)
  • cloud-agent-next/wrapper/src/server.ts - 0 issues (property reorder)
  • cloud-agent/src/router/handlers/session-init.ts - 0 issues (variant passthrough)
  • cloud-agent/src/router/schemas.ts - 0 issues (regex validation added)
  • cloud-agent/src/session-service.ts - 0 issues (variant plumbing)
  • cloud-agent/src/streaming.ts - 0 issues (variant validation + CLI flag)
  • cloudflare-code-review-infra/src/types.ts - 0 issues (type addition)
  • packages/db/src/schema-types.ts - 0 issues (thinking_effort field added)
  • src/components/code-reviews/ReviewConfigForm.tsx - 0 issues (UI for thinking effort)
  • src/lib/code-reviews/core/model-variants.ts - 0 issues (new helper file)
  • src/lib/code-reviews/triggers/prepare-review-payload.ts - 0 issues (variant passthrough)
  • src/lib/providers/recommended-models.ts - 0 issues (inlined isAnthropicModel)
  • src/routers/cloud-agent-next-schemas.ts - 0 issues (regex validation added)
  • src/routers/cloud-agent-schemas.ts - 0 issues (regex validation added)
  • src/routers/code-reviews-router.ts - 0 issues (thinking effort plumbing)
  • src/routers/organizations/organization-code-reviews-router.ts - 1 issue

Fix these issues in Kilo Cloud

…Schema

Defense-in-depth: add .max(50).regex(/^[a-zA-Z]+$/) to match all other
variant schemas in this PR, preventing potential injection if bad data
reaches the DB.
Ensures getAvailableThinkingEfforts (client-safe) stays in sync with
getModelVariants (server-side) for all provider branches, catching
drift at CI time.
isFirstExecution: currentIsFirst,
kiloSessionId,
images: options?.images,
variant: options?.variant,
Copy link
Contributor

Choose a reason for hiding this comment

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

[SUGGESTION]: Redundant explicit property — variant is already included via ...options spread

images: options?.images (line above) has the same redundancy and predates this PR, so this is a pre-existing pattern. Both are no-ops since ...options already spreads images and variant. Not a bug, but worth noting for a future cleanup pass.

Collapse two redundant if-branches into one: if thinkingEffort is set
and not in availableVariants (including empty array), clear it.
Defense-in-depth: reject non-alphabetic variant values at the shell
interpolation site, independent of upstream Zod schema validation.
customInstructions: null,
maxReviewTimeMinutes: 10,
modelSlug: PRIMARY_DEFAULT_MODEL,
thinkingEffort: null as string | null,
Copy link
Contributor

Choose a reason for hiding this comment

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

SUGGESTION: Avoid as type assertion — use a typed annotation instead

Per project coding style, as should be strongly avoided. Here null as string | null widens the literal null type so the return object matches both branches. A cleaner alternative is to annotate the default object with a type or extract a typed variable:

Suggested change
thinkingEffort: null as string | null,
thinkingEffort: null as string | null,

Alternative (no as):

const thinkingEffort: string | null = null;
// then use `thinkingEffort` in the object

Low priority — the same as const pattern is already used on adjacent lines, so this is consistent with existing code.

customInstructions: null,
maxReviewTimeMinutes: 10,
modelSlug: PRIMARY_DEFAULT_MODEL,
thinkingEffort: null as string | null,
Copy link
Contributor

Choose a reason for hiding this comment

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

[SUGGESTION]: Avoid as type assertion — use a typed annotation instead

Same issue as in code-reviews-router.ts line 161: null as string | null uses TypeScript's as operator which the project style guide strongly discourages. Consider using satisfies or a typed variable instead.

Suggested change
thinkingEffort: null as string | null,
thinkingEffort: null satisfies string | null,

…hat when POST /session fails, the response body is captured and logged at error level. This prevents the opaque "HTTP error from server" message and instead shows the actual error (like the ConfigInvalidError we just discovered).
The kilo CLI v7.0.34 uses strict config validation and rejects the autoApproval key. Replaced the entire autoApproval block with equivalent settings in the permission format:
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.

1 participant