-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Sync history to stream #2640
base: main
Are you sure you want to change the base?
Sync history to stream #2640
Conversation
@@ -319,13 +319,13 @@ async def _step(self): | |||
else: | |||
await self.add_history(action, NullObservation('')) | |||
|
|||
if not isinstance(action, NullAction): | |||
await self.event_stream.add_event(action, EventSource.AGENT) |
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 would cause some trouble for delegation at least. When you add an event to the stream, its callback is called. In delegation scenario, the control is then handed over to child agent (controller). Even if we just exceeded the budget during this step, the child agent would still continue because we haven't computed and checked budget yet.
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.
Is this scenario you're thinking of at the beginning of delegation, so when the event is a delegate action?
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.
Yes, when event is AgentDelegateAction
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.
Okay, we could stop it at some point ( perhaps on_event
or follow up), though I'm not sure it will be pretty. Or when the controller is about to start and initializes the budget (oops error). I guess we could even, if it seems better, set the agent to ERROR, then add the event; to check for that state and stop the process. I'm not anymore at the computer, will give it some thought. If we can't, IMHO an alternative is to cancel, that is, this action "doesn't exist". I still don't see it in history unless it's in the stream...
(On a side note, the funny thing here is that I literally couldn't merge the current logic. Because histories are copies of the event stream in main
, and the copies will vanish when we refactor to have the event stream as the source of truth. There's no 'space' between add_history and add_event anymore 😅 )
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.
In the worst case, we could merge this PR as it is, and don't care about the budget thing I mentioned. It won't be ideal but not too bad.
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 would agree, but maybe the simplest is to just move the budget check before the call to the agent step
. It seems like it would work, to stop the next step... Will check.
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.
but maybe the simplest is to just move the budget check before the call to the agent step
Oh yeah sounds like a plan.
@li-boxuan I think we can't merge this, it doesn't work with delegates errors. First, the issue we talked about is on
On
But on the PR branch the delegates errors just don't work at all:
Either way, I think we can't merge this, because it breaks delegates errors worse than minor issues on main. FWIW I played a bit with it at the end of the step, and at the start of the step, same freeze. Gonna have to try to see if I broke it too when I merged... 😅 |
I think we could - would that solve the problem? |
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 converted this to a draft until we've resolved the issue with delegation!
In a recent PR #2595 we have fixed an issue with errors when the budget check is done in the controller, and it seems that now the flow isn't quite as expected: an event is added to history, a pending action may be stored (waiting for an obs), then the budget check is done and if it's not right (error) then we return, before adding that event to the stream.
I think that if an event is in history it should be because it's in the stream. Otherwise, I don't know, it's... a hallucination. 😅 This PR proposes to do it the other way around, add the event, then check budget or what else we need to check.
In addition, adding it will create the observation if suitable, and thus complete the step. Also, the pending action doesn't seem reset in any other way than doing this, currently. An error afterwards will still stop the next step.