fix(llm): remove step limit and tool timeout, use while loop with 999 cap
This commit is contained in:
@@ -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']
|
[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: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: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
|
||||||
|
|||||||
@@ -314,8 +314,10 @@ def run_llm_pipeline(dataset_id: str, entity_col: str = "",
|
|||||||
# Track tool call history for smarter guidance
|
# Track tool call history for smarter guidance
|
||||||
called_tools: set[str] = set()
|
called_tools: set[str] = set()
|
||||||
consecutive_errors = 0
|
consecutive_errors = 0
|
||||||
|
step = 0
|
||||||
|
max_steps = 999
|
||||||
|
|
||||||
for step in range(25):
|
while step < max_steps:
|
||||||
resp = call_llm(msgs, config)
|
resp = call_llm(msgs, config)
|
||||||
if resp is None:
|
if resp is None:
|
||||||
if callback:
|
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]}')
|
logger.info(f'[TOOL] step={step} name={name} args={json.dumps(args)[:200]}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async def _call_with_timeout():
|
result = asyncio.run(handle_call(name, args))
|
||||||
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')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result = {'error': f'MCP tool error: {e}'}
|
result = {'error': f'MCP tool error: {e}'}
|
||||||
logger.error(f'[TOOL] {name} error: {e}')
|
|
||||||
|
|
||||||
if callback:
|
if callback:
|
||||||
callback(step, name, result, meta={"args": args})
|
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.",
|
"content": f"Tool '{name}' failed: {result['error'][:200]}. Call '{suggested}' to diagnose, then retry with corrected parameters.",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
step += 1
|
||||||
|
|
||||||
if callback:
|
if callback:
|
||||||
callback(25, "max_steps", None)
|
callback(max_steps, "max_steps", None)
|
||||||
return {"error": "Reached max 25 tool calls", "steps": 25}
|
return {"error": f"Reached max {max_steps} tool calls", "steps": max_steps}
|
||||||
|
|||||||
Reference in New Issue
Block a user