From 7cb23c7f88c92f96c78e893962b7d8ce6ca493ad Mon Sep 17 00:00:00 2001 From: ymq Date: Sun, 9 Aug 2026 23:58:15 +0800 Subject: [PATCH] debug: trace LLM raw output, tool calls, history rows, system prompt env --- wwwroot/api/cockpit_chat.dspy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 0edfbb5..a8bec46 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -479,6 +479,7 @@ if action == 'send_message': repos_str = ', '.join([r['n'] for r in ctx['repos']]) or '无' env_text = f"【当前项目: {ctx['pname'] or '未选择'}】— 所有操作在当前项目内完成\n工作空间: {ctx['ws'] or '未设置'} | 仓库: {repos_str}" system = AGENT_PROMPT.replace('__TOOLS__',TOOLS_TEXT).replace('__ENV__',env_text) + debug(f"SYSTEM PROMPT env: {env_text}") msgs = [{"role":"system","content":system}] # Load history scoped to current project (via iteration_id = project_id) sql = "SELECT role,content FROM pipeline_conversations WHERE created_by=${u}$ ORDER BY created_at ASC LIMIT 20" @@ -486,7 +487,9 @@ if action == 'send_message': if ctx['pid']: sql = "SELECT role,content FROM pipeline_conversations WHERE created_by=${u}$ AND iteration_id=${p}$ ORDER BY created_at ASC LIMIT 20" params = {"u":uid,"p":ctx['pid']} - for h in (await sor.sqlExe(sql, params) or []): + hist_rows = await sor.sqlExe(sql, params) + debug(f"HISTORY: loaded {len(hist_rows or [])} rows, project={ctx['pid'][:8] if ctx['pid'] else 'none'}") + for h in (hist_rows or []): c = getattr(h,'content','') or '' r = getattr(h,'role','') or '' # Skip raw tool_call JSON — prevents LLM from mimicking old tool calls @@ -500,11 +503,13 @@ if action == 'send_message': for turn in range(10): raw = await _call_llm(model, msgs, 0.4) act = _parse(raw) + debug(f"LLM turn {turn}: raw={raw[:200]}, action={act.get('action','?')}, tool={act.get('tool','?')}") if act.get('action') == 'reply': agent_reply = act.get('message', raw); break if act.get('action') == 'tool_call': tool = act.get('tool','') label = _tool_labels.get(tool,tool) + debug(f"TOOL CALL: {tool} params={act.get('params',{})}") d = json.dumps(_w_progress(f"🔄 {label}..."), ensure_ascii=False)+'\n' debug(f"YIELD progress: {d[:60]}") yield d