Skip to content

Enable dynamic context data#194

Merged
scottpersinger merged 1 commit intomainfrom
dynamic_context_vars
Jun 2, 2025
Merged

Enable dynamic context data#194
scottpersinger merged 1 commit intomainfrom
dynamic_context_vars

Conversation

@scottpersinger
Copy link
Collaborator

This simple PR allows someone to specify run_context data via a function that gets invoked every time, rather than simple static data. This is super useful for your agent to, for example, have access to data you want to load from a database each time:

        def get_current_trips():
            current_trips = session.query(Trip).all()
            trip_list = "\n".join([f"{t.id}: {t.title} ({t.start_date} - {t.end_date})" for t in current_trips])
            return trip_list

        runner = AgentRunner(new_agent)
        runner.repl_loop({"trip_id": trip.id, "current_trips": get_current_trips})

So supplying current_trips as a function means that the function gets invoked every time before the next turn.

@scottpersinger scottpersinger merged commit 87f8355 into main Jun 2, 2025
2 checks passed
@scottpersinger scottpersinger deleted the dynamic_context_vars branch June 2, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants