chatboxai/chatbox · warning · ChatboxCliUsageError
Image generation requires an active chat session.
Error message
Image generation requires an active chat session.
What it means
ChatboxCliUsageError thrown at the top of generateImage when context.sessionId is falsy. Image generation is a session-scoped, callback-driven background task and cannot run without an active conversation to bind the resulting record and callback to.
Source
Thrown at src/renderer/packages/chatbox-cli/images.ts:155
if (existing.signature !== signature) {
return Promise.reject(new Error(`Tool call ${key} was reused with different image arguments.`))
}
return existing.promise
}
const promise = create()
executionCache.set(key, { signature, promise })
void promise.catch(() => {
if (executionCache.get(key)?.promise === promise) executionCache.delete(key)
})
if (executionCache.size > 100) {
const oldest = executionCache.keys().next().value
if (typeof oldest === 'string') executionCache.delete(oldest)
}
return promise
}
async function generateImage(context: ChatboxCliCommandContext): Promise<Record<string, unknown>> {
if (!context.sessionId) throw new ChatboxCliUsageError('Image generation requires an active chat session.')
if (!context.toolCallId) throw new ChatboxCliUsageError('Image generation requires a tool call id.')
const sessionId = context.sessionId
const toolCallId = context.toolCallId
const requestedPrompt = stringFlag(context.parsed, 'prompt') ?? context.parsed.positionals.join(' ').trim()
if (!requestedPrompt) throw new ChatboxCliUsageError('Missing --prompt.')
if (requestedPrompt.length > 8_000) throw new ChatboxCliUsageError('Prompt must be at most 8000 characters.')
const requestedProvider = stringFlag(context.parsed, 'provider')
const requestedModelId = stringFlag(context.parsed, 'model')
const requestedCount = integerFlag(context.parsed, 'count', { defaultValue: 1, min: 1, max: 4 })
const requestedAspectRatio = stringFlag(context.parsed, 'aspect-ratio')
const requestedStyle = stringFlag(context.parsed, 'style')
if (requestedStyle && requestedStyle !== 'vivid' && requestedStyle !== 'natural') {
throw new ChatboxCliUsageError('--style must be vivid or natural.')
}
const parsedStyle: 'vivid' | 'natural' | undefined =
requestedStyle === 'vivid' || requestedStyle === 'natural' ? requestedStyle : undefined
const approvedRequest =View on GitHub (pinned to 81571269ad)
Solutions
- Ensure the command is dispatched within an active conversation so context.sessionId is set.
- In the caller, check for an active session before offering the image-generate action.
- If programmatically driven, open/load a session first and pass its id into the tool context.
Example fix
// before
await executeChatboxCliCommand({ argv: ['image','generate','--prompt', p] }, { ...ctx, sessionId: undefined })
// after
if (!activeSessionId) return openConversationFirst()
await executeChatboxCliCommand({ argv: ['image','generate','--prompt', p] }, { ...ctx, sessionId: activeSessionId }) Defensive patterns
Strategy: validation
Validate before calling
if (!ctx.sessionId) {
return { error: 'Open a conversation before generating images', kind: 'usage' }
}
await executeChatboxCliCommand({ argv: ['image','generate','--prompt', prompt] }, ctx) Type guard
function hasActiveSession(ctx: { sessionId?: string }): ctx is { sessionId: string } {
return typeof ctx.sessionId === 'string' && ctx.sessionId.length > 0
} Try / catch
const res = await executeChatboxCliCommand({ argv: ['image','generate','--prompt', p] }, ctx)
if (!res.ok && res.kind === 'usage' && res.error.includes('active chat session')) {
// open/load a conversation first, then retry
} Prevention
- Only offer image generation from within an active conversation.
- Check for an active session in the caller before dispatching.
- Seed sessionId in test harnesses before invoking generate.
When it happens
Trigger: Invoking 'image generate' from a context with no active chat session (e.g. a global/background tool invocation, or before any conversation is loaded).
Common situations: An LLM attempting image generation outside a chat turn, a test harness that did not seed sessionId, or a UI flow that lost the active-session reference.
Related errors
- Missing --prompt.
- --style must be vivid or natural.
- Image model is not available: ${provider}/${modelId}. Use "c
- Missing image generation record id.
- Missing search query.
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/8479e35f31eb3fe8.
Report an issue: GitHub.