Abstract message sequence to handlers that can be overriden.#528
Abstract message sequence to handlers that can be overriden.#528
Conversation
|
Depends on #527 |
eb8680
left a comment
There was a problem hiding this comment.
Let's see if we can simplify this a bit
eb8680
left a comment
There was a problem hiding this comment.
Another invariant we should be enforcing and testing is that Messages are always ordered correctly in the input to completion. I'm a little concerned that this will reorder histories by ordering Messages by handler context, rather than actual global time.
yes, that is a problem, msg_list = list(messages)
seen_ids = {m["id"] for m in msg_list}
prefix = [
m for msg_id, m in self.message_sequence.items() if msg_id not in seen_ids
]
message, tool_calls, result = fwd(prefix + msg_list, *args, **kwargs)
self.message_sequence[message["id"]] = message
return message, tool_calls, resultThis implementation of |
|
@eb8680 updated with a new design that does enforce all the invariants + tests pass Key interface is a new operation
|
This PR updates LiteLLMProvider to handle message sequences through a handler. The
agent.pyhas been updated to reuse this mechanism. The tests have been updated to enforce the respective invariants forcall_toolandcall_assistant, that is:call_tool: fresh message sequence
call_assistant: does not duplicate messages, only saves messages on successful execution of fwd