|
|
@@ -604,6 +604,13 @@ async def compute_bid_adjustment(
|
|
|
summary_parts = [f"{label}:{action_counts.get(act, 0)}" for act, label in action_labels]
|
|
|
lines.append(f"合计: {' / '.join(summary_parts)} / 冷启动保护:{cold_start_count}")
|
|
|
|
|
|
+ # 添加 JSON 数据块供执行 Agent 使用
|
|
|
+ lines.append("\n" + "=" * 60)
|
|
|
+ lines.append("执行数据(JSON格式,供执行Agent使用):")
|
|
|
+ lines.append("```json")
|
|
|
+ lines.append(json.dumps({"adjustment_plan": results}, ensure_ascii=False, indent=2))
|
|
|
+ lines.append("```")
|
|
|
+
|
|
|
return ToolResult(
|
|
|
title=f"出价调整方案({len(results)}条,{strategy})",
|
|
|
output="\n".join(lines),
|
|
|
@@ -632,7 +639,7 @@ async def compute_bid_adjustment(
|
|
|
|
|
|
@tool(description="执行出价调整方案,批量调用 API 修改出价")
|
|
|
async def bid_adjustment_execute(
|
|
|
- adjustment_plan: List[Dict],
|
|
|
+ adjustment_plan_json: str,
|
|
|
account_id: int,
|
|
|
context: Optional[ToolContext] = None,
|
|
|
) -> ToolResult:
|
|
|
@@ -640,9 +647,26 @@ async def bid_adjustment_execute(
|
|
|
批量执行出价调整。
|
|
|
|
|
|
Args:
|
|
|
- adjustment_plan: 调整方案列表,每项包含 ad_id, new_bid, action
|
|
|
+ adjustment_plan_json: 调整方案 JSON 字符串或列表,每项包含 ad_id, new_bid, action
|
|
|
account_id: 账户ID
|
|
|
"""
|
|
|
+ # 解析 JSON(支持字符串或已解析的列表)
|
|
|
+ if isinstance(adjustment_plan_json, str):
|
|
|
+ try:
|
|
|
+ data = json.loads(adjustment_plan_json)
|
|
|
+ # 如果是 {"adjustment_plan": [...]} 格式,提取列表
|
|
|
+ if isinstance(data, dict) and "adjustment_plan" in data:
|
|
|
+ adjustment_plan = data["adjustment_plan"]
|
|
|
+ else:
|
|
|
+ adjustment_plan = data
|
|
|
+ except json.JSONDecodeError as e:
|
|
|
+ return ToolResult(
|
|
|
+ title="执行失败",
|
|
|
+ output=f"JSON 解析失败: {e}",
|
|
|
+ error=str(e),
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ adjustment_plan = adjustment_plan_json
|
|
|
success_count = 0
|
|
|
failed_count = 0
|
|
|
errors = []
|