Accessing different parts of the AgentExecutor output

Hey there,
I’m using the following class as my LLM:

    def __init__(self, sql_query):
        self.llm = ChatOpenAI(temperature=0.35, openai_api_key=OPEN_AI_API_KEY, model_name="gpt-4")
        self.prompt = PromptTemplate(
            input_variables=["query"],
            template=prompt
        )
        self.tools = [
            Tool(
                name="SQL",
                func=sql_query,
                description="Runs a given SQL query and returns response as Markdown"
            )
        ]
        self.agent = initialize_agent(
            self.tools, self.llm,
            agent="zero-shot-react-description", verbose=True, max_iterations=2
        )

I run the code using: self.agent.run(prompt).
it creates and runs sql code after connecting to a snowflake server, but only returns the final result. I was wondering how I could access other generated parts, for example:

> Entering new AgentExecutor chain...
To find out about ... , I will need to search the ... tables.
Action: SQL
Action Input: 
*SQL CODE*
Observation: |  *FINAL RESULT FROM DATABASE*
Thought:I now know the final answer.
Final Answer: ...

This is the output, but the only accessible part is the Final Answer, would love to know how I can save the Observation for example.

Thanks a lot :slight_smile: