feat(agent): hierarchical executor with path resolve, runtime probe, quiet UI
Make Zed Agent closer to Cursor: deterministic DevOps path index, live Traefik port probe before blind edits, stop-after-edit, and quieter Russian progress.
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ssh -o BatchMode=yes eventhub-ift bash -s <<'REMOTE'
|
||||
set -euo pipefail
|
||||
cd /opt/ai-router-stack
|
||||
set -a; source .env; set +a
|
||||
BASE="${PUBLIC_URL:-https://ai-router.ift.calentiq.com}"
|
||||
KEY="${ROUTER_API_KEY:-$LITELLM_MASTER_KEY}"
|
||||
PLAN=$(python3 - <<'PY'
|
||||
import json
|
||||
d=json.load(open("/tmp/agent-plan.json"))
|
||||
msg=(d.get("choices") or [{}])[0].get("message") or {}
|
||||
print(msg.get("content") or "")
|
||||
PY
|
||||
)
|
||||
# Approve with tools like Zed agent
|
||||
python3 - <<'PY' > /tmp/agent-approve-req.json
|
||||
import json
|
||||
plan=open("/tmp/agent-plan.json").read()
|
||||
d=json.loads(plan)
|
||||
content=((d.get("choices") or [{}])[0].get("message") or {}).get("content") or ""
|
||||
tools=[{
|
||||
"type":"function",
|
||||
"function":{
|
||||
"name":"read_file",
|
||||
"description":"Read a file",
|
||||
"parameters":{"type":"object","properties":{"path":{"type":"string"}},"required":["path"]}
|
||||
}
|
||||
},{
|
||||
"type":"function",
|
||||
"function":{
|
||||
"name":"edit_file",
|
||||
"description":"Edit a file",
|
||||
"parameters":{"type":"object","properties":{
|
||||
"path":{"type":"string"},
|
||||
"edits":{"type":"array","items":{"type":"object","properties":{
|
||||
"old_text":{"type":"string"},"new_text":{"type":"string"}
|
||||
}}}
|
||||
},"required":["path","edits"]}
|
||||
}
|
||||
}]
|
||||
body={
|
||||
"model":"smart-router",
|
||||
"stream": False,
|
||||
"tools": tools,
|
||||
"tool_choice":"auto",
|
||||
"messages":[
|
||||
{"role":"user","content":"observer.ift.calentiq.com не работает - Bad Gateway почини"},
|
||||
{"role":"assistant","content":content},
|
||||
{"role":"user","content":"ok"}
|
||||
]
|
||||
}
|
||||
json.dump(body, open("/tmp/agent-approve-req.json","w"), ensure_ascii=False)
|
||||
print("req bytes", len(json.dumps(body)))
|
||||
PY
|
||||
echo "== approve+tools =="
|
||||
curl -sS --max-time 180 "$BASE/v1/chat/completions" \
|
||||
-H "Authorization: Bearer $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-AI-Orchestrate: force" \
|
||||
-H "X-AI-Quality: balanced" \
|
||||
-d @/tmp/agent-approve-req.json | tee /tmp/agent-exec1.json | python3 -c '
|
||||
import json,sys
|
||||
d=json.load(sys.stdin)
|
||||
ch=(d.get("choices") or [{}])[0]
|
||||
msg=ch.get("message") or {}
|
||||
print("finish", ch.get("finish_reason"))
|
||||
print("content", (msg.get("content") or "")[:1200])
|
||||
tcs=msg.get("tool_calls") or []
|
||||
print("tool_calls", len(tcs))
|
||||
for tc in tcs:
|
||||
fn=tc.get("function") or {}
|
||||
print(" TOOL", fn.get("name"), (fn.get("arguments") or "")[:300])
|
||||
meta=d.get("x_router_meta") or {}
|
||||
print("meta phase", meta.get("agent_phase"), "force_edit", meta.get("executor_force_edit_after_read"), "model", meta.get("executor_model") or meta.get("selected_model"))
|
||||
'
|
||||
echo "== router log since approve =="
|
||||
docker service logs --since 3m --raw ai-router_router 2>&1 \
|
||||
| grep -iE 'path_index|force edit|stop after|hierarchical_agent|executor result|kickstart|phase=' \
|
||||
| tail -30
|
||||
REMOTE
|
||||
Reference in New Issue
Block a user