Skip to content

fix: accept LLM output when command key missing but task_done is True#161

Open
amitkuma-1234 wants to merge 1 commit into
microsoft:mainfrom
amitkuma-1234:fix/issue-78-task-done-no-command
Open

fix: accept LLM output when command key missing but task_done is True#161
amitkuma-1234 wants to merge 1 commit into
microsoft:mainfrom
amitkuma-1234:fix/issue-78-task-done-no-command

Conversation

@amitkuma-1234

Copy link
Copy Markdown

Problem

When LLM sets task_done=True but does not include a command key,
the bot crashes while trying to process the missing command.

Fixes #78

Fix

Added early return check — if task_done is True before the main
loop, bot returns successfully without processing command.

Testing

Pass LLM response with task_done=True and no command key —
bot should return BotRunResult with status=True.

@amitkuma-1234

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR intends to prevent crashes when the LLM returns task_done=True but omits the command key, by adding an early return in MicroBot.run() to skip command processing when the task is already complete.

Changes:

  • Added an early-return path in MicroBot.run() when llm_response.task_done is True.
  • Added logging of “final thoughts” before returning success in that early-return path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/microbots/MicroBot.py
Comment on lines +230 to +240
if llm_response.task_done is True:
if llm_response.thoughts:
logger.info(
f" LLM final thoughts: {llm_response.thoughts}",
)
logger.info("TASK COMPLETED : %s...", task[0:15])
return BotRunResult(
status=True,
result=llm_response.thoughts,
error=None
)
Comment thread src/microbots/MicroBot.py
Comment on lines +235 to +240
logger.info("TASK COMPLETED : %s...", task[0:15])
return BotRunResult(
status=True,
result=llm_response.thoughts,
error=None
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept the LLM output if "command" key is not there when "task_done" is True

2 participants