5 comments

[ 237 ms ] story [ 238 ms ] thread
React turns out to be a powerful tool to management the state of anything hierarchical and dynamic.

For the UI, we can show stuff dynamically with JSX; and the JSX would include actions that let user modify the state; the updated the state would trigger a re-rendering of UI to reflect the latest the state.

What if we can apply this paradigm to model Human + AI interacting with a shared piece of state? We can let React and LLM see the same state and use the same tools to change that change.

Nice idea. I'd love to try it in my project. One thing I am missing is that the LLM can only be triggered by user actions on the UI or some asynchronous data fetching logic. Is it possible to make it autonomous?

Maybe useEffect can help agent stay in an infinite loop? The "foot gun" is finally useful!

OK, but why do you need a new set of hooks for this? You can achieve the same thing by putting all your agent-related code into a reducer and just using Context.
I thought it might be easier to piecemeal add LLM functionality if we can reuse the existing structure of the app.