How to save the variable values from tools to agent extra_data

I was trying to save a variable value to agent extra_data from within one of its tool function, but not working.

when i initialize the agent with extra_data paramater, i can seen that it got saved in sqlite db. but when i try to do the same from agent’s tool function, then no values are getting saved in db.

below is the code snippet(dummy) of my agent & tool

def save_job_requirement_details(agent: Agent,requirement_text: str):
   
    print('agent.extra_data',agent.extra_data) #==> agent.extra_data {'req': 'req'}
    agent.extra_data['status'] = 'Python'
    print('agent.extra_data',agent.extra_data) #==>agent.extra_data {'req': 'req', 'status': 'Python'}


    return 'details saved successfully'


i have defined agent like this

 agent1 = Agent(
        name="Screener",
        model=azure_model,
        tools=[save_job_requirement_details]})

agent_main = Agent(
        name="Master",
       team=[agent1]
        model=azure_model,
        extra_data={'req':'req'})

even after executing the tool, db is still having the value ‘{‘req’:‘req’}’ not {‘req’: ‘req’, ‘status’: ‘Python’}

Note: im calling Master agent and trying to save data from slave agent’s tool.

Is it a bug or am i doing somethng wrong. Please help. :slight_smile:

Hi @akhilmstcs
Thanks for reaching out and for using Agno! I’ve looped in the right engineers to help with your question. We usually respond within 24 hours, but if this is urgent, just let us know, and we’ll do our best to prioritize it.
Appreciate your patience—we’ll get back to you soon! :smile:

hey @akhilmstcs
Really sorry for the late reply. I have debugged it, and adding instructions and extra_data in agent1 works.

def save_job_requirement_details(agent: Agent,requirement_text: str):
   
    print('agent.extra_data',agent.extra_data) #==> agent.extra_data {'req': 'req'}
    agent.extra_data['status'] = 'Python'
    print('agent.extra_data',agent.extra_data) #==>agent.extra_data {'req': 'req', 'status': 'Python'}


    return 'details saved successfully'

agent1 = Agent(
        name="Screener",
        model=OpenAIChat(id="gpt-4o"),
        tools=[save_job_requirement_details],
            extra_data={'req':'req'},
    instructions="""Process job requirements and save details using save_job_requirement_details tool.
    """
    )

agent_main = Agent(
        name="Master",
       team=[agent1],
        model=OpenAIChat(id="gpt-4o"),
        extra_data={'req':'req'},
        instructions="""Delegate job requirements to the Screener agent and save any updates.
        """
        )

response = agent_main.run()