Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
import { describe, expect, it, vi } from 'vitest';

import {
Expand Down Expand Up @@ -73,8 +74,8 @@ describe('constants', () => {
expect(PROMPT_MIN_LENGTH).toBe(3);
});

it('promptMaxLength is 4000', () => {
expect(PROMPT_MAX_LENGTH).toBe(4000);
it('promptMaxLength is the shared cloud agent prompt cap', () => {
expect(PROMPT_MAX_LENGTH).toBe(CLOUD_AGENT_PROMPT_MAX_LENGTH);
});

it('mode is "code"', () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/entrypoints/sidepanel/agents-new-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { fetchModelPreferences } from '@/src/shared/model-preferences-client';
import { isGatewayModelId } from '@/src/shared/model-picker-rows';
import { getModelPreferencesQueryKey } from '@/src/shared/side-panel-query-options';
import { thinkingEffortLabel } from '@/src/shared/kilo-api-client';
import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
import type { KiloGatewayModelOption } from '@/src/shared/kilo-api-client';
import { useExtensionAgents } from './agents-provider';
import { activeSessionsQueryKey, sessionHistoryQueryKey } from './agents-session-list';
Expand All @@ -43,7 +44,7 @@ import { useGatewayModels } from './use-gateway-models';
// ---------------------------------------------------------------------------

const PROMPT_MIN_LENGTH = 3;
const PROMPT_MAX_LENGTH = 4000;
const PROMPT_MAX_LENGTH = CLOUD_AGENT_PROMPT_MAX_LENGTH;
const MODE = 'code' as const;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ArrowUp, Paperclip, Square } from '@/components/ui/icons';
import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
import { type RefObject } from 'react';
import { useTranslation } from 'react-i18next';
import {
Expand Down Expand Up @@ -119,7 +120,7 @@ export function ChatComposerInputRow({
placeholder={placeholder}
placeholderTextColor={colors.mutedForeground}
multiline
maxLength={4000}
maxLength={CLOUD_AGENT_PROMPT_MAX_LENGTH}
onChangeText={onChangeText}
onFocus={onInputFocus}
onBlur={onInputBlur}
Expand Down
7 changes: 4 additions & 3 deletions apps/mobile/src/components/agents/chat-composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import * as Haptics from 'expo-haptics';
import { useActionSheet } from '@expo/react-native-action-sheet';
import { type SlashCommandInfo } from '@kilocode/cloud-agent-sdk';
import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
import { type RemoteCommandState } from '@kilocode/cloud-agent-sdk/remote-command-catalog';
import {
type Ref,
Expand Down Expand Up @@ -474,7 +475,7 @@ export function ChatComposer({
useSharePrefill({
shareId,
inputRef,
maxLength: 4000,
maxLength: CLOUD_AGENT_PROMPT_MAX_LENGTH,
onChangeText: handleChangeText,
addCandidates,
onDelivered: () => {
Expand All @@ -500,7 +501,7 @@ export function ChatComposer({
applyVoiceDraftToInput({
input: inputRef.current,
draft,
maxLength: 4000,
maxLength: CLOUD_AGENT_PROMPT_MAX_LENGTH,
onChangeText: handleChangeText,
});
},
Expand Down Expand Up @@ -537,7 +538,7 @@ export function ChatComposer({
input: inputRef.current,
draft: textRef.current,
selection: selectionRef.current,
maxLength: 4000,
maxLength: CLOUD_AGENT_PROMPT_MAX_LENGTH,
onChangeText: handleChangeText,
});
},
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/components/agents/new-session-prompt.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
import { useCallback, useEffect, useRef, useState } from 'react';
import {
type LayoutChangeEvent,
Expand Down Expand Up @@ -45,7 +46,7 @@ const PROMPT_INPUT_LINE_HEIGHT = 24;
const PROMPT_INPUT_VERTICAL_PADDING = 16;
const PROMPT_INPUT_HORIZONTAL_PADDING = Platform.OS === 'android' ? 48 : 16;
const PROMPT_INPUT_ANDROID_HORIZONTAL_INSET = 24;
const PROMPT_INPUT_MAX_CHARS = 4000;
const PROMPT_INPUT_MAX_CHARS = CLOUD_AGENT_PROMPT_MAX_LENGTH;
const PROMPT_INPUT_MIN_HEIGHT =
PROMPT_INPUT_LINE_HEIGHT * PROMPT_INPUT_DEFAULT_LINES + PROMPT_INPUT_VERTICAL_PADDING;
const PROMPT_INPUT_MAX_HEIGHT =
Expand Down
5 changes: 3 additions & 2 deletions apps/mobile/src/lib/share-payload.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
import * as Crypto from 'expo-crypto';
import { cacheDirectory, copyAsync, deleteAsync } from 'expo-file-system/legacy';
import { type ShareIntent } from 'expo-share-intent';
Expand All @@ -13,8 +14,8 @@ export type SharePayload = {
failedFiles: string[];
};

/** Mirrors PROMPT_INPUT_MAX_CHARS in new-session-prompt.tsx (module-local; composer clamps again). */
export const SHARE_TEXT_MAX_CHARS = 4000;
/** The cloud agent prompt cap; the composer clamps again on delivery. */
export const SHARE_TEXT_MAX_CHARS = CLOUD_AGENT_PROMPT_MAX_LENGTH;

export const SHARE_PAYLOAD_MAX_ENTRIES = 5;

Expand Down
10 changes: 3 additions & 7 deletions apps/web/src/lib/cloud-agent/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ export function normalizeAttachmentExtension(extension: string | undefined | nul
export type { CloudAgentAttachments } from '@kilocode/app-shared/cloud-agent';

/**
* Maximum prompt length (in characters) accepted by the cloud agent.
*
* Mirrors the server-side cap in `services/cloud-agent-next/src/schema.ts`
* (`Limits.MAX_PROMPT_LENGTH`). Prompts exceeding this would be rejected by
* the worker, so we enforce the same limit client-side to give users
* immediate feedback.
* Maximum prompt length (in characters) accepted by the cloud agent. Defined
* once in the SDK so the web, mobile, and extension composers share it.
*/
export const CLOUD_AGENT_PROMPT_MAX_LENGTH = 100_000;
export { CLOUD_AGENT_PROMPT_MAX_LENGTH } from '@kilocode/cloud-agent-sdk/limits';
8 changes: 8 additions & 0 deletions packages/cloud-agent-sdk/src/limits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Maximum prompt length (in characters) accepted by the cloud agent.
*
* Mirrors the server-side cap in `services/cloud-agent-next/src/schema.ts`
* (`Limits.MAX_PROMPT_LENGTH`). Every client enforces the same limit so a
* composer never silently drops text the worker would have accepted.
*/
export const CLOUD_AGENT_PROMPT_MAX_LENGTH = 100_000;