Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ async def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
"""
pass

async def update_progress(self, progress: float, status: str = "running"):
def update_progress(self, progress: float, status: str = "running"):
self.state.progress = progress
self.state.status = status
await self._sync_state()
self._sync_state()
logger.info(
f"Agent {self.agent_type} progress updated",
extra={
Expand All @@ -49,7 +49,7 @@ async def update_progress(self, progress: float, status: str = "running"):
}
)

async def _sync_state(self):
def _sync_state(self):
"""
Syncs current agent state to Firestore.
Rule 4.3 compliant: Always save intermediate state to Firestore.
Expand Down
2 changes: 1 addition & 1 deletion backend/agents/contract_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ContractAgent(BaseAgent):
def __init__(self, session_id: str):
super().__init__("contract", session_id)
self.gemini = GeminiService()
self.gemini = gemini_client

async def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
"""
Expand Down
1 change: 1 addition & 0 deletions backend/agents/linkedin_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class LinkedinAgent(BaseAgent):
def __init__(self, session_id: str):
super().__init__("linkedin", session_id)
self.linkedin_service = linkedin_service
self.gemini = gemini_client

async def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
"""
Expand Down
6 changes: 3 additions & 3 deletions backend/agents/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def execute_agent_with_retry(self, agent_type: str, context: Dict[str, Any

agent.state.status = "running"
agent.state.started_at = datetime.now(timezone.utc)
await agent._sync_state()
agent._sync_state()

while retries <= max_retries:
try:
Expand All @@ -49,7 +49,7 @@ async def execute_agent_with_retry(self, agent_type: str, context: Dict[str, Any
agent.state.progress = 100.0
agent.state.result = result
agent.state.completed_at = datetime.now(timezone.utc)
await agent._sync_state()
agent._sync_state()

logger.info(
f"Agent {agent_type} completed successfully",
Expand Down Expand Up @@ -78,7 +78,7 @@ async def execute_agent_with_retry(self, agent_type: str, context: Dict[str, Any
agent.state.status = "failed"
agent.state.error = str(e)
agent.state.completed_at = datetime.now(timezone.utc)
await agent._sync_state()
agent._sync_state()
logger.error(
f"Agent {agent_type} exhausted all retries",
extra={
Expand Down
1 change: 0 additions & 1 deletion backend/tests/test_contract_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
async def test_contract_agent_run(mock_openai):
with patch("backend.agents.contract_agent.GeminiService", return_value=mock_openai), \
patch("backend.agents.base.firebase_service"):

agent = ContractAgent(session_id="test-session")
context = {
"contract_text": "Sample US employment contract with relocation lock-in.",
Expand Down
3 changes: 2 additions & 1 deletion backend/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ async def test_orchestrator_executes_agent_and_updates_state(mock_job_agent):
result = await orchestrator.execute_agent_with_retry("job", context)

mock_job_agent.run.assert_awaited_once_with(context)
mock_job_agent._sync_state.assert_awaited() # Should be called multiple times for state updates
mock_job_agent._sync_state.assert_called() # Should be called multiple times for state updates

assert mock_job_agent.state.status == "completed"
assert mock_job_agent.state.progress == 100.0
Expand Down Expand Up @@ -241,3 +241,4 @@ async def test_orchestrator_handles_persistent_agent_failure(mock_job_agent):
assert "Persistent simulated failure" in mock_job_agent.state.error
assert result == {"status": "failed", "error": "Persistent simulated failure"}


2 changes: 1 addition & 1 deletion backend/tests/test_job_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@pytest.mark.asyncio
async def test_job_agent_run(mock_firecrawl):
# Patch FirecrawlService and firebase_service to avoid real network/db calls
with patch("backend.agents.job_agent.FirecrawlService", return_value=mock_firecrawl), \
with patch("backend.agents.job_agent.firecrawl_service", mock_firecrawl), \
patch("backend.agents.base.firebase_service") as mock_fb:

agent = JobAgent(session_id="test-session")
Expand Down
1 change: 0 additions & 1 deletion backend/tests/test_linkedin_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
async def test_linkedin_agent_run(mock_openai):
with patch("backend.agents.linkedin_agent.gemini_service", mock_openai), \
patch("backend.agents.base.firebase_service"):

agent = LinkedinAgent(session_id="test-session")
context = {
"recruiter_name": "Jane Smith",
Expand Down
1 change: 0 additions & 1 deletion backend/tests/test_resume_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ async def test_resume_agent_run(mock_openai):
mock_openai.generate_structured_response = AsyncMock(return_value="Mock LLM Response")
with patch("backend.agents.resume_agent.gemini_service", mock_openai), \
patch("backend.agents.base.firebase_service"):

agent = ResumeAgent(session_id="test-session")
context = {
"resume_text": "NYSC Software Engineer",
Expand Down