Merge branch 'master' of http://192.168.0.200/knowledge-base-bj/deerflow-server into xhy
This commit is contained in:
commit
667b365a84
94 files changed
+6430
-2390
No files matched your search
@@ -59,11 +59,18 @@ def load_agent_config(agent_id: str | None) -> AgentConfig | None:
|
||||
agent_id: The agent storage/runtime id.
|
||||
|
||||
Returns:
|
||||
AgentConfig instance.
|
||||
AgentConfig instance, or ``None`` when the on-disk artifacts are missing.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: If the agent directory or config.yaml does not exist.
|
||||
ValueError: If config.yaml cannot be parsed.
|
||||
ValueError: If config.yaml exists but cannot be parsed.
|
||||
|
||||
Tolerance:
|
||||
A missing agent directory or missing config.yaml is **not** an error —
|
||||
the runtime simply falls back to default Lead Agent behavior for that
|
||||
id. This keeps the chat session usable when the DB still has an agent
|
||||
row but its files have been deleted (e.g. data dir moved between
|
||||
machines, or filesystem wiped). The router layer is expected to
|
||||
lazily restore the directory next time the agent is fetched via API.
|
||||
"""
|
||||
|
||||
if agent_id is None:
|
||||
@@ -74,10 +81,20 @@ def load_agent_config(agent_id: str | None) -> AgentConfig | None:
|
||||
config_file = agent_dir / "config.yaml"
|
||||
|
||||
if not agent_dir.exists():
|
||||
raise FileNotFoundError(f"Agent directory not found: {agent_dir}")
|
||||
logger.warning(
|
||||
"Agent directory missing for id '%s' (%s); falling back to default config",
|
||||
agent_id,
|
||||
agent_dir,
|
||||
)
|
||||
return None
|
||||
|
||||
if not config_file.exists() and not (agent_dir / SOUL_FILENAME).exists():
|
||||
raise FileNotFoundError(f"Agent config not found: {config_file}")
|
||||
logger.warning(
|
||||
"Agent has no config.yaml or %s at %s; falling back to default config",
|
||||
SOUL_FILENAME,
|
||||
agent_dir,
|
||||
)
|
||||
return None
|
||||
|
||||
data: dict[str, Any] = {}
|
||||
if config_file.exists():
|
||||
|
||||
Reference in new issue
Block a user