fix(agent): wire up agent persistence and fix broken logger import - #235
Open
rhiannalitchfield wants to merge 1 commit into
Open
fix(agent): wire up agent persistence and fix broken logger import#235rhiannalitchfield wants to merge 1 commit into
rhiannalitchfield wants to merge 1 commit into
Conversation
…uGraph-family#40) PR TuGraph-family#234 added the AgentDao/AgentDo persistence layer for issue TuGraph-family#40, but left two gaps that meant agents were still never actually persisted: - AgentService never received the AgentDao instance (set_agent_dao() was never called from anywhere in the real app), so _agent_dao was always None and set_leadder()/add_expert() never persisted anything. - builtin_leader_state.py, agent_dao.py, agent_service.py, reasoner_factory.py, and workflow_factory.py all import a `app.utils.logger` module that does not exist in this codebase, raising ModuleNotFoundError as soon as any of them are imported. This change auto-wires the already-initialized AgentDao singleton into AgentService on construction, persists the leader/expert configuration when set_leadder()/add_expert() are called (the path used by AgentWrapper.build(), the real agent-creation entry point), and fixes the logger imports to use the existing Chat2GraphLogger. Adds test/unit/test_agent_persistence.py covering AgentDao save/round-trip/get_leader behavior and the new AgentService wiring. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #40.
#234 added the
AgentDao/AgentDopersistence layer to address #40, but two gaps meant agents were still never actually persisted in practice:AgentService.set_agent_dao()is defined onAgentService/LeaderState, but nothing in the application ever calls it —AgentWrapper.build(), the actual entry point used to constructLeader/Expertagents, only callsagent_service.set_leadder()/agent_service.add_expert(). SoAgentService._agent_daowas alwaysNone, andsave_agent_config()was never reached.builtin_leader_state.py,agent_dao.py,agent_service.py,reasoner_factory.py, andworkflow_factory.pyall dofrom app.utils.logger import logger, but noapp/utils/logger.pymodule exists in this codebase (the rest of the project usesapp.core.common.logger.Chat2GraphLogger). This raisesModuleNotFoundErrorthe moment any of these modules are imported, so the persistence code path couldn't even be exercised, tested, or run.Changes
agent_service.py:AgentService.__init__now grabs the already-initializedAgentDao.instance(theDaoFactoryinitializes all DAOs beforeServiceFactoryinitializes the services, so it's available by construction time).set_leadder()andadd_expert()now callAgentDao.save_agent_config()so agents created via the normal SDK path (AgentWrapper.build()) are actually persisted.app.utils.loggerimport in the 5 affected files to useChat2GraphLogger.get_logger(__name__), matching the rest of the codebase.test/unit/test_agent_persistence.pycovering:AgentService.set_leadder()persists the leader viaAgentDaoAgentService.add_expert()persists the expert viaAgentDaoAgentDao.save_agent_config()/get_agent_config()round-tripAgentDao.get_leader()Test plan
pytest test/unit/test_agent_persistence.pypasses (4/4)test/unitsuite (excluding tests that were already broken onmasterdue to the optional/commented-outdbgptdependency and external services like MemFuse/LLM API access) — no new failures introducedruff checkon the touched files — no new issues (cleaned up the import-sort warnings introduced by this change; pre-existing lint issues inagent_dao.py/workflow_factory.py/reasoner_factory.pyfrom feat(dal): implement persistence for Agent instances in database #234 are left untouched as out of scope for this fix)Note: I'm a first-time contributor to this project (see discussion on #40) — happy to adjust based on review feedback.