```
feat(learning): 添加技能学习候选者合成锁定机制 添加了 DraftSynthesisInProgress 和 DraftHasNoChanges 异常来处理并发场景, 确保同一技能学习候选者的合成过程不会重复执行。实现了 claim_learning_candidate_for_synthesis 方法来原子性地锁定候选者进行合成。 fix(web): 为技能草案创建端点添加适当的HTTP状态码 当草案没有变化或正在合成时,现在正确返回409状态码而不是内部错误。 feat(skills): 实现技能修订内容比较以检测无变化情况 添加了 _is_noop_revision 方法来比较基础技能和提议的修订, 如果内容没有实际变化则抛出 NoDraftChanges 异常。 refactor(process): 修复任务证据记录后根运行状态更新逻辑 将任务证据记录事件后的状态从 waiting 更改为 done,并设置 finished_at 时间戳。 feat(tools): 防止在同一运行中重复执行外部写入操作 为邮件发送、日历创建等外部写入工具添加去重机制,避免重复的外部操作。 test: 添加技能学习和工具执行的单元测试 增加测试用例验证并发草案合成、重复外部写入抑制和无变化修订检测等功能。 ```
This commit is contained in:
@ -0,0 +1,69 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_create_instance_writes_default_max_tool_iterations(tmp_path) -> None:
|
||||
app_instance_dir = Path(__file__).resolve().parents[3]
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
docker = fake_bin / "docker"
|
||||
docker.write_text(
|
||||
"""#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
case "${1:-}" in
|
||||
image)
|
||||
[[ "${2:-}" == "inspect" ]]
|
||||
exit 0
|
||||
;;
|
||||
container)
|
||||
[[ "${2:-}" == "inspect" ]]
|
||||
exit 1
|
||||
;;
|
||||
run)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "unexpected docker command: $*" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
docker.chmod(0o755)
|
||||
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = f"{fake_bin}:{env['PATH']}"
|
||||
instances_root = tmp_path / "instances"
|
||||
result = subprocess.run(
|
||||
[
|
||||
str(app_instance_dir / "create-instance.sh"),
|
||||
"--instance-id",
|
||||
"default-tools",
|
||||
"--auth-username",
|
||||
"steven",
|
||||
"--auth-password",
|
||||
"secret",
|
||||
"--skip-provider-config",
|
||||
"--host-port",
|
||||
"29001",
|
||||
"--instances-root",
|
||||
str(instances_root),
|
||||
"--registry",
|
||||
str(tmp_path / "registry.json"),
|
||||
"--skip-initial-skills",
|
||||
],
|
||||
cwd=app_instance_dir,
|
||||
env=env,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
config_path = instances_root / "default-tools" / "beaver-home" / "config.json"
|
||||
config = json.loads(config_path.read_text(encoding="utf-8"))
|
||||
|
||||
assert config["agents"]["defaults"]["maxToolIterations"] == 100
|
||||
Reference in New Issue
Block a user