Skip to content
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

Add GraphRun object to make use of next more ergonomic #833

Draft
wants to merge 1 commit into
base: dmontagu/stream-tool-calls
Choose a base branch
from

Conversation

dmontagu
Copy link
Contributor

@dmontagu dmontagu commented Feb 1, 2025

This is the result of trying to reduce the amount of stuff happening in Graph.run that wasn't just in next.

I made some related improvements I discovered while working on this in #834, but I think there are still some advantages to a GraphRun object.

The main two benefits of this are:

  • You don't have to pass state, deps, history, or infer_name after starting the "run". I understand that for the sake of interrupting etc. that that you need to be able to set these things, but it feels reasonable to me to interrupt the GraphRun as a whole — since we can start/stop runs from any node I don't see a problem with this. (I didn't expose a way to set the history of a run, but it would be trivial to add that.) And needing to keep a reference to deps etc., or even just pass the relevant arguments just feels kind of non-ergonomic when you just want actual streaming (not interrupts).
  • You get history managed for you; if we expect anyone using next to manage history themselves then the value of this is reduced, but we would still need to basically duplicate the history handling in Agent.next since Graph.next won't do it for us.

I expect we'll close this PR without merging, but I wanted to at least share the implementation as a proof of concept.

@dmontagu dmontagu changed the title Dmontagu/graph run object Add GraphRun object Feb 1, 2025
@dmontagu dmontagu changed the title Add GraphRun object Add GraphRun object to make use of next more ergonomic Feb 1, 2025
@github-actions github-actions bot temporarily deployed to deploy-preview February 1, 2025 00:55 Inactive
@dmontagu dmontagu mentioned this pull request Feb 1, 2025
@dmontagu dmontagu force-pushed the dmontagu/graph-run-object branch from 6ce755e to 571d805 Compare February 1, 2025 01:08
@dmontagu dmontagu changed the base branch from main to dmontagu/stream-tool-calls February 1, 2025 01:09
@dmontagu dmontagu force-pushed the dmontagu/stream-tool-calls branch from 1443b49 to c4e9180 Compare February 1, 2025 01:09
@dmontagu dmontagu force-pushed the dmontagu/graph-run-object branch from 571d805 to 04fc74c Compare February 1, 2025 01:10
@@ -184,19 +184,12 @@ async def main():

next_node = start_node
while True:
next_node = await self.next(next_node, history, state=state, deps=deps, infer_name=False)
next_node = await graph_run.next(next_node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The simplicity of this loop is the primary reason I want to have a graph_run object — it just feels like there's so much less cruft.

@github-actions github-actions bot temporarily deployed to deploy-preview February 1, 2025 01:13 Inactive
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.

1 participant