From 7c23da8fd1b2881c37f074b1f925c7a223d5c20f Mon Sep 17 00:00:00 2001 From: zhonghao lu Date: Sat, 18 Oct 2025 14:49:11 +0800 Subject: [PATCH 1/2] config: disable all agents except ResearchAgent in initializatio --- python/configs/agent_cards/aswath_damodaran_agent.json | 2 +- python/configs/agent_cards/ben_graham_agent.json | 2 +- python/configs/agent_cards/bill_ackman_agent.json | 2 +- python/configs/agent_cards/cathie_wood_agent.json | 2 +- python/configs/agent_cards/charlie_munger_agent.json | 2 +- python/configs/agent_cards/fundamentals_analyst_agent.json | 2 +- python/configs/agent_cards/michael_burry_agent.json | 2 +- python/configs/agent_cards/mohnish_pabrai_agent.json | 2 +- python/configs/agent_cards/peter_lynch_agent.json | 2 +- python/configs/agent_cards/phil_fisher_agent.json | 2 +- python/configs/agent_cards/rakesh_jhunjhunwala_agent.json | 2 +- python/configs/agent_cards/sentiment_analyst_agent.json | 2 +- python/configs/agent_cards/stanley_druckenmiller_agent.json | 2 +- python/configs/agent_cards/technical_analyst_agent.json | 2 +- python/configs/agent_cards/trading_agents.json | 1 + python/configs/agent_cards/valuation_analyst_agent.json | 2 +- python/configs/agent_cards/warren_buffett_agent.json | 2 +- 17 files changed, 17 insertions(+), 16 deletions(-) diff --git a/python/configs/agent_cards/aswath_damodaran_agent.json b/python/configs/agent_cards/aswath_damodaran_agent.json index 5a043849a..bb1cd4633 100644 --- a/python/configs/agent_cards/aswath_damodaran_agent.json +++ b/python/configs/agent_cards/aswath_damodaran_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/ben_graham_agent.json b/python/configs/agent_cards/ben_graham_agent.json index e5b7647f4..aaf55b744 100644 --- a/python/configs/agent_cards/ben_graham_agent.json +++ b/python/configs/agent_cards/ben_graham_agent.json @@ -18,7 +18,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/bill_ackman_agent.json b/python/configs/agent_cards/bill_ackman_agent.json index be7b96c0d..0ca1700f9 100644 --- a/python/configs/agent_cards/bill_ackman_agent.json +++ b/python/configs/agent_cards/bill_ackman_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/cathie_wood_agent.json b/python/configs/agent_cards/cathie_wood_agent.json index 34f2fe614..5ca598951 100644 --- a/python/configs/agent_cards/cathie_wood_agent.json +++ b/python/configs/agent_cards/cathie_wood_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/charlie_munger_agent.json b/python/configs/agent_cards/charlie_munger_agent.json index 0783b90e9..56854aa0e 100644 --- a/python/configs/agent_cards/charlie_munger_agent.json +++ b/python/configs/agent_cards/charlie_munger_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/fundamentals_analyst_agent.json b/python/configs/agent_cards/fundamentals_analyst_agent.json index de7ad49ce..322d94b87 100644 --- a/python/configs/agent_cards/fundamentals_analyst_agent.json +++ b/python/configs/agent_cards/fundamentals_analyst_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/michael_burry_agent.json b/python/configs/agent_cards/michael_burry_agent.json index 9c446515e..cedaba8c0 100644 --- a/python/configs/agent_cards/michael_burry_agent.json +++ b/python/configs/agent_cards/michael_burry_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/mohnish_pabrai_agent.json b/python/configs/agent_cards/mohnish_pabrai_agent.json index d7da3c98a..8c4d53e3e 100644 --- a/python/configs/agent_cards/mohnish_pabrai_agent.json +++ b/python/configs/agent_cards/mohnish_pabrai_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/peter_lynch_agent.json b/python/configs/agent_cards/peter_lynch_agent.json index c4586d852..2d8ca82e3 100644 --- a/python/configs/agent_cards/peter_lynch_agent.json +++ b/python/configs/agent_cards/peter_lynch_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/phil_fisher_agent.json b/python/configs/agent_cards/phil_fisher_agent.json index aed469ad3..14e872978 100644 --- a/python/configs/agent_cards/phil_fisher_agent.json +++ b/python/configs/agent_cards/phil_fisher_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/rakesh_jhunjhunwala_agent.json b/python/configs/agent_cards/rakesh_jhunjhunwala_agent.json index 6b339f944..e64f69337 100644 --- a/python/configs/agent_cards/rakesh_jhunjhunwala_agent.json +++ b/python/configs/agent_cards/rakesh_jhunjhunwala_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/sentiment_analyst_agent.json b/python/configs/agent_cards/sentiment_analyst_agent.json index 54e227b20..4363dd602 100644 --- a/python/configs/agent_cards/sentiment_analyst_agent.json +++ b/python/configs/agent_cards/sentiment_analyst_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/stanley_druckenmiller_agent.json b/python/configs/agent_cards/stanley_druckenmiller_agent.json index 858569d52..93e387ad2 100644 --- a/python/configs/agent_cards/stanley_druckenmiller_agent.json +++ b/python/configs/agent_cards/stanley_druckenmiller_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/technical_analyst_agent.json b/python/configs/agent_cards/technical_analyst_agent.json index b7767adcf..4e285fea1 100644 --- a/python/configs/agent_cards/technical_analyst_agent.json +++ b/python/configs/agent_cards/technical_analyst_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/trading_agents.json b/python/configs/agent_cards/trading_agents.json index a6ea33899..20541542f 100644 --- a/python/configs/agent_cards/trading_agents.json +++ b/python/configs/agent_cards/trading_agents.json @@ -23,6 +23,7 @@ "US market" ] }], + "enabled": false, "provider": { "organization": "Tauric", "url": "https://arxiv.org/abs/2412.20138" diff --git a/python/configs/agent_cards/valuation_analyst_agent.json b/python/configs/agent_cards/valuation_analyst_agent.json index f0feeffcf..e6358019e 100644 --- a/python/configs/agent_cards/valuation_analyst_agent.json +++ b/python/configs/agent_cards/valuation_analyst_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", diff --git a/python/configs/agent_cards/warren_buffett_agent.json b/python/configs/agent_cards/warren_buffett_agent.json index 71e230345..9423764c3 100644 --- a/python/configs/agent_cards/warren_buffett_agent.json +++ b/python/configs/agent_cards/warren_buffett_agent.json @@ -19,7 +19,7 @@ ] } ], - "enabled": true, + "enabled": false, "metadata": { "version": "1.0.0", "author": "ValueCell Team", From eadf3257b93824738afa5ef0a21e36048e731af6 Mon Sep 17 00:00:00 2001 From: zhonghao lu Date: Sat, 18 Oct 2025 15:32:41 +0800 Subject: [PATCH 2/2] feat: add agent enable/disable API endpoint Add POST /agents/{agent_name}/enable endpoint to dynamically toggle agent status without service restart --- python/valuecell/server/api/routers/agent.py | 54 ++++++++++++++++++- python/valuecell/server/api/schemas/agent.py | 15 ++++++ .../server/services/agent_service.py | 41 ++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/python/valuecell/server/api/routers/agent.py b/python/valuecell/server/api/routers/agent.py index bd2f8ce9e..d24e8eded 100644 --- a/python/valuecell/server/api/routers/agent.py +++ b/python/valuecell/server/api/routers/agent.py @@ -7,7 +7,13 @@ from fastapi import APIRouter, Depends, HTTPException, Path, Query from sqlalchemy.orm import Session -from valuecell.server.api.schemas.agent import AgentListResponse, AgentResponse +from valuecell.server.api.schemas.agent import ( + AgentEnableRequest, + AgentEnableResponse, + AgentEnableSuccessResponse, + AgentListResponse, + AgentResponse, +) from valuecell.server.api.schemas.base import SuccessResponse from valuecell.server.db import get_db from valuecell.server.services.agent_service import AgentService @@ -124,4 +130,50 @@ async def get_agent_by_name( detail=f"Failed to retrieve agent information: {str(e)}", ) + @router.post( + "/{agent_name}/enable", + response_model=AgentEnableSuccessResponse, + summary="Update agent enable status", + description="Enable or disable an agent by its name", + ) + async def update_agent_enable_status( + agent_name: str = Path(..., description="Name of the agent"), + request: AgentEnableRequest = ..., + db: Session = Depends(get_db), + ) -> AgentEnableSuccessResponse: + """ + Update the enabled status of a specific agent by name. + + - **agent_name**: Name of the agent to update + - **enabled**: Whether to enable (true) or disable (false) the agent + + Returns updated agent status information, or 404 error if agent doesn't exist. + """ + try: + updated_agent = AgentService.update_agent_enabled( + db=db, agent_name=agent_name, enabled=request.enabled + ) + if not updated_agent: + raise HTTPException( + status_code=404, detail=f"Agent with name '{agent_name}' not found" + ) + + response_data = AgentEnableResponse( + agent_name=updated_agent.agent_name, + enabled=updated_agent.enabled, + message=f"Agent '{agent_name}' has been {'enabled' if request.enabled else 'disabled'} successfully" + ) + + return SuccessResponse.create( + data=response_data, + msg=f"Successfully {'enabled' if request.enabled else 'disabled'} agent '{agent_name}'" + ) + except HTTPException: + raise + except Exception as e: + raise HTTPException( + status_code=500, + detail=f"Failed to update agent status: {str(e)}", + ) + return router diff --git a/python/valuecell/server/api/schemas/agent.py b/python/valuecell/server/api/schemas/agent.py index a570c3396..ed90dba9e 100644 --- a/python/valuecell/server/api/schemas/agent.py +++ b/python/valuecell/server/api/schemas/agent.py @@ -108,6 +108,21 @@ class AgentQueryParams(BaseModel): ) +class AgentEnableRequest(BaseModel): + """Request model for updating agent enable status.""" + + enabled: bool = Field(..., description="Whether to enable or disable the agent") + + +class AgentEnableResponse(BaseModel): + """Response model for agent enable status update.""" + + agent_name: str = Field(..., description="Name of the agent") + enabled: bool = Field(..., description="Current enabled status") + message: str = Field(..., description="Status update message") + + # Type aliases for SuccessResponse AgentResponse = SuccessResponse[AgentData] AgentListResponse = SuccessResponse[AgentListData] +AgentEnableSuccessResponse = SuccessResponse[AgentEnableResponse] diff --git a/python/valuecell/server/services/agent_service.py b/python/valuecell/server/services/agent_service.py index d784e72e6..6d11053a0 100644 --- a/python/valuecell/server/services/agent_service.py +++ b/python/valuecell/server/services/agent_service.py @@ -2,6 +2,7 @@ Agent service layer for handling agent-related business logic. """ +from datetime import datetime from typing import Optional from sqlalchemy import and_, or_ @@ -106,6 +107,46 @@ def get_agent_by_id(db: Session, agent_id: int) -> Optional[AgentData]: updated_at=agent.updated_at, ) + @staticmethod + def update_agent_enabled(db: Session, agent_name: str, enabled: bool) -> Optional[AgentData]: + """ + Update the enabled status of an agent by name. + + Args: + db: Database session + agent_name: Name of the agent to update + enabled: New enabled status + + Returns: + Updated AgentData if found and updated, None if agent not found + """ + agent = db.query(Agent).filter(Agent.name == agent_name).first() + + if not agent: + return None + + # Update the enabled status and timestamp + agent.enabled = enabled + agent.updated_at = datetime.utcnow() + + # Commit the changes + db.commit() + db.refresh(agent) + + return AgentData( + id=agent.id, + agent_name=agent.name, + display_name=agent.display_name, + description=agent.description, + version=agent.version, + enabled=agent.enabled, + icon_url=agent.icon_url, + agent_metadata=agent.agent_metadata, + config=agent.config, + created_at=agent.created_at, + updated_at=agent.updated_at, + ) + @staticmethod def get_agent_by_name(db: Session, agent_name: str) -> Optional[AgentData]: """