Repository navigation
fix(logging): api 进程显式初始化应用日志,模型调用记录不再丢失 - #90
Merged
Merged
Conversation
added 2 commits
October 30, 2026 10:57
uvicorn's --log-level only configures its own loggers; it neither sets the root logger level nor installs a root handler. service.py only fetched logging.getLogger(agent_attack_lab) without configuring it, so every logger.info record from the api process was dropped by the root logger default of WARNING. attacker/defender did emit logs because importing agents.common triggered logging.basicConfig as a side effect. The result was a misleading split: for one battle, attacker and defender each logged 17 model_call_completed lines while api logged none, even though all four rounds ran with verificationMode=live and each target call took 1.7-2.5s. Add logging_setup.configure_logging(): install a root handler when missing and lift the agent_attack_lab package logger to INFO without touching the root level, so httpx/openai INFO noise stays suppressed. Call it from service.py and agents.common instead of relying on import side effects.
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
Deploying agent-attack-lab with
|
| Latest commit: |
6fd57a3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8ea518cb.agent-attack-lab.pages.dev |
| Branch Preview URL: | https://fix-app-logging-init-rebased.agent-attack-lab.pages.dev |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-app-logging-init-rebased-agent-attack-lab.3498414260.workers.dev (commit 6fd57a3)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
May18th
added a commit
that referenced
this pull request
Oct 30, 2026
chore(diagnose): 增加三个服务的模型调用计数 [skip ci] 判断「模型是否被调用」以业务数据为准,这一步只回答「日志有没有落盘」。 logging 补修上线后,api 单元应同时出现 model_call_completed 与 model_text_completed(靶标),可用于直接核对。#90 之前在 api 恒为 0。 Co-authored-by: userName <userEmail>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
原提交
e77d749(分支 fix/app-logging-init)已 rebase 到cc78737后重推,内容未改,仅补了两处过期数据。问题
uvicorn 的
--log-level只作用于uvicorn/uvicorn.error/uvicorn.access,既不设根 logger 级别也不装 handler。service.py只写了logging.getLogger("agent_attack_lab"),api 进程里所有logger.info被根 logger 默认的 WARNING 丢弃。实测症状:同一战局 attacker 与 defender 各记 17 条
model_call_completed,api 记 0 条,而 4 轮全是verificationMode=live、每轮靶标 1.7~2.5 秒——模型确实调用了,只是日志没落盘。根因是agents/common.py的logging.basicConfig副作用:attacker/defender 导入它时顺带打开了日志,api 没有等价调用。改动
logging_setup.configure_logging():根 logger 无 handler 时装一个,把agent_attack_lab包 logger 调到 INFO,不动根级别(避免 httpx/openai 噪音)service.py与agents/common.py统一调用它,不再依赖导入副作用tests/test_logging_setup.py覆盖 6 种情形本次 rebase 顺带校正(第二个 commit)
332 passed是 fix(defender): 同一分类多条线索不再整体回退规则,附 CI 转绿 #88 合并前的基线,现为 338 passed, 5 skippedb585460已不是当前 release,改为「当时在跑的 release」验证
合并会触发 backend/** 部署。部署后预期:三个服务的 journal 都能看到
model_call_completed/model_text_completed。