mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-12 04:01:20 +00:00
Merge remote-tracking branch 'origin/worktree/session-format-05-v1-v2-chunk-migration' into worktree/session-format-06-v2-snapshot-rollout
# Conflicts: # apps/web/tests/scaffold.ts # apps/web/tests/subagent-conversation.e2e.ts # docs/config-catalog.i18n.yaml # docs/config-catalog.zh.md # packages/test-support/llm-replay/README.i18n.yaml # packages/test-support/llm-replay/README.md # packages/test-support/llm-replay/README.zh.md # packages/test-support/llm-replay/tests/llm-replay.spec.ts # snapshots/sdk/subagent-continuable-inheritance/session.1.v2.jsonl # snapshots/sdk/subagent-continuable/session.1.v2.jsonl # snapshots/sdk/subagent-dsh-sdk-diagnostic/session.v2.jsonl # snapshots/sdk/subagent-list-agents/session.1.v2.jsonl # snapshots/sdk/subagent-send-message/session.1.v2.jsonl # snapshots/session/agent-instructions/session.v2.jsonl # snapshots/session/headless.snapshot.ts # snapshots/web/schedule-catalog/session.v2.jsonl
This commit is contained in:
@@ -1872,7 +1872,7 @@ def expand_snapshot_stream_member(member: object) -> list[dict[str, object]]:
|
||||
return [chunk]
|
||||
packed_kinds = {
|
||||
"text-chunks": ("texts", "text-delta", "text"),
|
||||
"reasoning-chunks": ("reasoning", "reasoning-delta", "reasoning"),
|
||||
"reasoning-chunks": ("texts", "reasoning-delta", "text"),
|
||||
"tool-call-chunks": ("args", "tool-call-delta", "argumentsDelta"),
|
||||
}
|
||||
packed = packed_kinds.get(member_type)
|
||||
@@ -1942,11 +1942,14 @@ def expand_snapshot_assistant_event(value: object) -> list[object]:
|
||||
return expanded
|
||||
|
||||
|
||||
def normalize_session_format_comparison(value: object) -> object:
|
||||
def normalize_session_format_comparison(
|
||||
value: object,
|
||||
source_session_version: int | None = None,
|
||||
) -> object:
|
||||
"""Canonicalize only generation provenance that differs across immutable Session files."""
|
||||
if isinstance(value, list):
|
||||
return [
|
||||
normalize_session_format_comparison(expanded)
|
||||
normalize_session_format_comparison(expanded, source_session_version)
|
||||
for item in value
|
||||
for expanded in expand_snapshot_assistant_event(item)
|
||||
]
|
||||
@@ -1954,7 +1957,7 @@ def normalize_session_format_comparison(value: object) -> object:
|
||||
return value
|
||||
|
||||
normalized = {
|
||||
key: normalize_session_format_comparison(item)
|
||||
key: normalize_session_format_comparison(item, source_session_version)
|
||||
for key, item in value.items()
|
||||
}
|
||||
if normalized.get("type") == "session" and "version" in normalized:
|
||||
@@ -1972,6 +1975,7 @@ def normalize_session_format_comparison(value: object) -> object:
|
||||
if isinstance(normalized.get("type"), str) and "data" in normalized:
|
||||
normalized.pop("seq", None)
|
||||
normalized.pop("time", None)
|
||||
if source_session_version == 1 and normalized.get("type") == "assistant/message":
|
||||
normalized.pop("sourceEventSeqs", None)
|
||||
if normalized.get("type") == "session-log-deepseek/delivery-accepted":
|
||||
data = normalized.get("data")
|
||||
@@ -1992,11 +1996,15 @@ def normalize_session_format_comparison(value: object) -> object:
|
||||
def normalize_snapshot_comparison_text(name: str, content: str) -> str:
|
||||
"""Normalize Session generation provenance only while comparing committed expected outputs."""
|
||||
if name.startswith("session") and name.endswith(".jsonl"):
|
||||
parsed = [json.loads(line) for line in content.splitlines() if line]
|
||||
header = parsed[0] if parsed else None
|
||||
source_version = header.get("version") if isinstance(header, dict) else None
|
||||
if not isinstance(source_version, int):
|
||||
raise AssertionError(f"{name}: snapshot Session header has no integer format version")
|
||||
records = [
|
||||
normalize_session_format_comparison(expanded)
|
||||
for line in content.splitlines()
|
||||
if line
|
||||
for expanded in expand_snapshot_assistant_event(json.loads(line))
|
||||
normalize_session_format_comparison(expanded, source_version)
|
||||
for record in parsed
|
||||
for expanded in expand_snapshot_assistant_event(record)
|
||||
]
|
||||
return render_jsonl(records)
|
||||
if name.endswith(".json"):
|
||||
@@ -2016,7 +2024,7 @@ def compare_snapshot_files(
|
||||
) -> None:
|
||||
"""Write or exactly compare one scenario's expected snapshot files."""
|
||||
scenario = directory.name
|
||||
if update and tuple(files) != filenames:
|
||||
if tuple(files) != filenames:
|
||||
raise AssertionError(f"{scenario} snapshot builder produced {tuple(files)}, expected {filenames}")
|
||||
if update:
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user