fix(llm): remove step limit and tool timeout, use while loop with 999 cap

This commit is contained in:
PM-pinou
2026-07-24 12:41:25 +08:00
parent f683a084f3
commit d24507e541
2 changed files with 22 additions and 13 deletions
+14
View File
@@ -58,3 +58,17 @@ Restored 1 datasets from disk
[2026-07-24 12:30:18,840] INFO analysis.data_loader: [CLEAN] HEX columns added hex_pairs_count: ['0cph', '0crv', '0ver', '0rnt', '0rnd']
[24/Jul/2026 12:30:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:31:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:31:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:32:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:32:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:33:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:33:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:34:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:34:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:35:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:35:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:36:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:36:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:37:07] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:37:37] "HEAD / HTTP/1.1" 200 0
[24/Jul/2026 12:38:07] "HEAD / HTTP/1.1" 200 0
+8 -13
View File
@@ -314,8 +314,10 @@ def run_llm_pipeline(dataset_id: str, entity_col: str = "",
# Track tool call history for smarter guidance
called_tools: set[str] = set()
consecutive_errors = 0
step = 0
max_steps = 999
for step in range(25):
while step < max_steps:
resp = call_llm(msgs, config)
if resp is None:
if callback:
@@ -368,18 +370,9 @@ def run_llm_pipeline(dataset_id: str, entity_col: str = "",
logger.info(f'[TOOL] step={step} name={name} args={json.dumps(args)[:200]}')
try:
async def _call_with_timeout():
return await asyncio.wait_for(
handle_call(name, args),
timeout=120,
)
result = asyncio.run(_call_with_timeout())
except asyncio.TimeoutError:
result = {'error': f'Tool {name} timed out after 120s'}
logger.warning(f'[TOOL] {name} timed out')
result = asyncio.run(handle_call(name, args))
except Exception as e:
result = {'error': f'MCP tool error: {e}'}
logger.error(f'[TOOL] {name} error: {e}')
if callback:
callback(step, name, result, meta={"args": args})
@@ -417,6 +410,8 @@ def run_llm_pipeline(dataset_id: str, entity_col: str = "",
"content": f"Tool '{name}' failed: {result['error'][:200]}. Call '{suggested}' to diagnose, then retry with corrected parameters.",
})
step += 1
if callback:
callback(25, "max_steps", None)
return {"error": "Reached max 25 tool calls", "steps": 25}
callback(max_steps, "max_steps", None)
return {"error": f"Reached max {max_steps} tool calls", "steps": max_steps}