iOfficeAI/AionUi · error
assistant_id is required
Error message
assistant_id is required
What it means
While resolving the agent configuration for a scheduled (cron) task, the selected assistant could not be found among `presetAssistants` by either its prefixed (`provider:id`) or raw id. The code treats a missing assistant as an invalid configuration and refuses to build the cron agent config.
Source
Thrown at packages/desktop/src/renderer/pages/cron/ScheduledTasksPage/resolveCronAgentConfig.ts:49
export function resolveCronAgentConfig(input: ResolveCronAgentConfigInput): ResolveCronAgentConfigResult {
const {
agentValue,
presetAssistants,
selectedAionrsProvider,
model_id,
config_options,
workspace,
localeKey = 'en-US',
getMode,
aionrsModelRequiredMessage,
} = input;
const colonIdx = agentValue.indexOf(':');
const prefixedId = colonIdx >= 0 ? agentValue.substring(colonIdx + 1) : agentValue;
const assistantSelection = presetAssistants.find((item) => item.id === prefixedId || item.id === agentValue);
if (!assistantSelection) {
throw new Error('assistant_id is required');
}
let agent_config: ICronAgentConfigWrite | undefined;
const assistant = assistantSelection;
const assistantName = resolveAssistantName(assistant, localeKey, assistant.name);
const mode = getMode(assistant);
if (isAionrsAssistant(assistant)) {
if (!selectedAionrsProvider?.id || !model_id) {
throw new Error(aionrsModelRequiredMessage);
}
agent_config = {
name: assistantName,
assistant_id: assistant.id,
mode,
model_id,
model: {View on GitHub (pinned to 711aa0550e)
Solutions
- Re-fetch/refresh the preset assistants list and confirm it is non-empty before rendering the picker
- Verify the agentValue string format matches the provider-prefixed convention used when building the list
- Clear stale form state and re-select the assistant from the current list
- If the assistant was removed, prompt the user to choose a replacement before submitting
Example fix
// before
const assistantSelection = presetAssistants.find((item) => item.id === prefixedId || item.id === agentValue);
if (!assistantSelection) {
throw new Error('assistant_id is required');
}
// after (validate before submit and show i18n message)
const assistantSelection = presetAssistants.find((item) => item.id === prefixedId || item.id === agentValue);
if (!assistantSelection) {
return { error: 'assistant_unavailable' } as const; // handled by handleSubmit with a toast
} Defensive patterns
Strategy: validation
Validate before calling
const valid = presetAssistants.some((a) => a.id === extractId(agentValue));
if (!valid) { /* re-select assistant, do not submit */ } Type guard
const isKnownAssistant = (list: Assistant[], value: string): boolean =>
list.some((a) => a.id === value || a.id === value.substring(value.indexOf(':') + 1)); Try / catch
catch (e) { if (e.message === 'assistant_id is required') { await reloadAssistants(); toast.warning(t('cron.assistantUnavailable')); } } Prevention
- Refresh the assistant list when the scheduled-task form opens
- Disable submit when the selected id is not in the current list
When it happens
Trigger: Submitting or evaluating a scheduled task whose `agentValue` references an assistant id that is not present in the loaded preset assistants list — e.g. an assistant that was uninstalled, disabled, or whose provider-scoped id string was parsed incorrectly.
Common situations: User picks an assistant, then the assistant/plugin is removed before the task is saved; preset assistant list failed to load (empty array) so every lookup misses; agentValue format changed (missing or extra `provider:` prefix) so the substring extraction yields a stale id; stale form state restored from localStorage after a version change.
Related errors
AI-assisted analysis of iOfficeAI/AionUi@711aa0550e (2026-08-28).
Data as JSON: /api/errors/bb8367c2000d9f2f.
Report an issue: GitHub.