refactor(platform): cache agent guide and remove unused raw_json field

- Add @lru_cache to _load_agent_guide() to avoid re-reading the file on
  every conversion call
- Remove unused raw_json field from WorkflowDescription — it was populated
  by all describers but never read by any consumer
This commit is contained in:
Zamil Majdy
2026-03-16 23:56:36 +07:00
parent 7b44c3e416
commit 2cbc152654
3 changed files with 3 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ Uses the CoPilot's LLM client to generate AutoGPT agent JSON from a structured
WorkflowDescription, then validates and fixes via the existing pipeline.
"""
import functools
import json
import logging
import pathlib
@@ -45,8 +46,9 @@ def _get_llm_client() -> tuple[Any, ChatConfig]:
return _llm_client, _llm_config
@functools.lru_cache(maxsize=1)
def _load_agent_guide() -> str:
"""Load the agent generation guide markdown."""
"""Load the agent generation guide markdown (cached after first read)."""
return _AGENT_GUIDE_PATH.read_text()

View File

@@ -101,7 +101,6 @@ def describe_n8n_workflow(json_data: dict[str, Any]) -> WorkflowDescription:
steps=steps,
trigger_type=trigger_type,
source_format=SourcePlatform.N8N,
raw_json=json_data,
)
@@ -160,7 +159,6 @@ def describe_make_workflow(json_data: dict[str, Any]) -> WorkflowDescription:
steps=steps,
trigger_type=trigger_type,
source_format=SourcePlatform.MAKE,
raw_json=json_data,
)
@@ -201,7 +199,6 @@ def describe_zapier_workflow(json_data: dict[str, Any]) -> WorkflowDescription:
steps=steps,
trigger_type=trigger_type,
source_format=SourcePlatform.ZAPIER,
raw_json=json_data,
)

View File

@@ -4,7 +4,6 @@ from enum import Enum
from typing import Any
import pydantic
from pydantic import Field
class SourcePlatform(str, Enum):
@@ -32,4 +31,3 @@ class WorkflowDescription(pydantic.BaseModel):
steps: list[StepDescription]
trigger_type: str | None = None
source_format: SourcePlatform
raw_json: dict[str, Any] = Field(default_factory=dict, exclude=True)