feat(agent): add redis short-term user context cache and align tests
This commit is contained in:
@@ -40,7 +40,7 @@ backend/src/core/agent/infrastructure/litellm/usage_tracker.py:26
|
||||
|
||||
### 复现步骤
|
||||
1. 重启服务: `infra/scripts/app.sh stop && infra/scripts/app.sh start`
|
||||
2. 运行诊断: `uv run python test_agent_sse_flow.py`
|
||||
2. 运行诊断: `AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v`
|
||||
|
||||
### 影响范围
|
||||
- LLM 调用成功,但无法提取 token 使用量和成本
|
||||
@@ -94,7 +94,7 @@ register_model({
|
||||
### 验证方法
|
||||
修复后运行:
|
||||
```bash
|
||||
uv run python test_agent_sse_flow.py
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
```
|
||||
预期:
|
||||
- 看到 `RUN_STARTED` 和 `RUN_FINISHED` 事件
|
||||
@@ -112,7 +112,7 @@ uv run python test_agent_sse_flow.py
|
||||
~~**HIGH** - 阻塞 CI/CD 流程~~ **已解决**
|
||||
|
||||
### 问题描述
|
||||
`test_agent_closed_loop_live.py` 测试在 120 秒后超时,未完成执行。
|
||||
`test_sse_flow_live.py` 测试在 120 秒后超时,未完成执行。
|
||||
|
||||
### 根本原因
|
||||
- **阶段 1**: 由 Bug #1 引起(LLM Provider 配置错误)- **已修复**
|
||||
@@ -128,7 +128,7 @@ Bug #1 和 #1.1 修复后,测试应能正常完成。
|
||||
### 复现步骤
|
||||
```bash
|
||||
cd .worktrees/feature-agent-runtime-closed-loop
|
||||
AGENT_LIVE_E2E=1 uv run pytest backend/tests/e2e/test_agent_closed_loop_live.py -m live -v
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
```
|
||||
|
||||
### 预期行为
|
||||
@@ -187,7 +187,7 @@ AGENT_LIVE_E2E=1 uv run pytest backend/tests/e2e/test_agent_closed_loop_live.py
|
||||
- [ ] 重启服务验证
|
||||
|
||||
3. [ ] **验证修复**
|
||||
- [ ] 运行 `test_agent_sse_flow.py`
|
||||
- [ ] 运行 `test_sse_flow_live.py`
|
||||
- [ ] 确认事件流完整(RUN_STARTED → RUN_FINISHED)
|
||||
- [ ] 检查 DB 留痕
|
||||
|
||||
@@ -215,10 +215,10 @@ infra/scripts/app.sh start
|
||||
curl http://localhost:5775/health # 成功
|
||||
|
||||
# 3. 运行 live E2E (超时)
|
||||
AGENT_LIVE_E2E=1 uv run pytest backend/tests/e2e/test_agent_closed_loop_live.py -m live -v
|
||||
AGENT_lIVE_e2e=1 uv run pytest backend/tests/e2e/test_agent_closed_loop_live.py -m live -v
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
# 超时
|
||||
uv run python test_agent_sse_flow.py # 失败 (LLM Provider 错误)
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v # 失败 (LLM Provider 错误)
|
||||
|
||||
# 5. 检查日志
|
||||
tail -f logs/worker-default.log # 发现根本原因
|
||||
@@ -233,7 +233,7 @@ infra/scripts/app.sh stop && infra/scripts/app.sh start
|
||||
curl http://localhost:5775/health # 成功
|
||||
|
||||
# 9. 运行诊断脚本
|
||||
uv run python test_agent_sse_flow.py # 失败 (模型定价未映射)
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v # 失败 (模型定价未映射)
|
||||
|
||||
# 10. 检查日志
|
||||
tail -f logs/worker-default.log # 发现新错误: 模型未映射
|
||||
@@ -285,7 +285,7 @@ tail -f logs/worker-default.log # 发现新错误: 模型未映射
|
||||
|
||||
**命令**:
|
||||
```bash
|
||||
uv run python test_agent_sse_flow.py
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
```
|
||||
|
||||
**结果**: ✅ **成功**
|
||||
@@ -363,6 +363,6 @@ uv run python test_agent_sse_flow.py
|
||||
### 测试覆盖
|
||||
修复后需重新运行完整测试套件:
|
||||
```bash
|
||||
uv run python test_agent_sse_flow.py
|
||||
AGENT_LIVE_E2E=1 uv run pytest backend/tests/e2e/test_agent_closed_loop_live.py -m live -v
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
AGENT_LIVE_INTEGRATION=1 uv run pytest backend/tests/integration/v1/agent/test_sse_flow_live.py -m live -v
|
||||
```
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
1. memory短期的加载。memory的生命周期为ttl+对话条目+session_id。用crewai
|
||||
2.
|
||||
Reference in New Issue
Block a user