-
Hi, I am trying to implement new_session method for my agent struct, but the method signature doesn't allow me to store the agent session object anywhere - &self is immutable:
In the TypeScript example, the approach is to update the sessions map - https://github.com/zed-industries/agent-client-protocol/blob/main/typescript/examples/agent.ts#L37 Any advice on how to store the session object in Rust? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Requiring exclusive access for these methods on all implementations seems like a strong requirement that isn't necessary. In the case where we are forwarding this over stdio, there isn't a strong need for it. If you are implementing this in process, than what we do is use interior mutability ( |
Beta Was this translation helpful? Give feedback.
Requiring exclusive access for these methods on all implementations seems like a strong requirement that isn't necessary. In the case where we are forwarding this over stdio, there isn't a strong need for it.
If you are implementing this in process, than what we do is use interior mutability (
RefCell
orMutex
or other sync primitive) to handle updating the internal state. We usually use this sort of pattern with Zed anyway, so it fit in well, and it infers less about the particular implementation. Hopefully that helps!