mastra-ai/mastra · warning
Session configuration is not ready. Try again.
Error message
Session configuration is not ready. Try again.
What it means
Thrown inside useCreateUserSessionFromDraft's createDraftSessionMutation when the draft session is submitted but the UI has not yet resolved an active mode or active model. The mutation requires both activeModeId and activeModelId to hand off configuration to the server, so it aborts early with a retry-oriented message. It is a transient readiness guard, not a server failure.
Source
Thrown at mastracode/factory-ui/src/ui/domains/chat/hooks/useCreateUserSessionFromDraft.ts:29
import { AGENT_CONTROLLER_ID } from '../services/constants';
import { promptHandoffState } from './useHandoffPrompt';
export function useCreateUserSessionFromDraft() {
const { baseUrl, factorySessionState } = useChatSessionContext();
const { activeModeId } = useChatModes();
const { activeModelId, draftModelPackId, modelPacks } = useChatModels();
const { factoryId, draftSessionId } = useParams<{ factoryId: string; draftSessionId: string }>();
const queryClient = useQueryClient();
const navigate = useNavigate();
return useMutation({
mutationFn: async (prompt: string) => {
const projectRepositoryId = factorySessionState?.projectRepositoryId;
if (!draftSessionId || !factoryId || !projectRepositoryId) {
throw new Error('Could not create the session. Reload the page and try again.');
}
if (!activeModeId || !activeModelId) {
throw new Error('Session configuration is not ready. Try again.');
}
// Activating the pack applies its models server-side, so only hand off a
// model when the draft explicitly deviated from the selected pack.
const modeKey =
activeModeId === 'build' || activeModeId === 'plan' || activeModeId === 'fast' ? activeModeId : undefined;
const packModelId =
draftModelPackId && modeKey
? modelPacks.find(pack => pack.id === draftModelPackId)?.models[modeKey]
: undefined;
const handoffModelId = activeModelId === packModelId ? undefined : activeModelId;
try {
const session = await createUserSession(baseUrl, projectRepositoryId, {
sessionId: draftSessionId,
title: prompt,
});
return { session, prompt, factoryId, projectRepositoryId, activeModeId, handoffModelId, draftModelPackId };View on GitHub (pinned to 75dd419e61)
Solutions
- Wait until activeModeId and activeModelId are defined before enabling the submit control (disable the composer button when either is missing).
- Verify the model pack / mode state that should populate activeModelId actually loaded (check the pack activation response and model policy allowlist).
- Retry the mutation after the configuration state settles, per the error message.
- If persistent, confirm factorySessionState provides projectRepositoryId and that draftSessionId was created (the sibling error covers missing ids).
Example fix
// before
if (!activeModeId || !activeModelId) {
throw new Error('Session configuration is not ready. Try again.');
}
// after
if (!activeModeId || !activeModelId) {
if (!submitEnabled) return; // gate the button instead of throwing
throw new Error('Session configuration is not ready. Try again.');
} Defensive patterns
Strategy: validation
Validate before calling
const canSubmit = Boolean(draftSessionId && factoryId && factorySessionState?.projectRepositoryId && activeModeId && activeModelId); if (!canSubmit) disableSubmit(); // only call mutateAsync when canSubmit is true
Type guard
function hasSessionConfig(s: { activeModeId?: string | null; activeModelId?: string | null }): s is { activeModeId: string; activeModelId: string } {
return typeof s.activeModeId === 'string' && s.activeModeId.length > 0 && typeof s.activeModelId === 'string' && s.activeModelId.length > 0;
} Prevention
- Disable the submit button until mode and model are resolved.
- Surface a loading state while mode/model hydration is pending.
- Alert on model packs that activate with zero active models.
When it happens
Trigger: Calling createDraftSessionMutation.mutateAsync(prompt) while activeModeId or activeModelId is still undefined/null — typically submitting before mode/model selection hydrates from the draft session, pack activation, or model policy fetch.
Common situations: Rapid double-submit on mount before React Query resolves mode/model state; a draft whose model pack failed to activate server-side leaving no activeModelId; a model policy that filters out all models so no model becomes active.
Related errors
- Could not create the session: ${message}. Try again.
- Session settings are unavailable
- Failed to load models (${res.status})
- Failed to load Factories
- Factory project is required
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/0f2f138e2a9cc300.
Report an issue: GitHub.