-
Notifications
You must be signed in to change notification settings - Fork 14
Update Agent List to Show Last Call Status #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Also worth to mentioned you need to execute and you can check by : to verify the calls we can visit : |
|
i cant able to run the migration file as i had some version conflict on my system |
WalkthroughThe changes implement a comprehensive agent call status tracking system across the backend and frontend. The backend now updates and persists an agent's Changes
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
frontend/src/components/StatusBadge.jsx (1)
37-41: Clarify time-zone handling forlastCallTime.
new Date(timeString).toLocaleString()uses the client’s locale/time-zone, which can confuse users distributed across regions. Consider formatting on the server or usingtoUTCString()/Intl.DateTimeFormatwith an explicit zone so everyone sees the same reference.frontend/src/components/AgentCard.jsx (1)
39-53: Minor UX tweak: prevent header wrap jitter on narrow screens.Long agent names push the badge to a second line, causing layout jump. Adding
flex-shrink:0on the badge (orwhite-space:nowrapon the name) keeps the row stable:-<StatusBadge - status={agent.last_call_status || 'idle'} - lastCallTime={agent.last_call_time} /> +<StatusBadge + style={{ flexShrink: 0 }} + status={agent.last_call_status || 'idle'} + lastCallTime={agent.last_call_time} />Purely cosmetic, but improves readability on mobile.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
backend/migration_add_agent_status.py(1 hunks)frontend/src/components/AgentCard.jsx(2 hunks)frontend/src/components/StatusBadge.jsx(1 hunks)
|
@Adez017 Can you provide a demo video |
|
No need for any demo, just the thing is i can't able to run the as there is version conflict for python in my environment |
|
when you run the file i twill update the schema in the DB and the frontend part will be reflected |
|
I think theres no pip installed in it Try For this
python -m ensurepip --upgrade This will bootstrap pip in that specific Python environment.
python -m pip install --upgrade pip
python -m pip install sqlalchemy |
|
what changes have you done with UI as this pr pr was regarding UI update |
|
let me revert back the changes |
This reverts commit 5031be9.
|
Hi @Hiteshydv001 @213sanjana , i had made the correct chnages, i guess i mixed up some ither repo changes there. Sorry for the inconvenience, just one work to do , only one time we need to run the file : to get teh chnages reflected in DB. please look aournd if git any issues let me know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
backend/src/services/campaign_service.py (2)
7-10: Drop unused imports flagged by Ruff
campaign_schemaandagent_servicearen’t referenced in this module.-from ..schemas import campaign as campaign_schema -from .agent_service import agent_service
127-132: Agent may remain non-idle after campaign endsThe reset to
"idle"triggers only if the last status was still"calling". After a successful or failed final call, the agent remains"completed"/"failed", leaving the UI in a busy state.Consider unconditionally resetting, or adding a configurable post-campaign status policy.
backend/src/api/routes/calls.py (1)
51-59: Preserve traceback when re-raising HTTP errorsRuff B904: use exception chaining for clarity.
- except Exception as e: - db_agent.last_call_status = "failed" - db.commit() - raise HTTPException(status_code=500, detail=f"Failed to initiate call. Error: {str(e)}") + except Exception as e: + db_agent.last_call_status = "failed" + db.commit() + raise HTTPException(status_code=500, + detail="Failed to initiate call.") from e
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
backend/set_default_agent_status.py.py(1 hunks)backend/src/api/routes/calls.py(5 hunks)backend/src/schemas/agent.py(1 hunks)backend/src/services/campaign_service.py(7 hunks)frontend/src/components/AgentCard.jsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/components/AgentCard.jsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
backend/src/schemas/agent.py (1)
backend/src/models/agent.py (1)
Agent(5-11)
backend/set_default_agent_status.py.py (2)
backend/src/schemas/agent.py (1)
Agent(12-18)backend/src/models/agent.py (1)
Agent(5-11)
🪛 Ruff (0.12.2)
backend/src/services/campaign_service.py
8-8: ..schemas.campaign imported but unused
Remove unused import: ..schemas.campaign
(F401)
10-10: .agent_service.agent_service imported but unused
Remove unused import: .agent_service.agent_service
(F401)
backend/src/api/routes/calls.py
54-54: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
🔇 Additional comments (1)
backend/set_default_agent_status.py.py (1)
29-31: Attribute check will still fail without mapped column
hasattr(..., 'last_call_status')is true only if the ORM model already defines the column. Without it (see previous comment) the assignment here will raise. Merge this script after the model & Alembic migration are in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
backend/set_default_agent_status.py (3)
10-12: Prefer robust import pathing; avoid brittle sys.path hacksUsing pathlib is more robust and cross-platform. Alternatively, run the script with PYTHONPATH or package entry-points.
Apply:
+from pathlib import Path @@ -# Add the src directory to the Python path -sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) +# Add the src directory to the Python path +sys.path.insert(0, str(Path(__file__).resolve().parent / 'src'))
33-41: Guard potentially sensitive output and large dumps behind a verbosity flagPrinting all agent names/statuses may leak PII and spam logs for large datasets. Make it opt-in.
@@ - # Show current status of all agents - print("\n📋 Current agent statuses:") - for agent in agents: - print(f" Agent {agent.id} ({agent.name}): {agent.last_call_status}") + if os.getenv("VERBOSE", "0") == "1": + print("\n📋 Current agent statuses:") + # Optionally cap to first N rows + N = int(os.getenv("PRINT_LIMIT", "50")) + rows = db.query(Agent.id, Agent.name, Agent.last_call_status).limit(N).all() + for agent_id, agent_name, status in rows: + print(f" Agent {agent_id} ({agent_name}): {status}") + remaining = db.query(Agent).count() - len(rows) + if remaining > 0: + print(f" ... and {remaining} more")
42-46: Exit non-zero on failure and include traceback for easier debuggingCatching Exception and printing a line hides the stacktrace and returns 0. Return an error code and print the traceback.
+import traceback @@ - except Exception as e: - print(f"❌ Error updating agents: {e}") - db.rollback() + except Exception as e: + print(f"❌ Error updating agents: {e}") + traceback.print_exc() + db.rollback() + sys.exit(1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
backend/set_default_agent_status.py(1 hunks)
🔇 Additional comments (1)
backend/set_default_agent_status.py (1)
21-35: Use a single bulk UPDATE for scalabilityFetching and updating every
Agentin Python loads all rows into memory and incurs extra round-trips. Replace the per-row loop with one SQLUPDATEstatement.• File to update:
backend/set_default_agent_status.pyChoose the implementation that matches your SQLAlchemy version:
Option A – ORM-style bulk UPDATE (works in SQLAlchemy 1.4+):
from sqlalchemy import or_ @@ - db = SessionLocal() - try: - # Get all agents - agents = db.query(Agent).all() - - updated_count = 0 - for agent in agents: - # Set to idle if no status or empty status - if not hasattr(agent, 'last_call_status') or not agent.last_call_status: - agent.last_call_status = 'idle' - updated_count += 1 - - db.commit() - print(f"✅ Updated {updated_count} agents to 'idle' status") - print(f"📊 Total agents in database: {len(agents)}") + db = SessionLocal() + try: + updated_count = ( + db.query(Agent) + .filter(or_(Agent.last_call_status == None, Agent.last_call_status == "")) + .update({Agent.last_call_status: "idle"}, synchronize_session=False) + ) + db.commit() + total = db.query(Agent).count() + print(f"✅ Updated {updated_count} agents to 'idle' status") + print(f"📊 Total agents in database: {total}")Option B – Core UPDATE (SQLAlchemy 2.x style):
from sqlalchemy import or_, update, select @@ - db = SessionLocal() - try: - # Get all agents - agents = db.query(Agent).all() - - updated_count = 0 - for agent in agents: - # Set to idle if no status or empty status - if not hasattr(agent, 'last_call_status') or not agent.last_call_status: - agent.last_call_status = 'idle' - updated_count += 1 - - db.commit() - print(f"✅ Updated {updated_count} agents to 'idle' status") - print(f"📊 Total agents in database: {len(agents)}") + db = SessionLocal() + try: + result = db.execute( + update(Agent) + .where(or_(Agent.last_call_status == None, Agent.last_call_status == "")) + .values(last_call_status="idle") + ) + db.commit() + updated_count = result.rowcount or 0 + total = db.execute(select(Agent).count()).scalar_one() + print(f"✅ Updated {updated_count} agents to 'idle' status") + print(f"📊 Total agents in database: {total}")To determine which option to apply, check your installed SQLAlchemy version:
python -c "import sqlalchemy; print(sqlalchemy.__version__)"If you’re not pinning a version, consider adding one (e.g.,
sqlalchemy>=1.4,<2.0orsqlalchemy>=2.0) inbackend/requirements.txt.
|
Hi @Hiteshydv001 . please look into it |
|
@Adez017 attach a video and try to build the project with docker |
|
How uch more time will be required |
|
because it take a lot of time to test it on codespace due to less cloud storage |
|
Any updates @Adez017 ?? |
does we have any simpler sample code to test it , if possible we can proceed with that |




Hi @Hiteshydv001 , as per requested in #21 , i had added the necessary changes . please take a look
Summary by CodeRabbit
New Features
Chores