StreamlitCallbackHandler is not displaying the Though/Action integraction on webui

If you’re creating a debugging post, please include the following info:

  1. Share the link to the public app (deployed on Community Cloud).
  2. Share the link to your app’s public GitHub repository (including a requirements file).
  3. Share the full text of the error message (not a screenshot).
  4. Share the Streamlit and Python versions.

I am using this to display the interaction on stremlit web ui, show the interaction in logs though. Code as follows:
Please advice. Thanks for your help
streamlit version : 1.27.2
I am using lightning.ai stidio


container = st.container()
callback_handler = StreamlitCallbackHandler(parent_container=container)
output = custom_function(callbackhandler)
st.write(output)


def custom_function(callbackhandler)-> dict:

agent_executor = AgentExecutor(agent=agent, tools=tools, callback_handler=callbackhandler)
return agent_executor.invoke(prompt)