fix(task_capability): claim_task 查询用原样 role(兼容存量裸名),审计记录用规范名 agent.{role}

This commit is contained in:
ymq 2026-08-16 23:40:55 +08:00
parent 3687270ca7
commit 7673a7acdf

View File

@ -76,7 +76,7 @@ async def claim_task(tenant_id, role, agent_id, from_state=S_SUBMITTED,
返回 (ok, task_id_or_message)
"""
role = _normalize_role(role)
role_norm = _normalize_role(role) # 审计记录用规范名;查询用原样(兼容存量裸名数据)
db, dbname = _get_db()
async with db.sqlorContext(dbname) as sor:
claim_token = agent_id or getID()
@ -100,7 +100,7 @@ async def claim_task(tenant_id, role, agent_id, from_state=S_SUBMITTED,
return False, "认领竞争失败(已被他人认领)"
await record_audit(tenant_id, 'pipeline_tasks', task_id, 'claim',
from_state=from_state, to_state=to_state,
who=role, agent_id=agent_id, sor=sor)
who=role_norm, agent_id=agent_id, sor=sor)
return True, task_id