Multi Agent Investigations

This commit is contained in:
Raven Scott
2026-07-30 16:22:21 -04:00
parent 0f86534805
commit bcfec67368
8 changed files with 783 additions and 19 deletions
+28 -4
View File
@@ -445,7 +445,11 @@ export function createQvacEngine(deps) {
const profile = getProfile(profileId || 'recommended')
const prefs = deps.getPrefs?.() || {}
const userLast = [...history].reverse().find((m) => m.role === 'user')
let system = buildSystemPrompt(deps.getContext?.() || {})
const ctx = {
...(deps.getContext?.() || {}),
subAgents: prefs.subAgents !== false,
}
let system = buildSystemPrompt(ctx)
// Light RAG only — full catalog dumps blow small context windows
if (prefs.rag !== false && userLast?.content) {
@@ -457,16 +461,31 @@ export function createQvacEngine(deps) {
if (rag) system += `\n\n${rag.slice(0, 1200)}`
}
// Multi-agent briefing from parallel specialists (optional)
if (opts.agentBriefing) {
system += `\n\n${String(opts.agentBriefing).slice(0, 5000)}`
}
const fullHistory = [
{ role: 'system', content: system },
...history.filter((m) => m.role !== 'system'),
]
if (modelId && (sdkMode === 'main' || (sdk && sdk.completion))) {
return completeWithSdk(fullHistory, profile, opts)
return completeWithSdk(fullHistory, profile, opts, prefs)
}
status = status === 'ready' ? status : 'fallback'
// If multi-agent pack already ran, prefer its synthesis over naive fallback
if (opts.agentFallbackText) {
const text = String(opts.agentFallbackText)
if (opts.onToken) {
const chunk = 24
for (let i = 0; i < text.length; i += chunk) opts.onToken(text.slice(i, i + chunk))
}
opts.onEvent?.({ type: 'completionDone', stopReason: 'eos' })
return { contentText: text, toolCalls: opts.agentToolCalls || [], mode: 'fallback' }
}
const result = await fallbackComplete(userLast?.content || '', deps.tools, {
catalog: deps.getCatalog?.() || {},
rag: prefs.rag !== false,
@@ -485,9 +504,14 @@ export function createQvacEngine(deps) {
return result
}
async function completeWithSdk(history, profile, opts) {
async function completeWithSdk(history, profile, opts, prefs = {}) {
const depthPref = prefs.toolDepth || 'auto'
const depth =
depthPref === 'core' || depthPref === 'deep'
? depthPref
: undefined
let toolDefs = profile.tools
? deps.tools.defsForRole({ profileId: profile.id, profile })
? deps.tools.defsForRole({ profileId: profile.id, profile, depth })
: undefined
const ctxSize = profile.ctxSize || 8192
let toolsTok = estimateToolsTokens(toolDefs)