nikeshn commited on
Commit
1cda45f
·
verified ·
1 Parent(s): 06d155d

Update src/agentcore/orchestrator.py

Browse files
Files changed (1) hide show
  1. src/agentcore/orchestrator.py +12 -3
src/agentcore/orchestrator.py CHANGED
@@ -151,7 +151,7 @@ def _log_agent_query(question: str, response: AgentResponse, start_time: float)
151
  async def _post_to_worker():
152
  try:
153
  async with httpx.AsyncClient(timeout=5) as _cl:
154
- await _cl.post(
155
  worker_url.rstrip("/") + "/log",
156
  json={
157
  "question": _redact_for_analytics(question),
@@ -172,8 +172,17 @@ def _log_agent_query(question: str, response: AgentResponse, start_time: float)
172
  else {}
173
  ),
174
  )
175
- except Exception:
176
- pass
 
 
 
 
 
 
 
 
 
177
  try:
178
  loop = _al.get_event_loop()
179
  if loop.is_running():
 
151
  async def _post_to_worker():
152
  try:
153
  async with httpx.AsyncClient(timeout=5) as _cl:
154
+ _resp = await _cl.post(
155
  worker_url.rstrip("/") + "/log",
156
  json={
157
  "question": _redact_for_analytics(question),
 
172
  else {}
173
  ),
174
  )
175
+ # Surface auth/config failures: a silent 401 here is the
176
+ # usual reason the admin dashboard shows no new queries.
177
+ if _resp.status_code == 401:
178
+ logger.error(
179
+ "D1 logging rejected (401). CLOUDFLARE_WORKER_TOKEN "
180
+ "does not match the Worker's ANALYTICS_TOKEN secret."
181
+ )
182
+ elif _resp.status_code >= 400:
183
+ logger.warning(f"D1 logging failed: HTTP {_resp.status_code}")
184
+ except Exception as _exc:
185
+ logger.warning(f"D1 logging unreachable: {_exc}")
186
  try:
187
  loop = _al.get_event_loop()
188
  if loop.is_running():