Fix/preference distillation original date#533
Conversation
User preferences distillation was missing original_date, causing skill learner to use today's date instead of the historical date. - Fetch session.configs.original_date at task agent start - Pass original_date when publishing SkillLearnDistilled for preferences Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c4aac51 to
8bc0276
Compare
|
CI Failure Analysis + Suggestion The 3 failing tests in Root cause: These tests mock Suggestion: Merge Roughly: original_date = None
async with DB_CLIENT.get_session_context() as db_session:
r_sess = await SD.fetch_session(db_session, session_id)
sess, _ = r_sess.unpack()
if sess and sess.configs:
original_date = sess.configs.get("original_date")
r = await TD.fetch_current_tasks(db_session, session_id)
tasks, eil = r.unpack()
if eil:
return r
r_plan = await TD.fetch_planning_task(db_session, session_id)
planning_task, _ = r_plan.unpack()
...This avoids an extra connection pool checkout and preserves the existing tests' expectations on |
Consolidate SD.fetch_session and TD.fetch_current_tasks into a single DB_CLIENT.get_session_context() block to avoid exhausting mock side effects in test_task_agent_atomicity.py tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GenerQAQ
left a comment
There was a problem hiding this comment.
LGTM! Clean fix — correctly wires original_date into the preferences distillation path.
One minor suggestion: consider mirroring the eil-guarded pattern from skill_learner.py (L51-58) for consistency and observability:
session, eil = r_sess.unpack()
original_date = None
if not eil and session and session.configs:
original_date = session.configs.get("original_date")
LOG.info("task_agent.original_date_parsed", session_id=str(session_id), original_date=original_date)Not a blocker — the current code is functionally correct.
Why We Need This PR?
Problem
When users upload historical chat messages with
original_dateset in session configs, the skill learner correctly uses the historical date for task distillation, but user preferences distillation was missing theoriginal_date.This caused preference MQ messages to have
original_date: null, leading to skill files being written with today's date instead of the historical session date.Production logs showed:
{"original_date": null, "task_id": "00000000-0000-0000-0000-000000000000", ...}task_id: "00000000-..."indicates user preferences distillation (not a real task).original_date: nullwas the bug.Root Cause
task_agent_curdintask.pyhas two code paths for publishingSkillLearnDistilled:original_date✓original_date✗Solution
Fetch
session.configs.original_dateat the start oftask_agent_curdand pass it when publishing preferences.Code Change
File:
src/server/core/acontext_core/llm/agent/task.pyImplementation Tasks
original_datefetching fromsession.configsintask_agent_curdDB_CLIENT.get_session_context()block (avoid breaking atomicity tests)original_datewhen publishingSkillLearnDistilledfor user preferencesFiles Changed
src/server/core/acontext_core/llm/agent/task.pyoriginal_datefetch and pass to preferences MQImpact Areas
Which part of Acontext would this feature affect?