buildSideQuestionFallbackParams function
Future<CacheSafeParams>
buildSideQuestionFallbackParams({
- required List<
Map< tools,String, dynamic> > - required List<
Map< commands,String, dynamic> > - required List<
Map< mcpClients,String, dynamic> > - required List<
Map< messages,String, dynamic> > - required FileStateCache readFileState,
- required Map<
String, dynamic> getAppState(), - required void setAppState(),
- String? customSystemPrompt,
- String? appendSystemPrompt,
- Map<
String, dynamic> ? thinkingConfig, - required List<
Map< agents,String, dynamic> > - required GetSystemPromptFn getSystemPrompt,
- required GetUserContextFn getUserContext,
- required GetSystemContextFn getSystemContext,
Build CacheSafeParams for a side question fallback.
Implementation
Future<CacheSafeParams> buildSideQuestionFallbackParams({
required List<Map<String, dynamic>> tools,
required List<Map<String, dynamic>> commands,
required List<Map<String, dynamic>> mcpClients,
required List<Map<String, dynamic>> messages,
required FileStateCache readFileState,
required Map<String, dynamic> Function() getAppState,
required void Function(void Function(Map<String, dynamic>)) setAppState,
String? customSystemPrompt,
String? appendSystemPrompt,
Map<String, dynamic>? thinkingConfig,
required List<Map<String, dynamic>> agents,
required GetSystemPromptFn getSystemPrompt,
required GetUserContextFn getUserContext,
required GetSystemContextFn getSystemContext,
}) async {
final parts = await fetchSystemPromptParts(
getSystemPrompt: getSystemPrompt,
getUserContext: getUserContext,
getSystemContext: getSystemContext,
customSystemPrompt: customSystemPrompt,
);
final systemPrompt = <String>[
if (customSystemPrompt != null)
customSystemPrompt
else
...parts.defaultSystemPrompt,
?appendSystemPrompt,
];
// Strip in-progress assistant message.
final last = messages.isNotEmpty ? messages.last : null;
final forkContextMessages =
(last != null &&
last['type'] == 'assistant' &&
last['message']?['stop_reason'] == null)
? messages.sublist(0, messages.length - 1)
: messages;
final toolUseContext = <String, dynamic>{
'options': {
'commands': commands,
'debug': false,
'tools': tools,
'verbose': false,
'thinkingConfig': thinkingConfig,
'mcpClients': mcpClients,
'isNonInteractiveSession': true,
'agentDefinitions': {'activeAgents': agents, 'allAgents': []},
'customSystemPrompt': customSystemPrompt,
'appendSystemPrompt': appendSystemPrompt,
},
'readFileState': readFileState,
'messages': forkContextMessages,
};
return CacheSafeParams(
systemPrompt: systemPrompt,
userContext: parts.userContext,
systemContext: parts.systemContext,
toolUseContext: toolUseContext,
forkContextMessages: forkContextMessages,
);
}