-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Save session on turn rather than at final response #1550
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
base: main
Are you sure you want to change the base?
Conversation
Addresses issue #1551 |
891074f
to
c5e05ba
Compare
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.
Thanks for taking the time to send this. At a glance, the changes look good, but we need unit tests verifying the patterns and we don't need the additional example.
@@ -0,0 +1,116 @@ | |||
import asyncio |
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 having this example, we need unit tests verifying the pattern
c5e05ba
to
e98c3cd
Compare
I removed the example and added a unit test to There were a few linting and formatting issues that |
src/agents/realtime/model_events.py
Outdated
@@ -84,6 +84,7 @@ class RealtimeModelInputAudioTranscriptionCompletedEvent: | |||
|
|||
type: Literal["input_audio_transcription_completed"] = "input_audio_transcription_completed" | |||
|
|||
|
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.
can you remove these unrelated changes to make the review easier?
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.
can you remove these unrelated changes to make the review easier?
Of course! I removed the final commit that had all the make lint/check-format
changes that weren't part of the bug fix.
e98c3cd
to
c8a5d26
Compare
The current implementation of sessions saves the session on the final output. This works as a "memory" of previous full conversations, but does not work if you need access to the session during the turn. A use case for this is providing access to the full conversation to an agent-as-tool during the turn.
This PR updates the
run
and_start_streaming
methods inrun.py
to save the session on each turn.The basic flow is:
Also included is an example file that shows the use of this pattern. It is an adapted version of the agents-as-tools example where a check agent is called within the same turn as the translation agents and examines their outputs via the conversation history, rather than as a generated input.
Resolves #1551