调整了 agent.py 和 LLM client 协议/实现。 现在只传当前 action 的结构化结果和必要诊断日志,避免历史运行态影响判断。 提示词和文档也已同步说明。 verify-ip 增加健康检查重试 默认 VERIFY_INTERVAL_SEC=10、VERIFY_MAX_ATTEMPTS=12,约 2 分钟。 verify-ip 未通过但未达到最大次数时,会播报进度、保存 checkpoint,并继续从当前 verify-ip 重试,不会进入 download-log。 参数已加入 config.txt.example、脚本配置读取、README、打包 README、Skill 文档和流程图。
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
from pathlib import Path
|
|
|
|
from pam_deploy_graph.agent import PamDeployAgent
|
|
from pam_deploy_graph.fake_runner import FakeActionRunner
|
|
from pam_deploy_graph.langgraph_runtime import LangGraphDeploymentRuntime
|
|
|
|
|
|
PARAMS = {
|
|
"HOME_BASE_URL": "https://pam.home.example.com",
|
|
"CLIENT_ID": "client",
|
|
"CLIENT_SECRET": "secret",
|
|
"AIRPORT_CODE": "HET",
|
|
"APP_NAME": "PAM",
|
|
"MODULE_NAME": "Node",
|
|
"VERSION_NUMBER": "2.0.5",
|
|
"ZIP_FILE_PATH": "C:/pkg.zip",
|
|
"VERIFY_INTERVAL_SEC": 0,
|
|
"VERIFY_MAX_ATTEMPTS": 2,
|
|
}
|
|
|
|
|
|
def test_langgraph_runtime_pauses_failure_and_resume_retries(tmp_path: Path):
|
|
fake = FakeActionRunner(
|
|
{
|
|
"verify-ip:192.168.1.10": {
|
|
"ACTION": "verify-ip",
|
|
"IP": "192.168.1.10",
|
|
"SUCCESS": "false",
|
|
"MESSAGE": "health check failed",
|
|
}
|
|
}
|
|
)
|
|
agent = PamDeployAgent(fake_runner=fake)
|
|
state = agent.create_state(
|
|
params=PARAMS,
|
|
execution_strategy="fake",
|
|
config_path=str(tmp_path / "config.txt"),
|
|
checkpoint_path=str(tmp_path / "checkpoint.json"),
|
|
)
|
|
runtime = LangGraphDeploymentRuntime(agent=agent)
|
|
|
|
first = runtime.start(state)
|
|
|
|
assert first.interrupted is False
|
|
assert runtime.waiting_confirmation is False
|
|
assert first.confirmation == {}
|
|
assert first.state is not None
|
|
assert first.state.paused is True
|
|
assert first.state.pending_confirmation == ""
|
|
assert first.state.ip_states["192.168.1.10"]["failed_stage"] == "verify-ip"
|
|
|
|
fake.fixtures = {}
|
|
agent.resume_state(first.state)
|
|
second = runtime.start(first.state)
|
|
|
|
assert second.interrupted is False
|
|
assert runtime.waiting_confirmation is False
|
|
assert second.state is not None
|
|
assert second.state.pending_confirmation == ""
|
|
assert second.state.paused is False
|
|
assert second.state.ip_states["192.168.1.10"]["rollback_status"] == "ROLLBACK_NOT_RUN"
|
|
assert second.state.ip_states["192.168.1.11"]["status"] == "SUCCESS"
|