mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-30 17:38:17 -05:00
refactor: remove more inline comments per no-comments guideline
- Remove inline comment from DecompositionResult.type field - Remove "Convert typed dicts" comments from decompose_goal, generate_agent, generate_agent_patch - Remove inline comments from _sanitize_error_details regex operations - Remove inline comments from get_user_message_for_error error handling
This commit is contained in:
@@ -74,7 +74,7 @@ class DecompositionStep(TypedDict, total=False):
|
||||
class DecompositionResult(TypedDict, total=False):
|
||||
"""Result from decompose_goal - can be instructions, questions, or error."""
|
||||
|
||||
type: str # "instructions", "clarifying_questions", "error", etc.
|
||||
type: str
|
||||
steps: list[DecompositionStep]
|
||||
questions: list[dict[str, Any]]
|
||||
error: str
|
||||
@@ -518,7 +518,6 @@ async def decompose_goal(
|
||||
"""
|
||||
_check_service_configured()
|
||||
logger.info("Calling external Agent Generator service for decompose_goal")
|
||||
# Convert typed dicts to plain dicts for external service
|
||||
result = await decompose_goal_external(
|
||||
description, context, _to_dict_list(library_agents)
|
||||
)
|
||||
@@ -544,7 +543,6 @@ async def generate_agent(
|
||||
"""
|
||||
_check_service_configured()
|
||||
logger.info("Calling external Agent Generator service for generate_agent")
|
||||
# Convert typed dicts to plain dicts for external service
|
||||
result = await generate_agent_external(
|
||||
dict(instructions), _to_dict_list(library_agents)
|
||||
)
|
||||
@@ -761,7 +759,6 @@ async def generate_agent_patch(
|
||||
"""
|
||||
_check_service_configured()
|
||||
logger.info("Calling external Agent Generator service for generate_agent_patch")
|
||||
# Convert typed dicts to plain dicts for external service
|
||||
return await generate_agent_patch_external(
|
||||
update_request, current_agent, _to_dict_list(library_agents)
|
||||
)
|
||||
|
||||
@@ -18,21 +18,15 @@ def _sanitize_error_details(details: str) -> str:
|
||||
Returns:
|
||||
Sanitized error details safe for user display
|
||||
"""
|
||||
# Remove file paths (Unix-style)
|
||||
sanitized = re.sub(
|
||||
r"/[a-zA-Z0-9_./\-]+\.(py|js|ts|json|yaml|yml)", "[path]", details
|
||||
)
|
||||
# Remove file paths (Windows-style)
|
||||
sanitized = re.sub(r"[A-Z]:\\[a-zA-Z0-9_\\.\\-]+", "[path]", sanitized)
|
||||
# Remove database URLs
|
||||
sanitized = re.sub(
|
||||
r"(postgres|mysql|mongodb|redis)://[^\s]+", "[database_url]", sanitized
|
||||
)
|
||||
# Remove URLs with credentials
|
||||
sanitized = re.sub(r"https?://[^:]+:[^@]+@[^\s]+", "[url]", sanitized)
|
||||
# Remove line numbers from stack traces
|
||||
sanitized = re.sub(r", line \d+", "", sanitized)
|
||||
# Remove "File" references from stack traces
|
||||
sanitized = re.sub(r'File "[^"]+",?', "", sanitized)
|
||||
|
||||
return sanitized.strip()
|
||||
@@ -92,11 +86,8 @@ def get_user_message_for_error(
|
||||
else:
|
||||
base_message = f"Failed to {operation}. Please try again."
|
||||
|
||||
# Add error details if provided (sanitized and truncated)
|
||||
if error_details:
|
||||
# Sanitize to remove sensitive information
|
||||
details = _sanitize_error_details(error_details)
|
||||
# Truncate long error details
|
||||
if len(details) > 200:
|
||||
details = details[:200] + "..."
|
||||
base_message += f"\n\nTechnical details: {details}"
|
||||
|
||||
Reference in New Issue
Block a user