Created
February 17, 2026 15:07
-
-
Save pritipsingh/ff5a49c5d401f293f65d49e8b2414be7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """AgentOS with user feedback (human-in-the-loop). | |
| The agent uses UserFeedbackTools to pause and collect structured | |
| user choices (e.g. destination, budget) via the REST API. | |
| Run: | |
| cookbook/05_agent_os/agent_os_user_feedback.py | |
| """ | |
| from agno.agent import Agent | |
| from agno.db.sqlite import SqliteDb | |
| from agno.models.openai import OpenAIChat | |
| from agno.os import AgentOS | |
| from agno.tools.user_feedback import UserFeedbackTools | |
| # --------------------------------------------------------------------------- | |
| # Database (SQLite for local demo; use PostgresDb in production) | |
| # --------------------------------------------------------------------------- | |
| db = SqliteDb( | |
| db_file="tmp/agent_os_user_feedback.db", | |
| session_table="agent_sessions", | |
| ) | |
| # --------------------------------------------------------------------------- | |
| # Agent (same as user_feedback.py, with name and id for AgentOS) | |
| # --------------------------------------------------------------------------- | |
| travel_agent = Agent( | |
| name="Travel Assistant", | |
| id="Travel Assistant", | |
| model=OpenAIChat(id="gpt-4o-mini"), | |
| tools=[UserFeedbackTools()], | |
| instructions=[ | |
| "You are a helpful travel assistant.", | |
| "When the user asks you to plan a trip, use the ask_user tool to clarify their preferences.", | |
| ], | |
| markdown=True, | |
| db=db, | |
| ) | |
| # --------------------------------------------------------------------------- | |
| # AgentOS | |
| # --------------------------------------------------------------------------- | |
| agent_os = AgentOS( | |
| id="user-feedback-demo", | |
| description="AgentOS with user feedback (structured questions)", | |
| agents=[travel_agent], | |
| db=db, | |
| ) | |
| app = agent_os.get_app() | |
| if __name__ == "__main__": | |
| agent_os.serve(app="agent_os_user_feedback:app", port=7772) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment