Skip to content

Comments

Cloud Agent Next - Support All 5 CLI Agent Modes#366

Open
eshurakov wants to merge 1 commit intomainfrom
eshurakov/cloud-agent-next-new-modes-support
Open

Cloud Agent Next - Support All 5 CLI Agent Modes#366
eshurakov wants to merge 1 commit intomainfrom
eshurakov/cloud-agent-next-new-modes-support

Conversation

@eshurakov
Copy link
Contributor

Summary

Replace the old 2-mode system (build | plan) with the 5 CLI-aligned agent modes (code | plan | debug | orchestrator | ask) across the worker, Next.js API layer, and UI.

Changes

  • Worker schema (cloud-agent-next/src/schema.ts): InternalAgentModes now includes all 6 modes (5 + custom). normalizeAgentMode passes modes 1:1 to the CLI instead of collapsing debug/orchestrator/ask. build and architect remain as backward-compatible API aliases.
  • Worker defaults: All 'build' fallback defaults changed to 'code' (CloudAgentSession.ts, auto-commit.ts, openrouter route).
  • Next.js API layer (cloud-agent-next-schemas.ts, cloud-agent-client.ts): agentModeSendMessageSchema updated from ['plan', 'build'] to ['code', 'plan', 'debug', 'orchestrator', 'ask'].
  • UI components: AgentMode type, ModeCombobox, ResumeConfigModal, session-config.ts, and db-session-atoms.ts all updated to the 5 new modes.
  • Legacy safety: Added normalizeMode() helper in CloudChatContainer.tsx to map legacy 'build'/'architect' strings from DB/DO to their new equivalents, replacing unsafe as casts.
  • Dead code removal: Deleted unused mode-conversion.ts.
  • Tests: ~70 occurrences of 'build' updated to 'code' across 8 test files. All 627 cloud-agent-next tests and 16 frontend tests pass.

Backward Compatibility

  • Existing DO sessions with stored mode: 'build' are handled by keeping 'build' as an accepted API alias that normalizes to 'code'.
  • Database cli_sessions.last_mode is free-text; existing 'build' values are handled by worker normalization and the new normalizeMode() in the UI.

Replace the old 2-mode system (build | plan) with the 5 CLI-aligned
agent modes (code | plan | debug | orchestrator | ask) across the
worker, Next.js API layer, and UI.

- Update InternalAgentModes to pass modes 1:1 to the CLI instead of
  lossy normalization (debug/orchestrator/ask no longer collapse)
- Keep 'build' and 'architect' as backward-compatible API aliases
  (build → code, architect → plan) for existing DO sessions
- Replace all 'build' defaults with 'code' across worker, UI, and tests
- Add normalizeMode() in CloudChatContainer to safely handle legacy
  mode strings from DB/DO without unsafe 'as' casts
- Remove dead mode-conversion.ts (unused, stale logic)
- Update ModeCombobox, ResumeConfigModal, and tRPC schemas to expose
  all 5 modes in the UI
function normalizeMode(mode: string): AgentMode {
if (mode === 'build') return 'code';
if (mode === 'architect') return 'plan';
return mode as AgentMode;
Copy link
Contributor

Choose a reason for hiding this comment

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

[SUGGESTION]: The as AgentMode cast silently passes through any unknown mode string from DB/DO (e.g. 'custom', 'foobar'). Consider validating against the known modes and falling back to a safe default:

Suggested change
return mode as AgentMode;
const validModes: AgentMode[] = ['code', 'plan', 'debug', 'orchestrator', 'ask'];
return (validModes as string[]).includes(mode) ? (mode as AgentMode) : 'code';

This avoids silently propagating an invalid mode through the UI.

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 19, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Merge (minor suggestion only)

Overview

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

SUGGESTION

File Line Issue
src/components/cloud-agent-next/CloudChatContainer.tsx 61 normalizeMode uses as AgentMode cast — unknown mode strings from DB/DO pass through unchecked
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
src/routers/cloud-agent-next-schemas.ts 6 Stale module-level comment says "Uses new modes (plan, build)" — should be updated to reflect the new mode set
src/components/cloud-agent-next/types.ts 329 SessionConfig.mode comment says "(code, architect, debug, etc.)" — architect is now a legacy alias
Files Reviewed (20 files)
  • cloud-agent-next/src/kilo/wrapper-client.test.ts - 0 issues
  • cloud-agent-next/src/logger.ts - 0 issues
  • cloud-agent-next/src/persistence/CloudAgentSession.ts - 0 issues
  • cloud-agent-next/src/router.test.ts - 0 issues
  • cloud-agent-next/src/schema.ts - 0 issues
  • cloud-agent-next/src/session-prepare.test.ts - 0 issues
  • cloud-agent-next/src/session-service.test.ts - 0 issues
  • cloud-agent-next/src/streaming.test.ts - 0 issues
  • cloud-agent-next/test/integration/session/start-execution-v2.test.ts - 0 issues
  • cloud-agent-next/wrapper/src/auto-commit.ts - 0 issues
  • src/app/api/openrouter/[...path]/route.ts - 0 issues
  • src/components/cloud-agent-next/CloudChatContainer.tsx - 1 issue
  • src/components/cloud-agent-next/CloudNextSessionsPage.tsx - 0 issues
  • src/components/cloud-agent-next/ResumeConfigModal.tsx - 0 issues
  • src/components/cloud-agent-next/demo-config.ts - 0 issues
  • src/components/cloud-agent-next/hooks/useResumeConfigModal.test.ts - 0 issues
  • src/components/cloud-agent-next/hooks/useSidebarSessions.ts - 0 issues
  • src/components/cloud-agent-next/session-config.test.ts - 0 issues
  • src/components/cloud-agent-next/session-config.ts - 0 issues
  • src/components/cloud-agent-next/store/db-session-atoms.ts - 0 issues
  • src/components/cloud-agent-next/types.ts - 0 issues
  • src/components/cloud-agent-next/useCloudAgentStream.ts - 0 issues
  • src/components/cloud-agent-next/utils/mode-conversion.ts - 0 issues (deleted)
  • src/components/shared/ModeCombobox.tsx - 0 issues
  • src/lib/cloud-agent-next/cloud-agent-client.ts - 0 issues
  • src/routers/cloud-agent-next-schemas.ts - 0 issues

Fix these issues in Kilo Cloud

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