fix
This commit is contained in:
@@ -121,7 +121,6 @@ async def run_world_editor(
|
||||
for tc in tcs:
|
||||
fn = tc.get("function") or {}
|
||||
if not isinstance(fn, dict):
|
||||
# Some models put the function name/args directly on tc
|
||||
fn = {"name": tc.get("name", ""), "arguments": tc.get("arguments", "{}")}
|
||||
tname = fn.get("name", "")
|
||||
args_str = fn.get("arguments", "{}")
|
||||
@@ -136,7 +135,6 @@ async def run_world_editor(
|
||||
"question": targs.get("question", ""),
|
||||
"options": targs.get("options"),
|
||||
})
|
||||
# Wait for user answer via REST
|
||||
fut: asyncio.Future[str] = asyncio.get_event_loop().create_future()
|
||||
_pending_clarifications[world.id] = fut
|
||||
try:
|
||||
@@ -161,7 +159,6 @@ async def run_world_editor(
|
||||
"diff": diff,
|
||||
"comment": comment,
|
||||
})
|
||||
# Wait for user accept/reject via REST
|
||||
fut2: asyncio.Future[bool] = asyncio.get_event_loop().create_future()
|
||||
_pending_changes[world.id] = fut2
|
||||
try:
|
||||
@@ -176,21 +173,12 @@ async def run_world_editor(
|
||||
await _apply_diff(world, diff)
|
||||
await db.commit()
|
||||
await sse.emit("apply_changes", {"diff": diff})
|
||||
messages.append({
|
||||
"role": "tool",
|
||||
"tool_call_id": tc.get("id", ""),
|
||||
"name": tname,
|
||||
"content": json.dumps({"ok": True, "applied": True}),
|
||||
})
|
||||
else:
|
||||
await sse.emit("discard_changes", {})
|
||||
messages.append({
|
||||
"role": "tool",
|
||||
"tool_call_id": tc.get("id", ""),
|
||||
"name": tname,
|
||||
"content": json.dumps({"ok": True, "applied": False, "reason": "user_rejected"}),
|
||||
})
|
||||
continue
|
||||
# After propose_changes (accepted or rejected), END the loop.
|
||||
# Don't make another LLM call — the user's decision is final.
|
||||
done = True
|
||||
break
|
||||
# Regular tool — execute
|
||||
result = await registry.execute(tname, targs, ctx)
|
||||
messages.append({
|
||||
|
||||
Reference in New Issue
Block a user