forked from cleveragents/cleveragents-core
refactor: update logging and error handling in LLMAgent and TemplateRenderer
This commit is contained in:
@@ -222,7 +222,7 @@ class LLMAgent(AgentWithMemory):
|
||||
}
|
||||
pretty_context = pprint.pformat(display_context, indent=2)
|
||||
logger.debug(
|
||||
f"--- LLMAgent '{self.name}' render context ---\n{pretty_context}"
|
||||
f"--- LLMAgent '{self.name}' final render context ---\n{pretty_context}"
|
||||
)
|
||||
# --- END: ADDED FOR DEBUGGING ---
|
||||
|
||||
|
||||
@@ -252,11 +252,9 @@ class TemplateRenderer:
|
||||
else:
|
||||
raise TemplateError(f"Unsupported template engine: {self.engine_type}")
|
||||
except Exception as e:
|
||||
desc = (
|
||||
source_description or f"string starting with: '{template_str[:40]}...'"
|
||||
)
|
||||
desc = f" for {source_description}" if source_description else ""
|
||||
raise TemplateError(
|
||||
f"Failed to render template for {desc}: {str(e)}"
|
||||
f"Failed to render template string{desc}: {str(e)}"
|
||||
) from e
|
||||
|
||||
def get_template(self, name: str) -> str:
|
||||
|
||||
@@ -325,8 +325,8 @@ def step_impl(context):
|
||||
)
|
||||
original_process_response = context.agent.process_response
|
||||
|
||||
def mock_process_response(response):
|
||||
context.processed_response = original_process_response(response)
|
||||
def mock_process_response(response, ctx=None):
|
||||
context.processed_response = original_process_response(response, ctx)
|
||||
return context.processed_response
|
||||
|
||||
context.agent.process_response = mock_process_response
|
||||
@@ -353,8 +353,8 @@ def step_impl(context):
|
||||
)
|
||||
original_process_response = context.agent.process_response
|
||||
|
||||
def mock_process_response(response):
|
||||
context.processed_response = original_process_response(response)
|
||||
def mock_process_response(response, ctx=None):
|
||||
context.processed_response = original_process_response(response, ctx)
|
||||
return context.processed_response
|
||||
|
||||
context.agent.process_response = mock_process_response
|
||||
|
||||
Reference in New Issue
Block a user