mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
feat(agent): Improve history format for code flow execution results
This commit is contained in:
@@ -102,6 +102,8 @@ class ActionHistoryComponent(
|
||||
|
||||
@staticmethod
|
||||
def _make_result_message(episode: Episode, result: ActionResult) -> ChatMessage:
|
||||
from forge.components.code_flow_executor import CodeFlowExecutionComponent
|
||||
|
||||
if result.status == "success":
|
||||
return (
|
||||
ToolResultMessage(
|
||||
@@ -110,11 +112,18 @@ class ActionHistoryComponent(
|
||||
)
|
||||
if episode.action.raw_message.tool_calls
|
||||
else ChatMessage.user(
|
||||
f"{episode.action.use_tool.name} returned: "
|
||||
(
|
||||
"Execution result:"
|
||||
if (
|
||||
episode.action.use_tool.name
|
||||
== CodeFlowExecutionComponent.execute_code_flow.name
|
||||
)
|
||||
else f"{episode.action.use_tool.name} returned:"
|
||||
)
|
||||
+ (
|
||||
f"```\n{result.outputs}\n```"
|
||||
f"\n```\n{result.outputs}\n```"
|
||||
if "\n" in str(result.outputs)
|
||||
else f"`{result.outputs}`"
|
||||
else f" `{result.outputs}`"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ class CodeFlowExecutionComponent(CommandProvider):
|
||||
# limit the result to limit the characters
|
||||
if len(result) > MAX_RESULT_LENGTH:
|
||||
result = result[:MAX_RESULT_LENGTH] + "...[Truncated, Content is too long]"
|
||||
return f"Execution Plan:\n{plan_text}\n\nExecution Output:\n{result}"
|
||||
return result
|
||||
|
||||
def _get_available_functions(self) -> dict[str, Callable]:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user