debug: show system prompt and project context
This commit is contained in:
parent
2db4835893
commit
5cadd4ed70
57
wwwroot/api/test_agent_v2_debug.dspy
Normal file
57
wwwroot/api/test_agent_v2_debug.dspy
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# test_agent_v2_debug.dspy - 查看 Agent v2 的 system prompt 和上下文
|
||||||
|
|
||||||
|
uid = await get_user()
|
||||||
|
if not uid:
|
||||||
|
uid = 'user-01'
|
||||||
|
|
||||||
|
from pipeline_core.agent_config import load_agent_config
|
||||||
|
from pipeline_service.agent_loop_v2 import AgentExecutor
|
||||||
|
|
||||||
|
cfg = await load_agent_config()
|
||||||
|
|
||||||
|
# 获取项目上下文
|
||||||
|
dbname = get_module_dbname('pipeline-sdlc')
|
||||||
|
pid = ''
|
||||||
|
org_id = ''
|
||||||
|
project_name = ''
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
recs = await sor.sqlExe(
|
||||||
|
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$",
|
||||||
|
{"u": uid})
|
||||||
|
if recs:
|
||||||
|
pid = getattr(recs[0], 'current_project_id', '') or ''
|
||||||
|
|
||||||
|
if pid:
|
||||||
|
recs2 = await sor.sqlExe(
|
||||||
|
"SELECT name, org_id FROM sd_projects WHERE id=${p}$",
|
||||||
|
{"p": pid})
|
||||||
|
if recs2:
|
||||||
|
project_name = getattr(recs2[0], 'name', '')
|
||||||
|
org_id = getattr(recs2[0], 'org_id', '') or ''
|
||||||
|
|
||||||
|
# 技能加载
|
||||||
|
from pipeline_core.skill_loader import get_skill_loader
|
||||||
|
loader = get_skill_loader(cfg.skills.base_dir)
|
||||||
|
scopes = loader.list_by_scope()
|
||||||
|
merged = loader.get_merged(org_id, uid)
|
||||||
|
|
||||||
|
result = {
|
||||||
|
"user_id": uid,
|
||||||
|
"project_id": pid,
|
||||||
|
"project_name": project_name,
|
||||||
|
"org_id": org_id,
|
||||||
|
"max_turns": cfg.max_turns,
|
||||||
|
"compression": cfg.compression.enabled,
|
||||||
|
"memory": cfg.memory.enabled,
|
||||||
|
"skills": {
|
||||||
|
"enabled": cfg.skills.enabled,
|
||||||
|
"base_dir": cfg.skills.base_dir,
|
||||||
|
"by_scope": scopes,
|
||||||
|
"merged_count": len(merged),
|
||||||
|
"names": list(merged.keys()),
|
||||||
|
},
|
||||||
|
"tools": [t.name for t in cfg.tools if hasattr(t, 'enabled') and t.enabled],
|
||||||
|
"system_prompt_preview": cfg.system_prompt[:500],
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False, default=str)
|
||||||
Loading…
x
Reference in New Issue
Block a user