chore: server runtime type - #6774
Conversation
Sydney Runkle (sydney-runkle)
left a comment
There was a problem hiding this comment.
Am I understanding that the information that we'd want to access here would be:
- runtime context
- user info
- access context
I presume store and stream writer wouldn't be accessible, but maybe I'm not quite understanding where this would be plumbed through.
If so, might make sense to have a different data structure with just these? Specifically I'm a little concerned about making "runtime" accessible before runtime...
Not fully opposed to this though, I've been thinking about an AgentRuntime concept for create_agent :).
| !!! warning "Beta" | ||
| This API is in beta and may change in future releases. |
There was a problem hiding this comment.
Love
0f62839 to
15e03b2
Compare
15e03b2 to
a75ed5e
Compare
Sydney Runkle (sydney-runkle)
left a comment
There was a problem hiding this comment.
Do we want to call it XXXRuntime? ServerContext probably even more confusing?
Lots of the terms we use are overloaded, just wanted to check.
It makes me feel better that we're not inheriting from langgraph's runtime because for the read cases we'd have to manually construct a Runtime instance which feels wrong.
|
|
||
|
|
||
| @dataclass(kw_only=True, slots=True, frozen=True) | ||
| class _ServerRuntimeBase(Generic[ContextT]): |
There was a problem hiding this comment.
why is this one generic on context t?
There was a problem hiding this comment.
Lol should only be the execution one
There was a problem hiding this comment.
Ah jk. want it for execution_runtime() to show the return type. Can also create a sibling to execution context butI think I prefer to just keep onthe base for now.
| @property | ||
| def execution_runtime(self) -> _ExecutionRuntime[ContextT] | None: |
There was a problem hiding this comment.
is this method actually helpful? maybe would be helpful to see usage somewhere
There was a problem hiding this comment.
Very useful. I show examples below in the docstring. We do this in a few different projects already using our n on-type-safe equivalents
eec1513 to
a84977d
Compare
a84977d to
87064cd
Compare
Main jtbd here:
a) clarify who/how a graph is being accessed and make the factory aware of the
contextwhere relevant (and make it obvious when it is available)b) make it more clear when you can bypass / defer resources with expensive lifespans (like MCp connections)
c) make auth access more type-safe.
Gives us room to add other information, like:
---- old
Can start doing things like this:
etc.
Points of expected confusion:
For maintainers, related draft PR int he server #6774