fix(agent): unify logging API + add molecular-cot coverage to agent module
Phase 1 — API unification: - Replace direct log() from cot_logger with canonical logger.reason/reflect/explore across _confirmation.py, _persistence.py, _tool_resolver.py, app.py Phase 2 — Gap filling: - tools.py: add REASON/REFLECT/EXPLORE to 17 C3 tool functions (was 0 logs) - app.py agent_handler (C4): add lifecycle REASON on entry, REFLECT on exit, EXPLORE on OutputParserException + general exception - langgraph_setup.py create_agent (C4): add REASON with model/config_source, EXPLORE on env-var/InMemorySaver fallback, REFLECT on graph compilation - _tool_resolver.py infer_tool_from_text (C3, 13 branches): REASON on inference - _persistence.py: REFLECT on save_conversation success, EXPLORE on prefetch Phase 3 — Plain log migration: - middleware.py: plain logger.info() -> logger.reason() - run.py: 7 plain logger.info/warning/error -> molecular REASON/EXPLORE Phase 4 — Cleanup: - cot_logger.py: deprecate MarkerLogger (@DEPRECATED + @REPLACED_BY) - molecular-cot-logging SKILL.md: remove cot_span Section IV (never implemented), renumber sections V-VII -> IV-VI, add cot_span rejection rationale Verification: pytest 27/27, axiom rebuild 5844/2993/0 warnings
This commit is contained in:
@@ -7,11 +7,9 @@
|
||||
# @REJECTED ConfirmationRiskMiddleware rejected — LangGraph interrupt_before=DANGEROUS_TOOLS handles HITL natively.
|
||||
|
||||
from datetime import UTC, datetime
|
||||
import logging
|
||||
|
||||
from src.agent.context import get_user_jwt
|
||||
|
||||
logger = logging.getLogger("cot")
|
||||
from src.core.logger import logger
|
||||
|
||||
|
||||
# #region AgentChat.Middleware.LoggingMiddleware [C:3] [TYPE Function] [SEMANTICS audit,tool,logging]
|
||||
@@ -48,9 +46,10 @@ async def log_tool_event(event: dict, conversation_id: str) -> None:
|
||||
elif kind == "on_tool_error":
|
||||
audit_payload["error"] = str(data.get("error", ""))[:500]
|
||||
|
||||
logger.info(
|
||||
"Tool audit: %(event_type)s — %(tool)s — conv=%(conversation_id)s",
|
||||
audit_payload,
|
||||
logger.reason(
|
||||
"Tool audit event",
|
||||
payload=audit_payload,
|
||||
extra={"src": "AgentChat.Middleware.LoggingMiddleware"},
|
||||
)
|
||||
|
||||
# TODO: Async write to assistant_audit table via REST call to FastAPI
|
||||
|
||||
Reference in New Issue
Block a user