Skip to content

Commit 801ba8a

Browse files
niksacdevclaude
andcommitted
fix: resolve PR validation errors and improve code quality
- Fix critical linting and type errors in safe_evaluator.py - Fix import errors in test files to match new repository structure - Resolve 500+ linting issues (96% reduction from 5600+ to 180) - Update test imports from mcp_servers to loan_processing.tools.mcp_servers - Fix line length issues and code formatting - Ensure security vulnerability fixes are properly applied - Maintain repository separation architecture (agents/ vs tools/) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 7f85dd3 commit 801ba8a

File tree

34 files changed

+984
-985
lines changed

34 files changed

+984
-985
lines changed

loan_processing/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
class LoanProcessingSystem:
1717
"""Main entry point for the loan processing system with multi-provider support."""
18-
18+
1919
def __init__(self, provider: str = "openai"):
2020
"""
2121
Initialize the loan processing system with specified provider.
22-
22+
2323
Args:
2424
provider: Provider name (e.g., "openai", "semantic_kernel", "autogen")
2525
"""
2626
self.provider = provider
2727
self.engine = self._create_engine(provider)
28-
28+
2929
def _create_engine(self, provider: str):
3030
"""Create provider-specific orchestration engine."""
3131
if provider == "openai":
@@ -40,31 +40,31 @@ def _create_engine(self, provider: str):
4040
else:
4141
available_providers = ["openai", "semantic_kernel", "autogen"]
4242
raise ValueError(f"Unknown provider: {provider}. Available: {available_providers}")
43-
43+
4444
async def process_application(
45-
self,
46-
application: LoanApplication,
45+
self,
46+
application: LoanApplication,
4747
pattern: str = "sequential",
48-
model: Optional[str] = None
48+
model: str | None = None
4949
) -> LoanDecision:
5050
"""
5151
Process a loan application using the configured provider.
52-
52+
5353
Args:
5454
application: Loan application to process
5555
pattern: Orchestration pattern to use (e.g., "sequential", "parallel")
5656
model: Optional model override for this processing
57-
57+
5858
Returns:
5959
Loan decision result
6060
"""
6161
return await self.engine.execute_pattern(pattern, application, model)
62-
62+
6363
def get_available_patterns(self) -> list[str]:
6464
"""Get list of available orchestration patterns for this provider."""
6565
# This could be enhanced to dynamically discover patterns
6666
return ["sequential", "parallel"]
67-
67+
6868
def get_provider_info(self) -> dict[str, str]:
6969
"""Get information about the current provider."""
7070
return {
@@ -92,9 +92,9 @@ def create_autogen_system() -> LoanProcessingSystem:
9292

9393
__all__ = [
9494
"LoanProcessingSystem",
95-
"create_openai_system",
95+
"create_openai_system",
9696
"create_semantic_kernel_system",
9797
"create_autogen_system",
9898
"LoanApplication",
9999
"LoanDecision"
100-
]
100+
]

loan_processing/agents/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# Future providers will be added here:
1212
# AVAILABLE_PROVIDERS = ["openai", "semantic_kernel", "autogen"]
1313

14-
__all__ = ["AVAILABLE_PROVIDERS"]
14+
__all__ = ["AVAILABLE_PROVIDERS"]

loan_processing/agents/providers/openai/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
including orchestration engine, pattern executors, and agent registry.
66
"""
77

8-
from loan_processing.agents.providers.openai.orchestration.engine import OrchestrationEngine, OrchestrationContext
98
from loan_processing.agents.providers.openai.agentregistry import AgentRegistry
9+
from loan_processing.agents.providers.openai.orchestration.engine import OrchestrationContext, OrchestrationEngine
1010

1111
__all__ = [
1212
"OrchestrationEngine",
13-
"OrchestrationContext",
13+
"OrchestrationContext",
1414
"AgentRegistry"
1515
]

loan_processing/agents/providers/openai/agentregistry.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
from __future__ import annotations
1010

11-
import yaml
12-
from pathlib import Path
13-
from typing import Dict, List, Any, Optional
11+
from typing import Any
1412

1513
from agents import Agent
1614
from agents.mcp.server import MCPServerSse
@@ -20,16 +18,16 @@
2018

2119
class MCPServerFactory:
2220
"""Factory for creating MCP server instances."""
23-
24-
_server_cache: Dict[str, MCPServerSse] = {}
25-
21+
22+
_server_cache: dict[str, MCPServerSse] = {}
23+
2624
@classmethod
2725
def get_server(cls, server_type: str) -> MCPServerSse:
2826
"""Get or create an MCP server instance."""
2927
if server_type not in cls._server_cache:
3028
cls._server_cache[server_type] = cls._create_server(server_type)
3129
return cls._server_cache[server_type]
32-
30+
3331
@classmethod
3432
def _create_server(cls, server_type: str) -> MCPServerSse:
3533
"""Create a new MCP server instance from configuration."""
@@ -39,66 +37,66 @@ def _create_server(cls, server_type: str) -> MCPServerSse:
3937

4038
class AgentRegistry:
4139
"""Central registry for agent types and configurations."""
42-
40+
4341
@classmethod
4442
def create_agent(cls, agent_type: str, model: str | None = None) -> Agent:
4543
"""
4644
Create a configuration-driven agent instance.
47-
45+
4846
Agents are created based on external configuration files,
4947
making it easy to add new agent types without code changes.
50-
48+
5149
Args:
5250
agent_type: Type of agent to create (defined in agents.yaml)
5351
model: OpenAI model to use (e.g., "gpt-4")
54-
52+
5553
Returns:
5654
Configured Agent instance without hardcoded workflow dependencies
57-
55+
5856
Raises:
5957
ValueError: If agent_type is not defined in configuration
6058
"""
6159
# Load agent configuration
6260
agent_config = ConfigurationLoader.get_agent_config(agent_type)
63-
61+
6462
# Create MCP server instances for this agent
6563
mcp_servers = [
66-
MCPServerFactory.get_server(server_type)
64+
MCPServerFactory.get_server(server_type)
6765
for server_type in agent_config["mcp_servers"]
6866
]
69-
67+
7068
# Load persona instructions (without handoff configurations)
7169
persona_instructions = load_persona(agent_config["persona_file"])
72-
70+
7371
# Add structured output requirements for orchestration
7472
enhanced_instructions = OutputFormatGenerator.add_structured_output_instructions(
75-
persona_instructions,
73+
persona_instructions,
7674
agent_config.get("output_format", {})
7775
)
78-
76+
7977
return Agent(
8078
name=agent_config["name"],
8179
instructions=enhanced_instructions,
8280
model=model,
8381
mcp_servers=mcp_servers,
8482
# No handoffs - orchestrator manages workflow
8583
)
86-
84+
8785
@classmethod
88-
def get_agent_info(cls, agent_type: str) -> Dict[str, Any]:
86+
def get_agent_info(cls, agent_type: str) -> dict[str, Any]:
8987
"""Get information about an agent type from configuration."""
9088
return ConfigurationLoader.get_agent_config(agent_type).copy()
91-
89+
9290
@classmethod
93-
def list_agent_types(cls) -> List[str]:
91+
def list_agent_types(cls) -> list[str]:
9492
"""Get list of available agent types from configuration."""
9593
return ConfigurationLoader.list_agent_types()
96-
94+
9795
@classmethod
98-
def get_agent_capabilities(cls, agent_type: str) -> List[str]:
96+
def get_agent_capabilities(cls, agent_type: str) -> list[str]:
9997
"""Get capabilities of a specific agent type."""
10098
return ConfigurationLoader.get_agent_capabilities(agent_type)
101-
99+
102100
@classmethod
103101
def reload_configuration(cls) -> None:
104102
"""Force reload of configuration from disk."""
@@ -107,4 +105,4 @@ def reload_configuration(cls) -> None:
107105
MCPServerFactory._server_cache.clear()
108106

109107

110-
__all__ = ["AgentRegistry", "MCPServerFactory"]
108+
__all__ = ["AgentRegistry", "MCPServerFactory"]

loan_processing/agents/providers/openai/orchestration/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
optimized for OpenAI Agents SDK.
66
"""
77

8-
from .engine import OrchestrationEngine, OrchestrationContext
9-
from .sequential import SequentialPatternExecutor
8+
from .base import AgentExecutionService, HandoffValidationService, PatternExecutor
9+
from .engine import OrchestrationContext, OrchestrationEngine
1010
from .parallel import ParallelPatternExecutor
11-
from .base import PatternExecutor, AgentExecutionService, HandoffValidationService
11+
from .sequential import SequentialPatternExecutor
1212

1313
__all__ = [
14-
"OrchestrationEngine",
14+
"OrchestrationEngine",
1515
"OrchestrationContext",
1616
"SequentialPatternExecutor",
1717
"ParallelPatternExecutor",
1818
"PatternExecutor",
19-
"AgentExecutionService",
19+
"AgentExecutionService",
2020
"HandoffValidationService"
21-
]
21+
]

0 commit comments

Comments
 (0)