Skip to content

Commit 4d3e807

Browse files
authored
feat(core): add logging for original_date parsing and fixed pending contexts using wrong date (#528)
* feat(skill_learner): add logging for original_date parsing - Log original_date value when extracted from session.configs - Log date resolution in SkillLearnerPrompt * feat(schema): add warning log for original_date validation failure - Log warning when original_date format validation fails - Include session_id in the log for debugging Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(skill_learner): use each context's own original_date - Each pending context now uses its own original_date field instead of sharing the single date from initial session - Add Date: header to each context for clarity - Remove unused original_date parameter from pack_incoming_contexts
1 parent 1605010 commit 4d3e807

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/server/core/acontext_core/llm/prompt/skill_learner.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .base import BasePrompt
55
from ...schema.llm import ToolSchema
66
from ..tool.skill_learner_tools import SKILL_LEARNER_TOOLS
7+
from ...env import LOG
78

89
if TYPE_CHECKING:
910
from ...schema.mq.learning import SkillLearnDistilled
@@ -154,6 +155,11 @@ def pack_skill_learner_input(
154155
original_date: str | None = None,
155156
) -> str:
156157
today = original_date or date.today().isoformat()
158+
LOG.info(
159+
"skill_learner_prompt.date_resolved",
160+
original_date=original_date,
161+
today=today,
162+
)
157163
parts = [distilled_context]
158164

159165
if pending_contexts:
@@ -183,15 +189,16 @@ def pack_incoming_contexts(
183189
count_bases: int = 0,
184190
original_date: str | None = None,
185191
) -> str:
186-
today = original_date or date.today().isoformat()
187192
header = (
188193
"Additional contexts have arrived while you were working. "
189194
"Finish your current task first, then process these in order."
190195
)
191196
ctx_parts = []
192197
for i, ctx in enumerate(contexts, 1):
198+
# Use each context's own original_date, fall back to today
199+
ctx_date = ctx.original_date or date.today().isoformat()
193200
ctx_parts.append(
194-
f"### New Context {i+count_bases}\n{ctx.distilled_context}"
201+
f"### New Context {i+count_bases}\nDate: {ctx_date}\n{ctx.distilled_context}"
195202
)
196203

197204
return f"""{header}
@@ -200,8 +207,6 @@ def pack_incoming_contexts(
200207
201208
## Available Skills (updated)
202209
{available_skills_str}
203-
204-
Today's date: {today}
205210
"""
206211

207212
@classmethod

src/server/core/acontext_core/schema/mq/learning.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Optional
44
from pydantic import BaseModel, field_validator
55
from ..utils import asUUID
6+
from ...env import LOG
67

78

89
class SkillLearnTask(BaseModel):
@@ -25,10 +26,12 @@ class SkillLearnDistilled(BaseModel):
2526

2627
@field_validator("original_date")
2728
@classmethod
28-
def validate_original_date(cls, v):
29+
def validate_original_date(cls, v, info):
2930
if v is None:
3031
return v
3132

33+
session_id = info.data.get("session_id")
34+
3235
# ISO format: YYYY-MM-DD
3336
try:
3437
date.fromisoformat(v)
@@ -44,6 +47,13 @@ def validate_original_date(cls, v):
4447
except ValueError:
4548
pass
4649

50+
# Validation failed - log warning before raising error
51+
LOG.warning(
52+
"skill_learner.original_date_validation_failed",
53+
session_id=str(session_id) if session_id else None,
54+
original_date=v,
55+
)
56+
4757
raise ValueError(
4858
"original_date must be 'YYYY-MM-DD' or 'YYYY/MM/DD (Day) HH:MM', "
4959
f"got: {v!r}"

src/server/core/acontext_core/service/skill_learner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ async def process_skill_distillation(body: SkillLearnTask, message: Message):
5252
original_date = None
5353
if not eil and session and session.configs:
5454
original_date = session.configs.get("original_date")
55+
LOG.info(
56+
"skill_learner.original_date_parsed",
57+
session_id=str(body.session_id),
58+
original_date=original_date,
59+
)
5560

5661
learning_space_id = ls_session.learning_space_id
5762
wide["learning_space_id"] = str(learning_space_id)

0 commit comments

Comments
 (0)