Skip to content

Commit 9a8d1b6

Browse files
authored
test(core): add test for incoming contexts using own original_date (#529)
- Add test_uses_each_context_own_original_date - Verify each context uses its own date, not a shared one - Verify contexts without original_date fallback to today
1 parent 9a698bb commit 9a8d1b6

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/server/core/tests/llm/test_skill_learner_prompt.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,47 @@ def test_includes_finish_instruction(self):
135135
result = SkillLearnerPrompt.pack_incoming_contexts([ctx], "")
136136
assert "Finish your current task first" in result
137137

138+
def test_uses_each_context_own_original_date(self):
139+
"""pack_incoming_contexts uses each context's own original_date."""
140+
# Context with historical date
141+
ctx_a = SkillLearnDistilled(
142+
project_id=uuid.uuid4(),
143+
session_id=uuid.uuid4(),
144+
task_id=uuid.uuid4(),
145+
learning_space_id=uuid.uuid4(),
146+
distilled_context="## Task Analysis\nHistorical session A",
147+
original_date="2023/05/21 (Sun) 14:03",
148+
)
149+
# Context with different historical date
150+
ctx_b = SkillLearnDistilled(
151+
project_id=uuid.uuid4(),
152+
session_id=uuid.uuid4(),
153+
task_id=uuid.uuid4(),
154+
learning_space_id=uuid.uuid4(),
155+
distilled_context="## Task Analysis\nHistorical session B",
156+
original_date="2024/01/15 (Mon) 10:30",
157+
)
158+
# Context without original_date (should use today)
159+
ctx_c = SkillLearnDistilled(
160+
project_id=uuid.uuid4(),
161+
session_id=uuid.uuid4(),
162+
task_id=uuid.uuid4(),
163+
learning_space_id=uuid.uuid4(),
164+
distilled_context="## Task Analysis\nRecent session C",
165+
original_date=None,
166+
)
167+
168+
result = SkillLearnerPrompt.pack_incoming_contexts(
169+
[ctx_a, ctx_b, ctx_c], "- **skill-a**: desc"
170+
)
171+
172+
# Each context should have its own date
173+
assert "Date: 2023/05/21" in result
174+
assert "Date: 2024/01/15" in result
175+
assert "Date: 2026-04-01" in result # today's date fallback
176+
# Should NOT have a single "Today's date" at the end
177+
assert "Today's date:" not in result
178+
138179

139180
class TestToolSchemas:
140181
def test_returns_9_tools(self):

0 commit comments

Comments
 (0)