feat: [CLI] 9392 cli improve confirmation ux - revisited (#9824)

Co-authored-by: bavg <bavg@ubuntu-server.fritz.box>
This commit is contained in:
Vasi 2025-07-24 16:13:19 +02:00 committed by GitHub
parent b7f234641c
commit f6060f9c53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 12 deletions

View File

@ -239,7 +239,7 @@ async def run_session(
ChangeAgentStateAction(AgentState.USER_CONFIRMED),
EventSource.USER,
)
elif confirmation_status == 'edit':
else: # 'no' or alternative instructions
# Tell the agent the proposed action was rejected
event_stream.add_event(
ChangeAgentStateAction(AgentState.USER_REJECTED),
@ -248,16 +248,9 @@ async def run_session(
# Notify the user
print_formatted_text(
HTML(
'<skyblue>Okay, please tell me what I should do instead.</skyblue>'
'<skyblue>Okay, please tell me what I should do next/instead.</skyblue>'
)
)
# Solicit replacement isntructions
await prompt_for_next_task(AgentState.AWAITING_USER_INPUT)
else: # 'no' or fallback
event_stream.add_event(
ChangeAgentStateAction(AgentState.USER_REJECTED),
EventSource.USER,
)
# Set the always_confirm_mode flag if the user wants to always confirm
if confirmation_status == 'always':

View File

@ -704,9 +704,8 @@ async def read_confirmation_input(config: OpenHandsConfig) -> str:
try:
choices = [
'Yes, proceed',
'No, skip this action',
'No (and allow to enter instructions)',
"Always proceed (don't ask again)",
'Let me provide different instructions',
]
# keep the outer coroutine responsive by using asyncio.to_thread which puts the blocking call app.run() of cli_confirm() in a separate thread
@ -714,7 +713,7 @@ async def read_confirmation_input(config: OpenHandsConfig) -> str:
cli_confirm, config, 'Choose an option:', choices
)
return {0: 'yes', 1: 'no', 2: 'always', 3: 'edit'}.get(index, 'no')
return {0: 'yes', 1: 'no', 2: 'always'}.get(index, 'no')
except (KeyboardInterrupt, EOFError):
return 'no'