-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support controlling agent task state. #1094
feat: support controlling agent task state. #1094
Conversation
Screen.Recording.movignore the error BE threw, i just started a 2b LLM to fastly demonstrate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks for taking it on
|
||
if self._task_state == TaskState.FINISHED: | ||
await self._stop_task(is_finished=True) # type: ignore[unreachable] | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be break
so we hit the log statement below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, i don't what you mean 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break
means "exit the loop". return
means "exit the function"
since you're returning here, we never reach the log statement that's below the loop
self.state = None | ||
self._cur_step = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we call reset_task
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, reuse code.
opendevin/server/agent/agent.py
Outdated
|
||
def close(self): | ||
# self.stop_task() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm
opendevin/server/agent/agent.py
Outdated
if self.controller is not None: | ||
event_dict['task_state'] = self.controller.get_task_state().value | ||
self.send(event_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of sending this constantly, should we send an event when state changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. let me adjust it. btw, the asyncio.create_task
to start the agent task will very likely block other threads. i think we should consider using multiprocessing to run the agent task in Python to realize the true async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree!
* feat: add agent task state to agent status bar. * feat: add agent task control bar to FE.
2290615
to
906ad0d
Compare
have been updated. sorry for the force push, take care next time😅 |
the changes mainly includes:
|
I force push to my branches all the time 😄 as long as you don't force push to main it's all good! I use |
Tried this locally. Seems to work well! Two things I think we can improve on:
I'm good merging this as-is as it's already a big improvement. But the second bullet might be easy to address at least |
opendevin/server/agent/agent.py
Outdated
@@ -133,15 +169,24 @@ async def create_controller(self, start_event: dict): | |||
callbacks=[self.on_agent_event], | |||
) | |||
except Exception as e: | |||
logger.exception(f'Error creating controller: {e}') | |||
logger.exception(f"Error creating controller: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please try running the following command locally?
poetry run pre-commit run --files opendevin/**/* agenthub/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml
I am surprised to see 1) your pre-commit hook doesn't fix this, and 2) CI doesn't fail.
FWIW I ran the above command on my end, and it would change this double quote to single quote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poetry (version 1.8.2)
pre-commit 3.7.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(
Something's wrong with Fix double quoted strings
hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it doesn't always detect the f""
pattern, even in the GitHub workflow CI env it seems to only detect some cases but not all about this pattern 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am able to reproduce it using 3.12.2
. With 3.11.x
, this line will be fixed by the plugin. (That's sad, isn't it? We don't want to force everyone to use the same python version just because of a linting tool). That being said, I don't know why CI (which uses 3.11) would ignore this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit/pre-commit-hooks#973
seems already to be fixed? i can take a look in my env later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems already to be fixed?
Nope I tried, it didn't work (even after upgrading pre-commit-hooks to latest version that includes this fix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the most confusing part because that code supposably only exists in their latest version, while we are using an old version.
do you mean removing the stop and just keeping the reset for now? yep, pause may get the feedback for a long time. i originally added an icon loading overlapping with the pause button, but then i removed it. i'll try to handle it to get better ux. |
@iFurySt we should probably combine play and pause into the same button (showing "play" if it's paused, and showing "pause" if it's running) |
Okay, let me adjust it. |
…led status for action buttons.
Screen.Recording.mov@rbren have a look. i've just combined pause and resume into one button. and made some improvements to the |
feat: add agent task state to agent status bar.
feat: add agent task control bar to FE.
#1049