mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 08:03:14 +00:00
fix: address pr-bug-scan validated finding from #7862
Oversized Hermes automation prompts no longer fail: launcher falls back to launching 'hermes --tui' empty and pasting the prompt after ready, so buildAgentStartupPlan-null no longer returns null.
This commit is contained in:
@@ -516,6 +516,27 @@ describe('launchAgentBackgroundSession', () => {
|
||||
expect(mockPasteDraftWhenAgentReady).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('falls back to paste delivery when a Hermes prompt overflows the startup-query budget', async () => {
|
||||
const oversizedPrompt = 'x'.repeat(30_000)
|
||||
const { launchAgentBackgroundSession } = await import('./launch-agent-background-session')
|
||||
|
||||
const result = await launchAgentBackgroundSession({
|
||||
agent: 'hermes',
|
||||
worktreeId: 'wt-1',
|
||||
prompt: oversizedPrompt
|
||||
})
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(mockSpawn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ command: 'hermes --tui' })
|
||||
)
|
||||
const spawnArgs = mockSpawn.mock.calls[0]?.[0]
|
||||
expect(spawnArgs?.env?.ORCA_HERMES_STARTUP_QUERY).toBeUndefined()
|
||||
expect(mockPasteDraftWhenAgentReady).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ agent: 'hermes', content: oversizedPrompt, submit: true })
|
||||
)
|
||||
})
|
||||
|
||||
it('uses the configured cmd shell for Windows Hermes background launches', async () => {
|
||||
mockGetAgentLaunchPlatformForRepo.mockReturnValue('win32')
|
||||
Object.assign(state.settings, { terminalWindowsShell: 'cmd.exe' })
|
||||
|
||||
@@ -83,8 +83,8 @@ export async function launchAgentBackgroundSession(
|
||||
const hasPrompt = trimmedPrompt.length > 0
|
||||
const isFollowupPath = TUI_AGENT_CONFIG[agent].promptInjectionMode === 'stdin-after-start'
|
||||
|
||||
const pasteDraftAfterLaunch = hasPrompt && isFollowupPath ? trimmedPrompt : null
|
||||
const startupPlan = buildAgentStartupPlan({
|
||||
let pasteDraftAfterLaunch = hasPrompt && isFollowupPath ? trimmedPrompt : null
|
||||
let startupPlan = buildAgentStartupPlan({
|
||||
agent,
|
||||
prompt: hasPrompt && !isFollowupPath ? trimmedPrompt : '',
|
||||
cmdOverrides,
|
||||
@@ -95,6 +95,26 @@ export async function launchAgentBackgroundSession(
|
||||
isRemote,
|
||||
allowEmptyPromptLaunch: !hasPrompt || isFollowupPath
|
||||
})
|
||||
if (!startupPlan && hasPrompt && !isFollowupPath) {
|
||||
// Why: a large prompt (e.g. an automation PR diff) can overflow the Hermes
|
||||
// native startup-query env budget, making buildAgentStartupPlan return null.
|
||||
// Rather than fail the whole dispatch, launch the agent with no prompt and
|
||||
// paste it after the TUI is ready — the pre-native-query delivery path.
|
||||
startupPlan = buildAgentStartupPlan({
|
||||
agent,
|
||||
prompt: '',
|
||||
cmdOverrides,
|
||||
agentArgs,
|
||||
agentEnv,
|
||||
platform: launchPlatform,
|
||||
shell: startupShell,
|
||||
isRemote,
|
||||
allowEmptyPromptLaunch: true
|
||||
})
|
||||
if (startupPlan) {
|
||||
pasteDraftAfterLaunch = trimmedPrompt
|
||||
}
|
||||
}
|
||||
if (!startupPlan) {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user